diff --git a/bukkit/src/main/java/me/lucko/luckperms/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/LPBukkitPlugin.java index b5d31435..307453d9 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/LPBukkitPlugin.java @@ -5,7 +5,6 @@ import me.lucko.luckperms.api.LuckPermsApi; import me.lucko.luckperms.api.implementation.ApiProvider; import me.lucko.luckperms.api.vault.VaultHook; 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.MySQLDatastore; import me.lucko.luckperms.data.methods.SQLiteDatastore; @@ -60,12 +59,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { final String storageMethod = configuration.getStorageMethod(); if (storageMethod.equalsIgnoreCase("mysql")) { getLogger().info("Using MySQL as storage method."); - datastore = new MySQLDatastore(this, new MySQLConfiguration( - configuration.getDatabaseValue("address"), - configuration.getDatabaseValue("database"), - configuration.getDatabaseValue("username"), - configuration.getDatabaseValue("password") - )); + datastore = new MySQLDatastore(this, configuration.getDatabaseValues()); } else if (storageMethod.equalsIgnoreCase("sqlite")) { getLogger().info("Using SQLite as storage method."); datastore = new SQLiteDatastore(this, new File(getDataFolder(), "luckperms.sqlite")); diff --git a/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java b/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java index a553c9bd..903efbde 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java +++ b/bukkit/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java @@ -21,6 +21,7 @@ public class PlayerListener implements Listener { @EventHandler public void onPlayerPreLogin(AsyncPlayerPreLoginEvent e) { + final long startTime = System.currentTimeMillis(); if (!plugin.getDatastore().isAcceptingLogins()) { // Datastore is disabled, prevent players from joining the server 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()); + final long time = System.currentTimeMillis() - startTime; + if (time >= 1000) { + plugin.getLogger().warning("Processing login for " + e.getName() + " took " + time + "ms."); + } } @EventHandler diff --git a/bungee/src/main/java/me/lucko/luckperms/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/LPBungeePlugin.java index 91e06deb..44794719 100644 --- a/bungee/src/main/java/me/lucko/luckperms/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/LPBungeePlugin.java @@ -4,7 +4,6 @@ import lombok.Getter; import me.lucko.luckperms.api.implementation.ApiProvider; import me.lucko.luckperms.commands.CommandManager; 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.MySQLDatastore; import me.lucko.luckperms.groups.GroupManager; @@ -51,12 +50,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { final String storageMethod = configuration.getStorageMethod(); if (storageMethod.equalsIgnoreCase("mysql")) { getLogger().info("Using MySQL as storage method."); - datastore = new MySQLDatastore(this, new MySQLConfiguration( - configuration.getDatabaseValue("address"), - configuration.getDatabaseValue("database"), - configuration.getDatabaseValue("username"), - configuration.getDatabaseValue("password") - )); + datastore = new MySQLDatastore(this, configuration.getDatabaseValues()); } else if (storageMethod.equalsIgnoreCase("flatfile")) { getLogger().info("Using Flatfile (JSON) as storage method."); datastore = new FlatfileDatastore(this, getDataFolder()); diff --git a/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java b/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java index c47bc967..1b7971bf 100644 --- a/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/listeners/PlayerListener.java @@ -34,6 +34,7 @@ public class PlayerListener implements Listener { Offline mode. */ e.registerIntent(plugin); plugin.doAsync(() -> { + final long startTime = System.currentTimeMillis(); final UuidCache cache = plugin.getUuidCache(); 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 // and the BungeeCord server try to make a new user at the same time. 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); }); } diff --git a/common/src/main/java/me/lucko/luckperms/commands/Predicate.java b/common/src/main/java/me/lucko/luckperms/commands/Predicate.java index a694e383..4ec7e08d 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/Predicate.java +++ b/common/src/main/java/me/lucko/luckperms/commands/Predicate.java @@ -2,6 +2,8 @@ package me.lucko.luckperms.commands; import lombok.experimental.UtilityClass; +import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.IntStream; @UtilityClass @@ -14,19 +16,19 @@ public class Predicate { return t -> true; } - public static java.util.function.Predicate notinRange(Integer start, Integer end) { + public static java.util.function.Predicate notInRange(Integer start, Integer end) { return inverse(inRange(start, end)); } public static java.util.function.Predicate 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 java.util.function.Predicate notOneOf(T[] ts) { + public static java.util.function.Predicate notOneOf(Set ts) { return inverse(isOneOf(ts)); } - public static java.util.function.Predicate isOneOf(T[] ta) { + public static java.util.function.Predicate isOneOf(Set ta) { return t -> { for (T i : ta) { if (i == t) { @@ -37,6 +39,14 @@ public class Predicate { }; } + public static java.util.function.Predicate not(T t) { + return inverse(is(t)); + } + + public static java.util.function.Predicate is(T t) { + return t2 -> t == t2; + } + public static java.util.function.Predicate inverse(java.util.function.Predicate t) { return t2 -> !t.test(t2); } diff --git a/common/src/main/java/me/lucko/luckperms/commands/SingleMainCommand.java b/common/src/main/java/me/lucko/luckperms/commands/SingleMainCommand.java index 224f4399..f85ac837 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/SingleMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/SingleMainCommand.java @@ -2,6 +2,7 @@ package me.lucko.luckperms.commands; import me.lucko.luckperms.LuckPermsPlugin; import me.lucko.luckperms.api.data.Callback; +import me.lucko.luckperms.constants.Permission; import java.util.Collections; import java.util.List; @@ -10,13 +11,21 @@ import java.util.List; * An extension of {@link MainCommand} for implementations without any subcommands */ public class SingleMainCommand extends MainCommand { - 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); + this.permission = permission; + } + + @Override + protected void execute(LuckPermsPlugin plugin, Sender sender, List args, String label) { + // Do nothing, allow the implementation to override this } @Override protected void getTarget(String target, LuckPermsPlugin plugin, Sender sender, Callback onSuccess) { - + // Do nothing, don't run callback } @Override @@ -33,4 +42,9 @@ public class SingleMainCommand extends MainCommand { public List> getSubCommands() { return Collections.emptyList(); } + + @Override + protected boolean isAuthorized(Sender sender) { + return permission.isAuthorized(sender); + } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/CreateGroup.java b/common/src/main/java/me/lucko/luckperms/commands/group/CreateGroup.java index 0d2c958a..1251e849 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/CreateGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/CreateGroup.java @@ -11,7 +11,7 @@ import java.util.List; public class CreateGroup extends SingleMainCommand { public CreateGroup() { - super("CreateGroup", "/%s creategroup ", 1); + super("CreateGroup", "/%s creategroup ", 1, Permission.CREATE_GROUP); } @Override @@ -48,9 +48,4 @@ public class CreateGroup extends SingleMainCommand { } }); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.CREATE_GROUP.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/DeleteGroup.java b/common/src/main/java/me/lucko/luckperms/commands/group/DeleteGroup.java index 53b4a37a..aa1a6916 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/DeleteGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/DeleteGroup.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; public class DeleteGroup extends SingleMainCommand { public DeleteGroup() { - super("DeleteGroup", "/%s deletegroup ", 1); + super("DeleteGroup", "/%s deletegroup ", 1, Permission.DELETE_GROUP); } @Override @@ -73,9 +73,4 @@ public class DeleteGroup extends SingleMainCommand { return Collections.emptyList(); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.DELETE_GROUP.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/ListGroups.java b/common/src/main/java/me/lucko/luckperms/commands/group/ListGroups.java index acfbfdc7..6c9fa49b 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/ListGroups.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/ListGroups.java @@ -12,7 +12,7 @@ import java.util.List; public class ListGroups extends SingleMainCommand { public ListGroups() { - super("ListGroups", "/%s listgroups", 0); + super("ListGroups", "/%s listgroups", 0, Permission.LIST_GROUPS); } @Override @@ -25,9 +25,4 @@ public class ListGroups extends SingleMainCommand { } }); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.LIST_GROUPS.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupHasPerm.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupHasPerm.java index ad56ac31..878a0ec4 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupHasPerm.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupHasPerm.java @@ -16,7 +16,7 @@ public class GroupHasPerm extends SubCommand { public GroupHasPerm() { super("haspermission", "Checks to see if a group has a certain permission node", "/%s group haspermission [server] [world]", Permission.GROUP_HASPERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupInheritsPerm.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupInheritsPerm.java index 2d6d0192..e05fa86c 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupInheritsPerm.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupInheritsPerm.java @@ -16,7 +16,7 @@ public class GroupInheritsPerm extends SubCommand { public GroupInheritsPerm() { super("inheritspermission", "Checks to see if a group inherits a certain permission node", "/%s group inheritspermission [server] [world]", Permission.GROUP_INHERITSPERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetInherit.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetInherit.java index 8f5ef136..2993969f 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetInherit.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetInherit.java @@ -16,7 +16,7 @@ public class GroupSetInherit extends SubCommand { public GroupSetInherit() { super("setinherit", "Sets another group for this group to inherit permissions from", "/%s group setinherit [server] [world]", Permission.GROUP_SETINHERIT, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetPermission.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetPermission.java index b1dcf727..bb5fd8b4 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetPermission.java @@ -15,7 +15,7 @@ import java.util.List; public class GroupSetPermission extends SubCommand { public GroupSetPermission() { super("set", "Sets a permission for a group", "/%s group set [server] [world]", - Permission.GROUP_SETPERMISSION, Predicate.notinRange(2, 4)); + Permission.GROUP_SETPERMISSION, Predicate.notInRange(2, 4)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempInherit.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempInherit.java index 69fa0059..55d415e0 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempInherit.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempInherit.java @@ -17,7 +17,7 @@ public class GroupSetTempInherit extends SubCommand { public GroupSetTempInherit() { super("settempinherit", "Sets another group for this group to inherit permissions from temporarily", "/%s group settempinherit [server] [world]", - Permission.GROUP_SET_TEMP_INHERIT, Predicate.notinRange(2, 4)); + Permission.GROUP_SET_TEMP_INHERIT, Predicate.notInRange(2, 4)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempPermission.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempPermission.java index 94716e33..f08562e0 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupSetTempPermission.java @@ -17,7 +17,7 @@ public class GroupSetTempPermission extends SubCommand { public GroupSetTempPermission() { super("settemp", "Sets a temporary permission for a group", "/%s group settemp [server] [world]", - Permission.GROUP_SET_TEMP_PERMISSION, Predicate.notinRange(3, 5)); + Permission.GROUP_SET_TEMP_PERMISSION, Predicate.notInRange(3, 5)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnSetPermission.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnSetPermission.java index fb54a1e8..08437e15 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnSetPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnSetPermission.java @@ -15,7 +15,7 @@ import java.util.List; public class GroupUnSetPermission extends SubCommand { public GroupUnSetPermission() { super("unset", "Unsets a permission for a group", "/%s group unset [server] [world]", - Permission.GROUP_UNSETPERMISSION, Predicate.notinRange(1, 3)); + Permission.GROUP_UNSETPERMISSION, Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetInherit.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetInherit.java index d737123f..9a173a54 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetInherit.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetInherit.java @@ -16,7 +16,7 @@ public class GroupUnsetInherit extends SubCommand { public GroupUnsetInherit() { super("unsetinherit", "Unsets another group for this group to inherit permissions from", "/%s group unsetinherit [server] [world]", Permission.GROUP_UNSETINHERIT, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempInherit.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempInherit.java index dcf6abdf..08826ecd 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempInherit.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempInherit.java @@ -16,7 +16,7 @@ public class GroupUnsetTempInherit extends SubCommand { public GroupUnsetTempInherit() { super("unsettempinherit", "Unsets another group for this group to inherit permissions from", "/%s group unsettempinherit [server] [world]", Permission.GROUP_UNSET_TEMP_INHERIT, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempPermission.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempPermission.java index 12f9420a..bedcc9b6 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupUnsetTempPermission.java @@ -16,7 +16,7 @@ public class GroupUnsetTempPermission extends SubCommand { public GroupUnsetTempPermission() { super("unsettemp", "Unsets a temporary permission for a group", "/%s group unsettemp [server] [world]", Permission.GROUP_UNSET_TEMP_PERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/misc/DebugCommand.java b/common/src/main/java/me/lucko/luckperms/commands/misc/DebugCommand.java index 30fc4fb9..03681ea6 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/misc/DebugCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/misc/DebugCommand.java @@ -10,7 +10,7 @@ import java.util.List; public class DebugCommand extends SingleMainCommand { public DebugCommand() { - super("Debug", "/%s debug", 0); + super("Debug", "/%s debug", 0, Permission.DEBUG); } @Override @@ -19,9 +19,4 @@ public class DebugCommand extends SingleMainCommand { plugin.getGroupManager().getGroups().size(), plugin.getTrackManager().getTracks().size() ); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.DEBUG.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java index d0a355f6..147a29c6 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java @@ -11,7 +11,7 @@ import java.util.List; public class InfoCommand extends SingleMainCommand { public InfoCommand() { - super("Info", "/%s info", 0); + super("Info", "/%s info", 0, Permission.INFO); } @Override @@ -20,9 +20,4 @@ public class InfoCommand extends SingleMainCommand { Message.INFO.send(sender, plugin.getVersion(), plugin.getDatastore().getName(), c.getServer(), c.getDefaultGroupName(), c.getSyncTime(), c.getIncludeGlobalPerms(), c.getOnlineMode()); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.INFO.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/misc/SyncCommand.java b/common/src/main/java/me/lucko/luckperms/commands/misc/SyncCommand.java index 8f6bb6a7..a2629437 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/misc/SyncCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/misc/SyncCommand.java @@ -10,7 +10,7 @@ import java.util.List; public class SyncCommand extends SingleMainCommand { public SyncCommand() { - super("Sync", "/%s sync", 0); + super("Sync", "/%s sync", 0, Permission.SYNC); } @Override @@ -18,9 +18,4 @@ public class SyncCommand extends SingleMainCommand { Message.UPDATE_TASK_RUN.send(sender); plugin.runUpdateTask(); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.SYNC.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/CreateTrack.java b/common/src/main/java/me/lucko/luckperms/commands/track/CreateTrack.java index ee31c2ff..5eea4961 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/CreateTrack.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/CreateTrack.java @@ -11,7 +11,7 @@ import java.util.List; public class CreateTrack extends SingleMainCommand { public CreateTrack() { - super("CreateTrack", "/%s createtrack ", 1); + super("CreateTrack", "/%s createtrack ", 1, Permission.CREATE_TRACK); } @Override @@ -48,9 +48,4 @@ public class CreateTrack extends SingleMainCommand { } }); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.CREATE_TRACK.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/DeleteTrack.java b/common/src/main/java/me/lucko/luckperms/commands/track/DeleteTrack.java index 99c140c3..8267a5e1 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/DeleteTrack.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/DeleteTrack.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; public class DeleteTrack extends SingleMainCommand { public DeleteTrack() { - super("DeleteTrack", "/%s deletetrack ", 1); + super("DeleteTrack", "/%s deletetrack ", 1, Permission.DELETE_TRACK); } @Override @@ -68,9 +68,4 @@ public class DeleteTrack extends SingleMainCommand { return Collections.emptyList(); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.DELETE_TRACK.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/ListTracks.java b/common/src/main/java/me/lucko/luckperms/commands/track/ListTracks.java index 1580d75c..1d36f10e 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/ListTracks.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/ListTracks.java @@ -12,7 +12,7 @@ import java.util.List; public class ListTracks extends SingleMainCommand { public ListTracks() { - super("ListTracks", "/%s listtracks", 0); + super("ListTracks", "/%s listtracks", 0, Permission.LIST_TRACKS); } @Override @@ -25,9 +25,4 @@ public class ListTracks extends SingleMainCommand { } }); } - - @Override - protected boolean isAuthorized(Sender sender) { - return Permission.LIST_TRACKS.isAuthorized(sender); - } } diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackAppend.java index b04011fe..c0cecbf5 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackAppend.java @@ -16,7 +16,7 @@ import java.util.List; public class TrackAppend extends SubCommand { public TrackAppend() { super("append", "Appends a group onto the end of the track", "/%s track append ", - Permission.TRACK_APPEND, Predicate.notOneOf(new Integer[]{1})); + Permission.TRACK_APPEND, Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackInsert.java index 873e28b0..f8022683 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackInsert.java @@ -16,7 +16,7 @@ import java.util.List; public class TrackInsert extends SubCommand { public TrackInsert() { super("insert", "Inserts a group at a given position along the track", - "/%s track insert ", Permission.TRACK_INSERT, Predicate.notOneOf(new Integer[]{2})); + "/%s track insert ", Permission.TRACK_INSERT, Predicate.not(2)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackRemove.java index 18934b36..179bc9d4 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/commands/track/subcommands/TrackRemove.java @@ -14,7 +14,7 @@ import java.util.List; public class TrackRemove extends SubCommand { public TrackRemove() { super("remove", "Removes a group from the track", "/%s track remove ", Permission.TRACK_REMOVE, - Predicate.notOneOf(new Integer[]{1})); + Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddGroup.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddGroup.java index 0870a171..a9c5a930 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddGroup.java @@ -16,7 +16,7 @@ import java.util.List; public class UserAddGroup extends SubCommand { public UserAddGroup() { super("addgroup", "Adds the user to a group", "/%s user addgroup [server] [world]", - Permission.USER_ADDGROUP, Predicate.notinRange(1, 3)); + Permission.USER_ADDGROUP, Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddTempGroup.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddTempGroup.java index 14623af1..b929fa0f 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddTempGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserAddTempGroup.java @@ -18,7 +18,7 @@ public class UserAddTempGroup extends SubCommand { public UserAddTempGroup() { super("addtempgroup", "Adds the user to a group temporarily", "/%s user addtempgroup [server] [world]", Permission.USER_ADDTEMPGROUP, - Predicate.notinRange(2, 4)); + Predicate.notInRange(2, 4)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserDemote.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserDemote.java index 264d1323..cbb21ba0 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserDemote.java @@ -18,7 +18,7 @@ import java.util.List; public class UserDemote extends SubCommand { public UserDemote() { super("demote", "Demotes a user along a track", "/%s user demote ", Permission.USER_DEMOTE, - Predicate.notOneOf(new Integer[]{1})); + Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserHasPerm.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserHasPerm.java index 6ddb6202..7d4f478e 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserHasPerm.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserHasPerm.java @@ -16,7 +16,7 @@ public class UserHasPerm extends SubCommand { public UserHasPerm() { super("haspermission", "Checks to see if a user has a certain permission node", "/%s user haspermission [server] [world]", Permission.USER_HASPERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserInheritsPerm.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserInheritsPerm.java index c1c813c4..09c41e2d 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserInheritsPerm.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserInheritsPerm.java @@ -16,7 +16,7 @@ public class UserInheritsPerm extends SubCommand { public UserInheritsPerm() { super("inheritspermission", "Checks to see if a user inherits a certain permission node", "/%s user inheritspermission [server] [world]", Permission.USER_INHERITSPERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserPromote.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserPromote.java index daff67be..d3273020 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserPromote.java @@ -18,7 +18,7 @@ import java.util.List; public class UserPromote extends SubCommand { public UserPromote() { super("promote", "Promotes the user along a track", "/%s user promote ", Permission.USER_PROMOTE, - Predicate.notOneOf(new Integer[]{1})); + Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveGroup.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveGroup.java index 9550a090..e3b56ab8 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveGroup.java @@ -15,7 +15,7 @@ import java.util.List; public class UserRemoveGroup extends SubCommand { public UserRemoveGroup() { super("removegroup", "Removes a user from a group", "/%s user removegroup [server] [world]", - Permission.USER_REMOVEGROUP, Predicate.notinRange(1, 3)); + Permission.USER_REMOVEGROUP, Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveTempGroup.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveTempGroup.java index 8a9bf2bb..e1935b70 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveTempGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserRemoveTempGroup.java @@ -16,7 +16,7 @@ public class UserRemoveTempGroup extends SubCommand { public UserRemoveTempGroup() { super("removetempgroup", "Removes a user from a temporary group", "/%s user removetempgroup [server] [world]", Permission.USER_REMOVETEMPGROUP, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPermission.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPermission.java index 800e3baa..8ba7451d 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPermission.java @@ -16,7 +16,7 @@ public class UserSetPermission extends SubCommand { public UserSetPermission() { super("set", "Sets a permission for a user", "/%s user set [server] [world]", Permission.USER_SETPERMISSION, - Predicate.notinRange(2, 4)); + Predicate.notInRange(2, 4)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPrimaryGroup.java index 276f9501..c5c95640 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetPrimaryGroup.java @@ -14,7 +14,7 @@ import java.util.List; public class UserSetPrimaryGroup extends SubCommand { public UserSetPrimaryGroup() { super("setprimarygroup", "Sets a users primary group", - "/%s user setprimarygroup ", Permission.USER_SETPRIMARYGROUP, Predicate.notOneOf(new Integer[]{1})); + "/%s user setprimarygroup ", Permission.USER_SETPRIMARYGROUP, Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetTempPermission.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetTempPermission.java index 3824cb8d..1164e855 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetTempPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserSetTempPermission.java @@ -17,7 +17,7 @@ public class UserSetTempPermission extends SubCommand { public UserSetTempPermission() { super("settemp", "Sets a temporary permission for a user", "/%s user settemp [server] [world]", - Permission.USER_SET_TEMP_PERMISSION, Predicate.notinRange(3, 5)); + Permission.USER_SET_TEMP_PERMISSION, Predicate.notInRange(3, 5)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserShowPos.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserShowPos.java index 165bc10d..10b0c0c4 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserShowPos.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserShowPos.java @@ -15,7 +15,7 @@ import java.util.List; public class UserShowPos extends SubCommand { public UserShowPos() { super("showpos", "Shows a users position on a track", "/%s user showpos ", Permission.USER_SHOWPOS, - Predicate.notOneOf(new Integer[]{1})); + Predicate.not(1)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnSetPermission.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnSetPermission.java index 0bb8e760..82be451b 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnSetPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnSetPermission.java @@ -15,7 +15,7 @@ import java.util.List; public class UserUnSetPermission extends SubCommand { public UserUnSetPermission() { super("unset", "Unsets a permission for a user", - "/%s user unset [server] [world]", Permission.USER_UNSETPERMISSION, Predicate.notinRange(1, 3)); + "/%s user unset [server] [world]", Permission.USER_UNSETPERMISSION, Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnsetTempPermission.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnsetTempPermission.java index a015dadf..189f7f52 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnsetTempPermission.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserUnsetTempPermission.java @@ -16,7 +16,7 @@ public class UserUnsetTempPermission extends SubCommand { public UserUnsetTempPermission() { super("unsettemp", "Unsets a temporary permission for a user", "/%s user unsettemp [server] [world]", Permission.USER_UNSET_TEMP_PERMISSION, - Predicate.notinRange(1, 3)); + Predicate.notInRange(1, 3)); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/utils/LPConfiguration.java b/common/src/main/java/me/lucko/luckperms/utils/LPConfiguration.java index e6808e0a..745a5cc3 100644 --- a/common/src/main/java/me/lucko/luckperms/utils/LPConfiguration.java +++ b/common/src/main/java/me/lucko/luckperms/utils/LPConfiguration.java @@ -3,6 +3,7 @@ package me.lucko.luckperms.utils; import lombok.AccessLevel; import lombok.Getter; import me.lucko.luckperms.LuckPermsPlugin; +import me.lucko.luckperms.data.MySQLConfiguration; public abstract class LPConfiguration { @@ -65,8 +66,13 @@ public abstract class LPConfiguration { return getBoolean("online-mode", true); } - public String getDatabaseValue(String value) { - return getString("sql." + value, null); + public MySQLConfiguration getDatabaseValues() { + return new MySQLConfiguration( + getString("sql.address", null), + getString("sql.database", null), + getString("sql.username", null), + getString("sql.password", null) + ); } public String getStorageMethod() {