Various small changes

This commit is contained in:
Luck 2016-08-03 12:08:10 +02:00
parent 5e23b6961e
commit 56e11b8b85
No known key found for this signature in database
GPG Key ID: EFA9B3EC5FD90F8B
43 changed files with 86 additions and 103 deletions

View File

@ -5,7 +5,6 @@ import me.lucko.luckperms.api.LuckPermsApi;
import me.lucko.luckperms.api.implementation.ApiProvider; import me.lucko.luckperms.api.implementation.ApiProvider;
import me.lucko.luckperms.api.vault.VaultHook; import me.lucko.luckperms.api.vault.VaultHook;
import me.lucko.luckperms.data.Datastore; import me.lucko.luckperms.data.Datastore;
import me.lucko.luckperms.data.MySQLConfiguration;
import me.lucko.luckperms.data.methods.FlatfileDatastore; import me.lucko.luckperms.data.methods.FlatfileDatastore;
import me.lucko.luckperms.data.methods.MySQLDatastore; import me.lucko.luckperms.data.methods.MySQLDatastore;
import me.lucko.luckperms.data.methods.SQLiteDatastore; import me.lucko.luckperms.data.methods.SQLiteDatastore;
@ -60,12 +59,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin {
final String storageMethod = configuration.getStorageMethod(); final String storageMethod = configuration.getStorageMethod();
if (storageMethod.equalsIgnoreCase("mysql")) { if (storageMethod.equalsIgnoreCase("mysql")) {
getLogger().info("Using MySQL as storage method."); getLogger().info("Using MySQL as storage method.");
datastore = new MySQLDatastore(this, new MySQLConfiguration( datastore = new MySQLDatastore(this, configuration.getDatabaseValues());
configuration.getDatabaseValue("address"),
configuration.getDatabaseValue("database"),
configuration.getDatabaseValue("username"),
configuration.getDatabaseValue("password")
));
} else if (storageMethod.equalsIgnoreCase("sqlite")) { } else if (storageMethod.equalsIgnoreCase("sqlite")) {
getLogger().info("Using SQLite as storage method."); getLogger().info("Using SQLite as storage method.");
datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite")); datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite"));

View File

@ -21,6 +21,7 @@ public class PlayerListener implements Listener {
@EventHandler @EventHandler
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) { public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) {
final long startTime = System.currentTimeMillis();
if (!plugin.getDatastore().isAcceptingLogins()) { if (!plugin.getDatastore().isAcceptingLogins()) {
// Datastore is disabled, prevent players from joining the server // Datastore is disabled, prevent players from joining the server
e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, KICK_MESSAGE); e.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, KICK_MESSAGE);
@ -43,6 +44,10 @@ public class PlayerListener implements Listener {
} }
plugin.getDatastore().loadOrCreateUser(cache.getUUID(e.getUniqueId()), e.getName()); plugin.getDatastore().loadOrCreateUser(cache.getUUID(e.getUniqueId()), e.getName());
final long time = System.currentTimeMillis() - startTime;
if (time >= 1000) {
plugin.getLogger().warning("Processing login for " + e.getName() + " took " + time + "ms.");
}
} }
@EventHandler @EventHandler

View File

@ -4,7 +4,6 @@ import lombok.Getter;
import me.lucko.luckperms.api.implementation.ApiProvider; import me.lucko.luckperms.api.implementation.ApiProvider;
import me.lucko.luckperms.commands.CommandManager; import me.lucko.luckperms.commands.CommandManager;
import me.lucko.luckperms.data.Datastore; import me.lucko.luckperms.data.Datastore;
import me.lucko.luckperms.data.MySQLConfiguration;
import me.lucko.luckperms.data.methods.FlatfileDatastore; import me.lucko.luckperms.data.methods.FlatfileDatastore;
import me.lucko.luckperms.data.methods.MySQLDatastore; import me.lucko.luckperms.data.methods.MySQLDatastore;
import me.lucko.luckperms.groups.GroupManager; import me.lucko.luckperms.groups.GroupManager;
@ -51,12 +50,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin {
final String storageMethod = configuration.getStorageMethod(); final String storageMethod = configuration.getStorageMethod();
if (storageMethod.equalsIgnoreCase("mysql")) { if (storageMethod.equalsIgnoreCase("mysql")) {
getLogger().info("Using MySQL as storage method."); getLogger().info("Using MySQL as storage method.");
datastore = new MySQLDatastore(this, new MySQLConfiguration( datastore = new MySQLDatastore(this, configuration.getDatabaseValues());
configuration.getDatabaseValue("address"),
configuration.getDatabaseValue("database"),
configuration.getDatabaseValue("username"),
configuration.getDatabaseValue("password")
));
} else if (storageMethod.equalsIgnoreCase("flatfile")) { } else if (storageMethod.equalsIgnoreCase("flatfile")) {
getLogger().info("Using Flatfile (JSON) as storage method."); getLogger().info("Using Flatfile (JSON) as storage method.");
datastore = new FlatfileDatastore(this, getDataFolder()); datastore = new FlatfileDatastore(this, getDataFolder());

View File

@ -34,6 +34,7 @@ public class PlayerListener implements Listener {
Offline mode. */ Offline mode. */
e.registerIntent(plugin); e.registerIntent(plugin);
plugin.doAsync(() -> { plugin.doAsync(() -> {
final long startTime = System.currentTimeMillis();
final UuidCache cache = plugin.getUuidCache(); final UuidCache cache = plugin.getUuidCache();
final PendingConnection c = e.getConnection(); final PendingConnection c = e.getConnection();
@ -54,6 +55,10 @@ public class PlayerListener implements Listener {
// We have to make a new user on this thread whilst the connection is being held, or we get concurrency issues as the Bukkit server // We have to make a new user on this thread whilst the connection is being held, or we get concurrency issues as the Bukkit server
// and the BungeeCord server try to make a new user at the same time. // and the BungeeCord server try to make a new user at the same time.
plugin.getDatastore().loadOrCreateUser(cache.getUUID(c.getUniqueId()), c.getName()); plugin.getDatastore().loadOrCreateUser(cache.getUUID(c.getUniqueId()), c.getName());
final long time = System.currentTimeMillis() - startTime;
if (time >= 1000) {
plugin.getLogger().warning("Processing login for " + c.getName() + " took " + time + "ms.");
}
e.completeIntent(plugin); e.completeIntent(plugin);
}); });
} }

View File

@ -2,6 +2,8 @@ package me.lucko.luckperms.commands;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@UtilityClass @UtilityClass
@ -14,19 +16,19 @@ public class Predicate {
return t -> true; return t -> true;
} }
public static java.util.function.Predicate<Integer> notinRange(Integer start, Integer end) { public static java.util.function.Predicate<Integer> notInRange(Integer start, Integer end) {
return inverse(inRange(start, end)); return inverse(inRange(start, end));
} }
public static java.util.function.Predicate<Integer> inRange(Integer start, Integer end) { public static java.util.function.Predicate<Integer> inRange(Integer start, Integer end) {
return isOneOf(IntStream.rangeClosed(start, end).boxed().toArray(Integer[]::new)); return isOneOf(IntStream.rangeClosed(start, end).boxed().collect(Collectors.toSet()));
} }
public static <T> java.util.function.Predicate<T> notOneOf(T[] ts) { public static <T> java.util.function.Predicate<T> notOneOf(Set<T> ts) {
return inverse(isOneOf(ts)); return inverse(isOneOf(ts));
} }
public static <T> java.util.function.Predicate<T> isOneOf(T[] ta) { public static <T> java.util.function.Predicate<T> isOneOf(Set<T> ta) {
return t -> { return t -> {
for (T i : ta) { for (T i : ta) {
if (i == t) { if (i == t) {
@ -37,6 +39,14 @@ public class Predicate {
}; };
} }
public static <T> java.util.function.Predicate<T> not(T t) {
return inverse(is(t));
}
public static <T> java.util.function.Predicate<T> is(T t) {
return t2 -> t == t2;
}
public static <T> java.util.function.Predicate<T> inverse(java.util.function.Predicate<T> t) { public static <T> java.util.function.Predicate<T> inverse(java.util.function.Predicate<T> t) {
return t2 -> !t.test(t2); return t2 -> !t.test(t2);
} }

View File

@ -2,6 +2,7 @@ package me.lucko.luckperms.commands;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.api.data.Callback; import me.lucko.luckperms.api.data.Callback;
import me.lucko.luckperms.constants.Permission;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -10,13 +11,21 @@ import java.util.List;
* An extension of {@link MainCommand} for implementations without any subcommands * An extension of {@link MainCommand} for implementations without any subcommands
*/ */
public class SingleMainCommand extends MainCommand<Object> { public class SingleMainCommand extends MainCommand<Object> {
public SingleMainCommand(String name, String usage, int requiredArgsLength) { private final Permission permission;
public SingleMainCommand(String name, String usage, int requiredArgsLength, Permission permission) {
super(name, usage, requiredArgsLength); super(name, usage, requiredArgsLength);
this.permission = permission;
}
@Override
protected void execute(LuckPermsPlugin plugin, Sender sender, List<String> args, String label) {
// Do nothing, allow the implementation to override this
} }
@Override @Override
protected void getTarget(String target, LuckPermsPlugin plugin, Sender sender, Callback onSuccess) { protected void getTarget(String target, LuckPermsPlugin plugin, Sender sender, Callback onSuccess) {
// Do nothing, don't run callback
} }
@Override @Override
@ -33,4 +42,9 @@ public class SingleMainCommand extends MainCommand<Object> {
public List<SubCommand<Object>> getSubCommands() { public List<SubCommand<Object>> getSubCommands() {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
protected boolean isAuthorized(Sender sender) {
return permission.isAuthorized(sender);
}
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
public class CreateGroup extends SingleMainCommand { public class CreateGroup extends SingleMainCommand {
public CreateGroup() { public CreateGroup() {
super("CreateGroup", "/%s creategroup <group>", 1); super("CreateGroup", "/%s creategroup <group>", 1, Permission.CREATE_GROUP);
} }
@Override @Override
@ -48,9 +48,4 @@ public class CreateGroup extends SingleMainCommand {
} }
}); });
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.CREATE_GROUP.isAuthorized(sender);
}
} }

View File

@ -15,7 +15,7 @@ import java.util.stream.Collectors;
public class DeleteGroup extends SingleMainCommand { public class DeleteGroup extends SingleMainCommand {
public DeleteGroup() { public DeleteGroup() {
super("DeleteGroup", "/%s deletegroup <group>", 1); super("DeleteGroup", "/%s deletegroup <group>", 1, Permission.DELETE_GROUP);
} }
@Override @Override
@ -73,9 +73,4 @@ public class DeleteGroup extends SingleMainCommand {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.DELETE_GROUP.isAuthorized(sender);
}
} }

View File

@ -12,7 +12,7 @@ import java.util.List;
public class ListGroups extends SingleMainCommand { public class ListGroups extends SingleMainCommand {
public ListGroups() { public ListGroups() {
super("ListGroups", "/%s listgroups", 0); super("ListGroups", "/%s listgroups", 0, Permission.LIST_GROUPS);
} }
@Override @Override
@ -25,9 +25,4 @@ public class ListGroups extends SingleMainCommand {
} }
}); });
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.LIST_GROUPS.isAuthorized(sender);
}
} }

View File

@ -16,7 +16,7 @@ public class GroupHasPerm extends SubCommand<Group> {
public GroupHasPerm() { public GroupHasPerm() {
super("haspermission", "Checks to see if a group has a certain permission node", super("haspermission", "Checks to see if a group has a certain permission node",
"/%s group <group> haspermission <node> [server] [world]", Permission.GROUP_HASPERMISSION, "/%s group <group> haspermission <node> [server] [world]", Permission.GROUP_HASPERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class GroupInheritsPerm extends SubCommand<Group> {
public GroupInheritsPerm() { public GroupInheritsPerm() {
super("inheritspermission", "Checks to see if a group inherits a certain permission node", super("inheritspermission", "Checks to see if a group inherits a certain permission node",
"/%s group <group> inheritspermission <node> [server] [world]", Permission.GROUP_INHERITSPERMISSION, "/%s group <group> inheritspermission <node> [server] [world]", Permission.GROUP_INHERITSPERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class GroupSetInherit extends SubCommand<Group> {
public GroupSetInherit() { public GroupSetInherit() {
super("setinherit", "Sets another group for this group to inherit permissions from", super("setinherit", "Sets another group for this group to inherit permissions from",
"/%s group <group> setinherit <group> [server] [world]", Permission.GROUP_SETINHERIT, "/%s group <group> setinherit <group> [server] [world]", Permission.GROUP_SETINHERIT,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -15,7 +15,7 @@ import java.util.List;
public class GroupSetPermission extends SubCommand<Group> { public class GroupSetPermission extends SubCommand<Group> {
public GroupSetPermission() { public GroupSetPermission() {
super("set", "Sets a permission for a group", "/%s group <group> set <node> <true|false> [server] [world]", super("set", "Sets a permission for a group", "/%s group <group> set <node> <true|false> [server] [world]",
Permission.GROUP_SETPERMISSION, Predicate.notinRange(2, 4)); Permission.GROUP_SETPERMISSION, Predicate.notInRange(2, 4));
} }
@Override @Override

View File

@ -17,7 +17,7 @@ public class GroupSetTempInherit extends SubCommand<Group> {
public GroupSetTempInherit() { public GroupSetTempInherit() {
super("settempinherit", "Sets another group for this group to inherit permissions from temporarily", super("settempinherit", "Sets another group for this group to inherit permissions from temporarily",
"/%s group <group> settempinherit <group> <duration> [server] [world]", "/%s group <group> settempinherit <group> <duration> [server] [world]",
Permission.GROUP_SET_TEMP_INHERIT, Predicate.notinRange(2, 4)); Permission.GROUP_SET_TEMP_INHERIT, Predicate.notInRange(2, 4));
} }
@Override @Override

View File

@ -17,7 +17,7 @@ public class GroupSetTempPermission extends SubCommand<Group> {
public GroupSetTempPermission() { public GroupSetTempPermission() {
super("settemp", "Sets a temporary permission for a group", super("settemp", "Sets a temporary permission for a group",
"/%s group <group> settemp <node> <true|false> <duration> [server] [world]", "/%s group <group> settemp <node> <true|false> <duration> [server] [world]",
Permission.GROUP_SET_TEMP_PERMISSION, Predicate.notinRange(3, 5)); Permission.GROUP_SET_TEMP_PERMISSION, Predicate.notInRange(3, 5));
} }
@Override @Override

View File

@ -15,7 +15,7 @@ import java.util.List;
public class GroupUnSetPermission extends SubCommand<Group> { public class GroupUnSetPermission extends SubCommand<Group> {
public GroupUnSetPermission() { public GroupUnSetPermission() {
super("unset", "Unsets a permission for a group", "/%s group <group> unset <node> [server] [world]", super("unset", "Unsets a permission for a group", "/%s group <group> unset <node> [server] [world]",
Permission.GROUP_UNSETPERMISSION, Predicate.notinRange(1, 3)); Permission.GROUP_UNSETPERMISSION, Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class GroupUnsetInherit extends SubCommand<Group> {
public GroupUnsetInherit() { public GroupUnsetInherit() {
super("unsetinherit", "Unsets another group for this group to inherit permissions from", super("unsetinherit", "Unsets another group for this group to inherit permissions from",
"/%s group <group> unsetinherit <group> [server] [world]", Permission.GROUP_UNSETINHERIT, "/%s group <group> unsetinherit <group> [server] [world]", Permission.GROUP_UNSETINHERIT,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class GroupUnsetTempInherit extends SubCommand<Group> {
public GroupUnsetTempInherit() { public GroupUnsetTempInherit() {
super("unsettempinherit", "Unsets another group for this group to inherit permissions from", super("unsettempinherit", "Unsets another group for this group to inherit permissions from",
"/%s group <group> unsettempinherit <group> [server] [world]", Permission.GROUP_UNSET_TEMP_INHERIT, "/%s group <group> unsettempinherit <group> [server] [world]", Permission.GROUP_UNSET_TEMP_INHERIT,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class GroupUnsetTempPermission extends SubCommand<Group> {
public GroupUnsetTempPermission() { public GroupUnsetTempPermission() {
super("unsettemp", "Unsets a temporary permission for a group", super("unsettemp", "Unsets a temporary permission for a group",
"/%s group <group> unsettemp <node> [server] [world]", Permission.GROUP_UNSET_TEMP_PERMISSION, "/%s group <group> unsettemp <node> [server] [world]", Permission.GROUP_UNSET_TEMP_PERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -10,7 +10,7 @@ import java.util.List;
public class DebugCommand extends SingleMainCommand { public class DebugCommand extends SingleMainCommand {
public DebugCommand() { public DebugCommand() {
super("Debug", "/%s debug", 0); super("Debug", "/%s debug", 0, Permission.DEBUG);
} }
@Override @Override
@ -19,9 +19,4 @@ public class DebugCommand extends SingleMainCommand {
plugin.getGroupManager().getGroups().size(), plugin.getTrackManager().getTracks().size() plugin.getGroupManager().getGroups().size(), plugin.getTrackManager().getTracks().size()
); );
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.DEBUG.isAuthorized(sender);
}
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
public class InfoCommand extends SingleMainCommand { public class InfoCommand extends SingleMainCommand {
public InfoCommand() { public InfoCommand() {
super("Info", "/%s info", 0); super("Info", "/%s info", 0, Permission.INFO);
} }
@Override @Override
@ -20,9 +20,4 @@ public class InfoCommand extends SingleMainCommand {
Message.INFO.send(sender, plugin.getVersion(), plugin.getDatastore().getName(), c.getServer(), Message.INFO.send(sender, plugin.getVersion(), plugin.getDatastore().getName(), c.getServer(),
c.getDefaultGroupName(), c.getSyncTime(), c.getIncludeGlobalPerms(), c.getOnlineMode()); c.getDefaultGroupName(), c.getSyncTime(), c.getIncludeGlobalPerms(), c.getOnlineMode());
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.INFO.isAuthorized(sender);
}
} }

View File

@ -10,7 +10,7 @@ import java.util.List;
public class SyncCommand extends SingleMainCommand { public class SyncCommand extends SingleMainCommand {
public SyncCommand() { public SyncCommand() {
super("Sync", "/%s sync", 0); super("Sync", "/%s sync", 0, Permission.SYNC);
} }
@Override @Override
@ -18,9 +18,4 @@ public class SyncCommand extends SingleMainCommand {
Message.UPDATE_TASK_RUN.send(sender); Message.UPDATE_TASK_RUN.send(sender);
plugin.runUpdateTask(); plugin.runUpdateTask();
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.SYNC.isAuthorized(sender);
}
} }

View File

@ -11,7 +11,7 @@ import java.util.List;
public class CreateTrack extends SingleMainCommand { public class CreateTrack extends SingleMainCommand {
public CreateTrack() { public CreateTrack() {
super("CreateTrack", "/%s createtrack <track>", 1); super("CreateTrack", "/%s createtrack <track>", 1, Permission.CREATE_TRACK);
} }
@Override @Override
@ -48,9 +48,4 @@ public class CreateTrack extends SingleMainCommand {
} }
}); });
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.CREATE_TRACK.isAuthorized(sender);
}
} }

View File

@ -15,7 +15,7 @@ import java.util.stream.Collectors;
public class DeleteTrack extends SingleMainCommand { public class DeleteTrack extends SingleMainCommand {
public DeleteTrack() { public DeleteTrack() {
super("DeleteTrack", "/%s deletetrack <track>", 1); super("DeleteTrack", "/%s deletetrack <track>", 1, Permission.DELETE_TRACK);
} }
@Override @Override
@ -68,9 +68,4 @@ public class DeleteTrack extends SingleMainCommand {
return Collections.emptyList(); return Collections.emptyList();
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.DELETE_TRACK.isAuthorized(sender);
}
} }

View File

@ -12,7 +12,7 @@ import java.util.List;
public class ListTracks extends SingleMainCommand { public class ListTracks extends SingleMainCommand {
public ListTracks() { public ListTracks() {
super("ListTracks", "/%s listtracks", 0); super("ListTracks", "/%s listtracks", 0, Permission.LIST_TRACKS);
} }
@Override @Override
@ -25,9 +25,4 @@ public class ListTracks extends SingleMainCommand {
} }
}); });
} }
@Override
protected boolean isAuthorized(Sender sender) {
return Permission.LIST_TRACKS.isAuthorized(sender);
}
} }

View File

@ -16,7 +16,7 @@ import java.util.List;
public class TrackAppend extends SubCommand<Track> { public class TrackAppend extends SubCommand<Track> {
public TrackAppend() { public TrackAppend() {
super("append", "Appends a group onto the end of the track", "/%s track <track> append <group>", super("append", "Appends a group onto the end of the track", "/%s track <track> append <group>",
Permission.TRACK_APPEND, Predicate.notOneOf(new Integer[]{1})); Permission.TRACK_APPEND, Predicate.not(1));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ import java.util.List;
public class TrackInsert extends SubCommand<Track> { public class TrackInsert extends SubCommand<Track> {
public TrackInsert() { public TrackInsert() {
super("insert", "Inserts a group at a given position along the track", super("insert", "Inserts a group at a given position along the track",
"/%s track <track> insert <group> <position>", Permission.TRACK_INSERT, Predicate.notOneOf(new Integer[]{2})); "/%s track <track> insert <group> <position>", Permission.TRACK_INSERT, Predicate.not(2));
} }
@Override @Override

View File

@ -14,7 +14,7 @@ import java.util.List;
public class TrackRemove extends SubCommand<Track> { public class TrackRemove extends SubCommand<Track> {
public TrackRemove() { public TrackRemove() {
super("remove", "Removes a group from the track", "/%s track <track> remove <group>", Permission.TRACK_REMOVE, super("remove", "Removes a group from the track", "/%s track <track> remove <group>", Permission.TRACK_REMOVE,
Predicate.notOneOf(new Integer[]{1})); Predicate.not(1));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ import java.util.List;
public class UserAddGroup extends SubCommand<User> { public class UserAddGroup extends SubCommand<User> {
public UserAddGroup() { public UserAddGroup() {
super("addgroup", "Adds the user to a group", "/%s user <user> addgroup <group> [server] [world]", super("addgroup", "Adds the user to a group", "/%s user <user> addgroup <group> [server] [world]",
Permission.USER_ADDGROUP, Predicate.notinRange(1, 3)); Permission.USER_ADDGROUP, Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -18,7 +18,7 @@ public class UserAddTempGroup extends SubCommand<User> {
public UserAddTempGroup() { public UserAddTempGroup() {
super("addtempgroup", "Adds the user to a group temporarily", super("addtempgroup", "Adds the user to a group temporarily",
"/%s user <user> addtempgroup <group> <duration> [server] [world]", Permission.USER_ADDTEMPGROUP, "/%s user <user> addtempgroup <group> <duration> [server] [world]", Permission.USER_ADDTEMPGROUP,
Predicate.notinRange(2, 4)); Predicate.notInRange(2, 4));
} }
@Override @Override

View File

@ -18,7 +18,7 @@ import java.util.List;
public class UserDemote extends SubCommand<User> { public class UserDemote extends SubCommand<User> {
public UserDemote() { public UserDemote() {
super("demote", "Demotes a user along a track", "/%s user <user> demote <track>", Permission.USER_DEMOTE, super("demote", "Demotes a user along a track", "/%s user <user> demote <track>", Permission.USER_DEMOTE,
Predicate.notOneOf(new Integer[]{1})); Predicate.not(1));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class UserHasPerm extends SubCommand<User> {
public UserHasPerm() { public UserHasPerm() {
super("haspermission", "Checks to see if a user has a certain permission node", super("haspermission", "Checks to see if a user has a certain permission node",
"/%s user <user> haspermission <node> [server] [world]", Permission.USER_HASPERMISSION, "/%s user <user> haspermission <node> [server] [world]", Permission.USER_HASPERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class UserInheritsPerm extends SubCommand<User> {
public UserInheritsPerm() { public UserInheritsPerm() {
super("inheritspermission", "Checks to see if a user inherits a certain permission node", super("inheritspermission", "Checks to see if a user inherits a certain permission node",
"/%s user <user> inheritspermission <node> [server] [world]", Permission.USER_INHERITSPERMISSION, "/%s user <user> inheritspermission <node> [server] [world]", Permission.USER_INHERITSPERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -18,7 +18,7 @@ import java.util.List;
public class UserPromote extends SubCommand<User> { public class UserPromote extends SubCommand<User> {
public UserPromote() { public UserPromote() {
super("promote", "Promotes the user along a track", "/%s user <user> promote <track>", Permission.USER_PROMOTE, super("promote", "Promotes the user along a track", "/%s user <user> promote <track>", Permission.USER_PROMOTE,
Predicate.notOneOf(new Integer[]{1})); Predicate.not(1));
} }
@Override @Override

View File

@ -15,7 +15,7 @@ import java.util.List;
public class UserRemoveGroup extends SubCommand<User> { public class UserRemoveGroup extends SubCommand<User> {
public UserRemoveGroup() { public UserRemoveGroup() {
super("removegroup", "Removes a user from a group", "/%s user <user> removegroup <group> [server] [world]", super("removegroup", "Removes a user from a group", "/%s user <user> removegroup <group> [server] [world]",
Permission.USER_REMOVEGROUP, Predicate.notinRange(1, 3)); Permission.USER_REMOVEGROUP, Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class UserRemoveTempGroup extends SubCommand<User> {
public UserRemoveTempGroup() { public UserRemoveTempGroup() {
super("removetempgroup", "Removes a user from a temporary group", super("removetempgroup", "Removes a user from a temporary group",
"/%s user <user> removetempgroup <group> [server] [world]", Permission.USER_REMOVETEMPGROUP, "/%s user <user> removetempgroup <group> [server] [world]", Permission.USER_REMOVETEMPGROUP,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class UserSetPermission extends SubCommand<User> {
public UserSetPermission() { public UserSetPermission() {
super("set", "Sets a permission for a user", super("set", "Sets a permission for a user",
"/%s user <user> set <node> <true|false> [server] [world]", Permission.USER_SETPERMISSION, "/%s user <user> set <node> <true|false> [server] [world]", Permission.USER_SETPERMISSION,
Predicate.notinRange(2, 4)); Predicate.notInRange(2, 4));
} }
@Override @Override

View File

@ -14,7 +14,7 @@ import java.util.List;
public class UserSetPrimaryGroup extends SubCommand<User> { public class UserSetPrimaryGroup extends SubCommand<User> {
public UserSetPrimaryGroup() { public UserSetPrimaryGroup() {
super("setprimarygroup", "Sets a users primary group", super("setprimarygroup", "Sets a users primary group",
"/%s user <user> setprimarygroup <group>", Permission.USER_SETPRIMARYGROUP, Predicate.notOneOf(new Integer[]{1})); "/%s user <user> setprimarygroup <group>", Permission.USER_SETPRIMARYGROUP, Predicate.not(1));
} }
@Override @Override

View File

@ -17,7 +17,7 @@ public class UserSetTempPermission extends SubCommand<User> {
public UserSetTempPermission() { public UserSetTempPermission() {
super("settemp", "Sets a temporary permission for a user", super("settemp", "Sets a temporary permission for a user",
"/%s user <user> settemp <node> <true|false> <duration> [server] [world]", "/%s user <user> settemp <node> <true|false> <duration> [server] [world]",
Permission.USER_SET_TEMP_PERMISSION, Predicate.notinRange(3, 5)); Permission.USER_SET_TEMP_PERMISSION, Predicate.notInRange(3, 5));
} }
@Override @Override

View File

@ -15,7 +15,7 @@ import java.util.List;
public class UserShowPos extends SubCommand<User> { public class UserShowPos extends SubCommand<User> {
public UserShowPos() { public UserShowPos() {
super("showpos", "Shows a users position on a track", "/%s user <user> showpos <track>", Permission.USER_SHOWPOS, super("showpos", "Shows a users position on a track", "/%s user <user> showpos <track>", Permission.USER_SHOWPOS,
Predicate.notOneOf(new Integer[]{1})); Predicate.not(1));
} }
@Override @Override

View File

@ -15,7 +15,7 @@ import java.util.List;
public class UserUnSetPermission extends SubCommand<User> { public class UserUnSetPermission extends SubCommand<User> {
public UserUnSetPermission() { public UserUnSetPermission() {
super("unset", "Unsets a permission for a user", super("unset", "Unsets a permission for a user",
"/%s user <user> unset <node> [server] [world]", Permission.USER_UNSETPERMISSION, Predicate.notinRange(1, 3)); "/%s user <user> unset <node> [server] [world]", Permission.USER_UNSETPERMISSION, Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -16,7 +16,7 @@ public class UserUnsetTempPermission extends SubCommand<User> {
public UserUnsetTempPermission() { public UserUnsetTempPermission() {
super("unsettemp", "Unsets a temporary permission for a user", super("unsettemp", "Unsets a temporary permission for a user",
"/%s user <user> unsettemp <node> [server] [world]", Permission.USER_UNSET_TEMP_PERMISSION, "/%s user <user> unsettemp <node> [server] [world]", Permission.USER_UNSET_TEMP_PERMISSION,
Predicate.notinRange(1, 3)); Predicate.notInRange(1, 3));
} }
@Override @Override

View File

@ -3,6 +3,7 @@ package me.lucko.luckperms.utils;
import lombok.AccessLevel; import lombok.AccessLevel;
import lombok.Getter; import lombok.Getter;
import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.LuckPermsPlugin;
import me.lucko.luckperms.data.MySQLConfiguration;
public abstract class LPConfiguration<T extends LuckPermsPlugin> { public abstract class LPConfiguration<T extends LuckPermsPlugin> {
@ -65,8 +66,13 @@ public abstract class LPConfiguration<T extends LuckPermsPlugin> {
return getBoolean("online-mode", true); return getBoolean("online-mode", true);
} }
public String getDatabaseValue(String value) { public MySQLConfiguration getDatabaseValues() {
return getString("sql." + value, null); return new MySQLConfiguration(
getString("sql.address", null),
getString("sql.database", null),
getString("sql.username", null),
getString("sql.password", null)
);
} }
public String getStorageMethod() { public String getStorageMethod() {