diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java index f2556afee..80c1eaf78 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/LPBukkitPlugin.java @@ -322,7 +322,7 @@ public class LPBukkitPlugin extends JavaPlugin implements LuckPermsPlugin { @Override public List getNotifyListeners() { return getServer().getOnlinePlayers().stream() - .map(p -> BukkitSenderFactory.get(this).wrap(p, Collections.singleton(Permission.LOG_NOTIFY))) + .map(p -> BukkitSenderFactory.get(this).wrap(p)) .filter(Permission.LOG_NOTIFY::isAuthorized) .collect(Collectors.toList()); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java index 10d08bdc1..12c9e2d43 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationBPermissions.java @@ -27,12 +27,12 @@ import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.lang.reflect.Field; @@ -82,7 +82,7 @@ public class MigrationBPermissions extends SubCommand { } public MigrationBPermissions() { - super("bpermissions", "Migration from bPermissions", MIGRATION, Predicate.alwaysFalse(), null); + super("bpermissions", "Migration from bPermissions", MIGRATION, Predicates.alwaysFalse(), null); } @Override diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java index 7c2776727..cfe5cdda3 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationGroupManager.java @@ -24,11 +24,15 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; import org.anjocaido.groupmanager.GlobalGroups; @@ -43,7 +47,7 @@ import java.util.stream.Collectors; public class MigrationGroupManager extends SubCommand { public MigrationGroupManager() { - super("groupmanager", "Migration from GroupManager", Permission.MIGRATION, Predicate.is(0), + super("groupmanager", "Migration from GroupManager", Permission.MIGRATION, Predicates.is(0), Arg.list(Arg.create("world names...", false, "a list of worlds to migrate permissions from")) ); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java index 0d10c3119..5b92ed17f 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPermissionsEx.java @@ -26,12 +26,16 @@ import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.api.PlatformType; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import ru.tehkode.permissions.NativeInterface; import ru.tehkode.permissions.PermissionGroup; @@ -46,7 +50,7 @@ import java.util.stream.Collectors; public class MigrationPermissionsEx extends SubCommand { public MigrationPermissionsEx() { - super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicate.alwaysFalse(), + super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(), Arg.list(Arg.create("world names...", false, "a list of worlds to migrate permissions from")) ); } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java index 254ec5a26..270cd2070 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationPowerfulPerms.java @@ -30,11 +30,15 @@ import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.data.Callback; import me.lucko.luckperms.bukkit.migration.utils.LPResultRunnable; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.lang.reflect.InvocationTargetException; @@ -116,7 +120,7 @@ public class MigrationPowerfulPerms extends SubCommand { public MigrationPowerfulPerms() { - super("powerfulperms", "Migration from PowerfulPerms", MIGRATION, Predicate.not(5), + super("powerfulperms", "Migration from PowerfulPerms", MIGRATION, Predicates.not(5), Arg.list( Arg.create("address", true, "the address of the PP database"), Arg.create("database", true, "the name of the PP database"), diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java index 0f3b7453d..f5d52cae7 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/migration/MigrationZPermissions.java @@ -25,13 +25,17 @@ package me.lucko.luckperms.bukkit.migration; import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import org.tyrannyofheaven.bukkit.zPermissions.ZPermissionsService; @@ -42,7 +46,7 @@ import java.util.stream.Collectors; public class MigrationZPermissions extends SubCommand { public MigrationZPermissions() { - super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicate.alwaysFalse(), + super("zpermissions", "Migration from zPermissions", Permission.MIGRATION, Predicates.alwaysFalse(), Arg.list(Arg.create("world names...", false, "a list of worlds to migrate permissions from")) ); } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java index f0b9b0966..3128d4e00 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/LPBungeePlugin.java @@ -58,7 +58,10 @@ import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.plugin.Plugin; import java.io.File; -import java.util.*; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -229,7 +232,7 @@ public class LPBungeePlugin extends Plugin implements LuckPermsPlugin { @Override public List getNotifyListeners() { return getProxy().getPlayers().stream() - .map(p -> BungeeSenderFactory.get(this).wrap(p, Collections.singleton(Permission.LOG_NOTIFY))) + .map(p -> BungeeSenderFactory.get(this).wrap(p)) .filter(Permission.LOG_NOTIFY::isAuthorized) .collect(Collectors.toList()); } diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java index 0cf18331f..8a8f731cd 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/migration/MigrationBungeePerms.java @@ -26,12 +26,12 @@ import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import net.alpenblock.bungeeperms.*; @@ -43,7 +43,7 @@ import java.util.Map; */ public class MigrationBungeePerms extends SubCommand { public MigrationBungeePerms() { - super("bungeeperms", "Migration from BungeePerms", Permission.MIGRATION, Predicate.alwaysFalse(), null); + super("bungeeperms", "Migration from BungeePerms", Permission.MIGRATION, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java index 04afe15fb..45b30b49e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/ApiProvider.java @@ -31,6 +31,7 @@ import me.lucko.luckperms.api.context.IContextCalculator; import me.lucko.luckperms.api.event.LPEvent; import me.lucko.luckperms.api.event.LPListener; import me.lucko.luckperms.common.LuckPermsPlugin; +import me.lucko.luckperms.common.api.internal.*; import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.users.UserIdentifier; @@ -95,17 +96,17 @@ public class ApiProvider implements LuckPermsApi { @Override public LPConfiguration getConfiguration() { - return new me.lucko.luckperms.common.api.internal.LPConfigurationLink(plugin.getConfiguration()); + return new LPConfigurationLink(plugin.getConfiguration()); } @Override public Datastore getDatastore() { - return new me.lucko.luckperms.common.api.internal.DatastoreLink(plugin, plugin.getDatastore()); + return new DatastoreLink(plugin, plugin.getDatastore()); } @Override public UuidCache getUuidCache() { - return new me.lucko.luckperms.common.api.internal.UuidCacheLink(plugin.getUuidCache()); + return new UuidCacheLink(plugin.getUuidCache()); } @Override @@ -116,11 +117,7 @@ public class ApiProvider implements LuckPermsApi { @Override public User getUser(@NonNull UUID uuid) { final me.lucko.luckperms.common.users.User user = plugin.getUserManager().get(uuid); - if (user == null) { - return null; - } - - return new me.lucko.luckperms.common.api.internal.UserLink(user); + return user == null ? null : new UserLink(user); } @Override @@ -131,11 +128,7 @@ public class ApiProvider implements LuckPermsApi { @Override public User getUser(@NonNull String name) { final me.lucko.luckperms.common.users.User user = plugin.getUserManager().get(name); - if (user == null) { - return null; - } - - return new me.lucko.luckperms.common.api.internal.UserLink(user); + return user == null ? null : new UserLink(user); } @Override @@ -145,7 +138,7 @@ public class ApiProvider implements LuckPermsApi { @Override public Set getUsers() { - return plugin.getUserManager().getAll().values().stream().map(me.lucko.luckperms.common.api.internal.UserLink::new).collect(Collectors.toSet()); + return plugin.getUserManager().getAll().values().stream().map(UserLink::new).collect(Collectors.toSet()); } @Override @@ -156,17 +149,13 @@ public class ApiProvider implements LuckPermsApi { @Override public void cleanupUser(@NonNull User user) { me.lucko.luckperms.common.api.internal.Utils.checkUser(user); - plugin.getUserManager().cleanup(((me.lucko.luckperms.common.api.internal.UserLink) user).getMaster()); + plugin.getUserManager().cleanup(((UserLink) user).getMaster()); } @Override public Group getGroup(@NonNull String name) { final me.lucko.luckperms.common.groups.Group group = plugin.getGroupManager().get(name); - if (group == null) { - return null; - } - - return new me.lucko.luckperms.common.api.internal.GroupLink(group); + return group == null ? null : new GroupLink(group); } @Override @@ -176,7 +165,7 @@ public class ApiProvider implements LuckPermsApi { @Override public Set getGroups() { - return plugin.getGroupManager().getAll().values().stream().map(me.lucko.luckperms.common.api.internal.GroupLink::new).collect(Collectors.toSet()); + return plugin.getGroupManager().getAll().values().stream().map(GroupLink::new).collect(Collectors.toSet()); } @Override @@ -187,11 +176,7 @@ public class ApiProvider implements LuckPermsApi { @Override public Track getTrack(@NonNull String name) { final me.lucko.luckperms.common.tracks.Track track = plugin.getTrackManager().get(name); - if (track == null) { - return null; - } - - return new me.lucko.luckperms.common.api.internal.TrackLink(track); + return track == null ? null : new TrackLink(track); } @Override @@ -201,7 +186,7 @@ public class ApiProvider implements LuckPermsApi { @Override public Set getTracks() { - return plugin.getTrackManager().getAll().values().stream().map(me.lucko.luckperms.common.api.internal.TrackLink::new).collect(Collectors.toSet()); + return plugin.getTrackManager().getAll().values().stream().map(TrackLink::new).collect(Collectors.toSet()); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/api/internal/Utils.java b/common/src/main/java/me/lucko/luckperms/common/api/internal/Utils.java index 2f32dcb01..37adbf3cd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/internal/Utils.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/internal/Utils.java @@ -22,6 +22,7 @@ package me.lucko.luckperms.common.api.internal; +import com.google.common.base.Preconditions; import lombok.experimental.UtilityClass; import me.lucko.luckperms.api.Group; import me.lucko.luckperms.api.Track; @@ -32,57 +33,51 @@ import me.lucko.luckperms.common.utils.ArgumentChecker; public class Utils { public static void checkUser(User user) { - if (!(user instanceof UserLink)) { - throw new IllegalStateException("User instance cannot be handled by this implementation."); - } + Preconditions.checkState(user instanceof UserLink, "User instance cannot be handled by this implementation."); } public static void checkGroup(Group group) { - if (!(group instanceof GroupLink)) { - throw new IllegalStateException("Group instance cannot be handled by this implementation."); - } + Preconditions.checkState(group instanceof GroupLink, "Group instance cannot be handled by this implementation."); } public static void checkTrack(Track track) { - if (!(track instanceof TrackLink)) { - throw new IllegalStateException("Track instance cannot be handled by this implementation."); - } + Preconditions.checkState(track instanceof TrackLink, "Track instance cannot be handled by this implementation."); } public static String checkUsername(String s) { - if (ArgumentChecker.checkUsername(s)) { - throw new IllegalArgumentException("Invalid username entry '" + s + "'. Usernames must be less than 16 chars" + - " and only contain 'a-z A-Z 1-9 _'."); - } + Preconditions.checkArgument( + !ArgumentChecker.checkUsername(s), + "Invalid username entry '" + s + "'. Usernames must be less than 16 chars and only contain 'a-z A-Z 1-9 _'." + ); return s; } public static String checkName(String s) { - if (ArgumentChecker.checkName(s)) { - throw new IllegalArgumentException("Invalid name entry '" + s + "'. Names must be less than 37 chars" + - " and only contain 'a-z A-Z 1-9'."); - } + Preconditions.checkArgument( + !ArgumentChecker.checkName(s), + "Invalid name entry '" + s + "'. Names must be less than 37 chars and only contain 'a-z A-Z 1-9'." + ); return s.toLowerCase(); } public static String checkServer(String s) { - if (ArgumentChecker.checkServer(s)) { - throw new IllegalArgumentException("Invalid server entry '" + s + "'. Server names can only contain alphanumeric characters."); - } + Preconditions.checkArgument( + !ArgumentChecker.checkServer(s), + "Invalid server entry '" + s + "'. Server names can only contain alphanumeric characters." + ); return s; } public static String checkNode(String s) { - if (ArgumentChecker.checkNode(s)) { - throw new IllegalArgumentException("Invalid node entry '" + s + "'. Nodes cannot contain '/' or '$' characters."); - } + Preconditions.checkArgument( + !ArgumentChecker.checkNode(s), + "Invalid node entry '" + s + "'. Nodes cannot contain '/' or '$' characters." + ); return s; } public static long checkTime(long l) { - if (ArgumentChecker.checkTime(l)) { - throw new IllegalArgumentException("Unix time '" + l + "' is invalid, as it has already passed."); - } + Preconditions.checkArgument(!ArgumentChecker.checkTime(l), "Unix time '" + l + "' is invalid, as it has already passed."); return l; } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/internal/UuidCacheLink.java b/common/src/main/java/me/lucko/luckperms/common/api/internal/UuidCacheLink.java index 8c050f77f..e2419bd9f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/internal/UuidCacheLink.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/internal/UuidCacheLink.java @@ -23,6 +23,7 @@ package me.lucko.luckperms.common.api.internal; import lombok.AllArgsConstructor; +import lombok.NonNull; import me.lucko.luckperms.api.UuidCache; import java.util.UUID; @@ -35,12 +36,12 @@ public class UuidCacheLink implements UuidCache { private final me.lucko.luckperms.common.core.UuidCache master; @Override - public UUID getUUID(UUID external) { + public UUID getUUID(@NonNull UUID external) { return master.getUUID(external); } @Override - public UUID getExternalUUID(UUID internal) { + public UUID getExternalUUID(@NonNull UUID internal) { return master.getExternalUUID(internal); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java b/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java index 87b48a2fe..68281aceb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/Arg.java @@ -43,11 +43,7 @@ public class Arg { private final String description; public String asPrettyString() { - if (required) { - return "&8<&7" + name + "&8>"; - } else { - return "&8[&7" + name + "&8]"; - } + return required ? "&8<&7" + name + "&8>" : "&8[&7" + name + "&8]"; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java b/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java index 4634c3928..9ff085796 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/CommandResult.java @@ -34,13 +34,13 @@ public enum CommandResult { INVALID_ARGS(false), NO_PERMISSION(false); - private boolean booleanValue; + private boolean value; - public boolean booleanValue() { - return booleanValue; + public boolean asBoolean() { + return value; } - static CommandResult of(boolean b) { + public static CommandResult of(boolean b) { return b ? SUCCESS : FAILURE; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/SenderFactory.java b/common/src/main/java/me/lucko/luckperms/common/commands/SenderFactory.java index 11a09d89b..84e72f193 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/SenderFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/SenderFactory.java @@ -27,7 +27,6 @@ import lombok.RequiredArgsConstructor; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.constants.Constants; import me.lucko.luckperms.common.constants.Permission; -import me.lucko.luckperms.common.utils.ImmutableCollectors; import java.lang.ref.WeakReference; import java.util.*; @@ -50,11 +49,7 @@ public abstract class SenderFactory implements Runnable { protected abstract boolean hasPermission(T t, String node); public final Sender wrap(T t) { - return new SenderImp(plugin, t, null); - } - - public final Sender wrap(T t, Set toCheck) { - return new SenderImp(plugin, t, toCheck); + return new SenderImp(plugin, t); } @Override @@ -77,9 +72,6 @@ public abstract class SenderFactory implements Runnable { private class SenderImp implements Sender { private final WeakReference tRef; - // Cache these permissions, so they can be accessed async - private Map perms; - @Getter private final String name; @@ -91,24 +83,12 @@ public abstract class SenderFactory implements Runnable { @Getter private final LuckPermsPlugin platform; - private SenderImp(LuckPermsPlugin platform, T t, Set toCheck) { + private SenderImp(LuckPermsPlugin platform, T t) { this.platform = platform; this.tRef = new WeakReference<>(t); this.name = factory.getName(t); this.uuid = factory.getUuid(t); this.console = this.uuid.equals(Constants.getConsoleUUID()) || this.uuid.equals(Constants.getImporterUUID()); - - if (!this.console) { - this.perms = ((toCheck == null || toCheck.isEmpty()) ? Arrays.stream(Permission.values()) : toCheck.stream()) - .collect(ImmutableCollectors.toImmutableMap(p -> p, p -> { - for (String s : p.getNodes()) { - if (factory.hasPermission(t, s)) { - return true; - } - } - return false; - })); - } } @Override @@ -128,7 +108,17 @@ public abstract class SenderFactory implements Runnable { @Override public boolean hasPermission(Permission permission) { - return console || perms.get(permission); + if (console) return true; + + T t = tRef.get(); + if (t == null) return false; + + for (String s : permission.getNodes()) { + if (factory.hasPermission(t, s)) { + return true; + } + } + return false; } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java index ca7461f44..70fbb0f58 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/SecondaryMainCommand.java @@ -23,9 +23,13 @@ package me.lucko.luckperms.common.commands.generic; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.PermissionHolder; +import me.lucko.luckperms.common.utils.Predicates; import java.util.ArrayList; import java.util.Collections; @@ -38,7 +42,7 @@ public class SecondaryMainCommand extends SubCommand private final List secondaryCommands; public SecondaryMainCommand(String name, String description, boolean user, List secondaryCommands) { - super(name, description, null, Predicate.alwaysFalse(), null); + super(name, description, null, Predicates.alwaysFalse(), null); this.secondaryCommands = secondaryCommands; this.user = user; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java index b35d34e92..f438627c8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddPrefix.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,13 +33,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaAddPrefix extends SecondarySubCommand { public MetaAddPrefix() { - super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX, Predicate.notInRange(2, 4), + super("addprefix", "Adds a prefix", Permission.USER_META_ADDPREFIX, Permission.GROUP_META_ADDPREFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the prefix at"), Arg.create("prefix", true, "the prefix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java index 29e08d81f..6d44089a4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddSuffix.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,13 +33,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaAddSuffix extends SecondarySubCommand { public MetaAddSuffix() { - super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX, Predicate.notInRange(2, 4), + super("addsuffix", "Adds a suffix", Permission.USER_META_ADDSUFFIX, Permission.GROUP_META_ADDSUFFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the suffix at"), Arg.create("suffix", true, "the suffix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java index fa75d92cc..75be96a7e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempPrefix.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,13 +34,14 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaAddTempPrefix extends SecondarySubCommand { public MetaAddTempPrefix() { - super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX, Permission.GROUP_META_ADDTEMP_PREFIX, Predicate.notInRange(3, 5), + super("addtempprefix", "Adds a prefix temporarily", Permission.USER_META_ADDTEMP_PREFIX, Permission.GROUP_META_ADDTEMP_PREFIX, Predicates.notInRange(3, 5), Arg.list( Arg.create("priority", true, "the priority to add the prefix at"), Arg.create("prefix", true, "the prefix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java index ba95e848c..9faae3492 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaAddTempSuffix.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,13 +34,14 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaAddTempSuffix extends SecondarySubCommand { public MetaAddTempSuffix() { - super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX, Permission.GROUP_META_ADDTEMP_SUFFIX, Predicate.notInRange(3, 5), + super("addtempsuffix", "Adds a suffix temporarily", Permission.USER_META_ADDTEMP_SUFFIX, Permission.GROUP_META_ADDTEMP_SUFFIX, Predicates.notInRange(3, 5), Arg.list( Arg.create("priority", true, "the priority to add the suffix at"), Arg.create("suffix", true, "the suffix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java index 7f4e00874..f3c59042c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaClear.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.meta; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -33,13 +32,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.stream.Collectors; public class MetaClear extends SecondarySubCommand { public MetaClear() { - super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicate.notInRange(0, 2), + super("clear", "Clears all chat meta", Permission.USER_META_CLEAR, Permission.GROUP_META_CLEAR, Predicates.notInRange(0, 2), Arg.list( Arg.create("server", false, "the server name to filter by"), Arg.create("world", false, "the world name to filter by") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java index a8f10155c..6150036b1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaInfo.java @@ -26,19 +26,19 @@ import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; +import me.lucko.luckperms.common.utils.Predicates; import java.util.*; public class MetaInfo extends SecondarySubCommand { public MetaInfo() { - super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicate.alwaysFalse(), null); + super("info", "Shows all chat meta", Permission.USER_META_INFO, Permission.GROUP_META_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java index d09835ba6..9cbaee6ed 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemovePrefix.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; @@ -42,7 +42,7 @@ import java.util.List; public class MetaRemovePrefix extends SecondarySubCommand { public MetaRemovePrefix() { - super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX, Predicate.notInRange(2, 4), + super("removeprefix", "Removes a prefix", Permission.USER_META_REMOVEPREFIX, Permission.GROUP_META_REMOVEPREFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the prefix at"), Arg.create("prefix", true, "the prefix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java index 16a767de4..b1df3aad5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveSuffix.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; @@ -42,7 +42,7 @@ import java.util.List; public class MetaRemoveSuffix extends SecondarySubCommand { public MetaRemoveSuffix() { - super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX, Predicate.notInRange(2, 4), + super("removesuffix", "Removes a suffix", Permission.USER_META_REMOVESUFFIX, Permission.GROUP_META_REMOVESUFFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the suffix at"), Arg.create("suffix", true, "the suffix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java index a5d005e59..5461b1aa2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempPrefix.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; @@ -42,7 +42,7 @@ import java.util.List; public class MetaRemoveTempPrefix extends SecondarySubCommand { public MetaRemoveTempPrefix() { - super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicate.notInRange(2, 4), + super("removetempprefix", "Removes a temporary prefix", Permission.USER_META_REMOVETEMP_PREFIX, Permission.GROUP_META_REMOVETEMP_PREFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the prefix at"), Arg.create("prefix", true, "the prefix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java index 094e40eee..7fcfa2bb9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaRemoveTempSuffix.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.ArrayList; @@ -42,7 +42,7 @@ import java.util.List; public class MetaRemoveTempSuffix extends SecondarySubCommand { public MetaRemoveTempSuffix() { - super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicate.notInRange(2, 4), + super("removetempsuffix", "Removes a temporary suffix", Permission.USER_META_REMOVETEMP_SUFFIX, Permission.GROUP_META_REMOVETEMP_SUFFIX, Predicates.notInRange(2, 4), Arg.list( Arg.create("priority", true, "the priority to add the suffix at"), Arg.create("suffix", true, "the suffix string"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java index 39880581e..a71c31d9e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSet.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -36,13 +35,14 @@ import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaSet extends SecondarySubCommand { public MetaSet() { - super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicate.notInRange(2, 4), + super("set", "Sets a meta value", Permission.USER_META_SET, Permission.GROUP_META_SET, Predicates.notInRange(2, 4), Arg.list( Arg.create("key", true, "the key to set"), Arg.create("value", true, "the value to set"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java index e0ba7f16d..5c3d897f3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaSetTemp.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -37,13 +36,14 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class MetaSetTemp extends SecondarySubCommand { public MetaSetTemp() { - super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicate.notInRange(3, 5), + super("settemp", "Sets a meta value temporarily", Permission.USER_META_SETTEMP, Permission.GROUP_META_SETTEMP, Predicates.notInRange(3, 5), Arg.list( Arg.create("key", true, "the key to set"), Arg.create("value", true, "the value to set"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java index 073996c82..637d1cf28 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnset.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,13 +33,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.stream.Collectors; public class MetaUnset extends SecondarySubCommand { public MetaUnset() { - super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, Predicate.notInRange(1, 3), + super("unset", "Unsets a meta value", Permission.USER_META_UNSET, Permission.GROUP_META_UNSET, Predicates.notInRange(1, 3), Arg.list( Arg.create("key", true, "the key to unset"), Arg.create("server", false, "the server to remove the meta pair on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java index 541528c57..8e457efe7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/meta/MetaUnsetTemp.java @@ -26,7 +26,6 @@ import me.lucko.luckperms.api.MetaUtils; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,13 +33,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.stream.Collectors; public class MetaUnsetTemp extends SecondarySubCommand { public MetaUnsetTemp() { - super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, Predicate.notInRange(1, 3), + super("unsettemp", "Unsets a temporary meta value", Permission.USER_META_UNSETTEMP, Permission.GROUP_META_UNSETTEMP, Predicates.notInRange(1, 3), Arg.list( Arg.create("key", true, "the key to unset"), Arg.create("server", false, "the server to remove the meta pair on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java index 3dbffd3af..d8454b4de 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderShowTracks.java @@ -24,10 +24,14 @@ package me.lucko.luckperms.common.commands.generic.other; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Set; @@ -36,7 +40,7 @@ import java.util.stream.Collectors; public class HolderShowTracks extends SubCommand { public HolderShowTracks(boolean user) { super("showtracks", "Lists the tracks that the object is on", - user ? Permission.USER_SHOWTRACKS : Permission.GROUP_SHOWTRACKS, Predicate.alwaysFalse(), null); + user ? Permission.USER_SHOWTRACKS : Permission.GROUP_SHOWTRACKS, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java index 8ecacf49e..f5f038cdf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAdd.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,6 +33,7 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; @@ -43,7 +43,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; public class ParentAdd extends SecondarySubCommand { public ParentAdd() { super("add", "Sets another group for the object to inherit permissions from", - Permission.USER_PARENT_ADD, Permission.GROUP_PARENT_ADD, Predicate.notInRange(1, 3), + Permission.USER_PARENT_ADD, Permission.GROUP_PARENT_ADD, Predicates.notInRange(1, 3), Arg.list( Arg.create("group", true, "the group to inherit from"), Arg.create("server", false, "the server to inherit the group on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java index bd638630d..47230e16c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentAddTemp.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; @@ -44,7 +44,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; public class ParentAddTemp extends SecondarySubCommand { public ParentAddTemp() { super("addtemp", "Sets another group for the object to inherit permissions from temporarily", - Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicate.notInRange(2, 4), + Permission.USER_PARENT_ADDTEMP, Permission.GROUP_PARENT_ADDTEMP, Predicates.notInRange(2, 4), Arg.list( Arg.create("group", true, "the group to inherit from"), Arg.create("duration", true, "the duration of the group membership"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java index 8cc8d1bda..ba5f5afc8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentInfo.java @@ -24,20 +24,20 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class ParentInfo extends SecondarySubCommand { public ParentInfo() { super("info", "Lists the groups that this object inherits from", - Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicate.alwaysFalse(), null); + Permission.USER_PARENT_INFO, Permission.GROUP_PARENT_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java index 4df1def8d..bb13c9348 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemove.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,6 +33,7 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; @@ -43,7 +43,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; public class ParentRemove extends SecondarySubCommand { public ParentRemove() { super("remove", "Removes a previously set inheritance rule", Permission.USER_PARENT_REMOVE, Permission.GROUP_PARENT_REMOVE, - Predicate.notInRange(1, 3), + Predicates.notInRange(1, 3), Arg.list( Arg.create("group", true, "the group to remove"), Arg.create("server", false, "the server to remove the group on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java index ce9decd9c..485a17a75 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentRemoveTemp.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -33,6 +32,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; @@ -42,7 +42,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; public class ParentRemoveTemp extends SecondarySubCommand { public ParentRemoveTemp() { super("removetemp", "Removes a previously set temporary inheritance rule", - Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicate.notInRange(1, 3), + Permission.USER_PARENT_REMOVETEMP, Permission.GROUP_PARENT_REMOVETEMP, Predicates.notInRange(1, 3), Arg.list( Arg.create("group", true, "the group to remove"), Arg.create("server", false, "the server to remove the group on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java index 032109475..f22f2982a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSet.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.parent; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -35,6 +34,7 @@ import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; @@ -44,7 +44,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getGroupTabComplete; public class ParentSet extends SecondarySubCommand { public ParentSet() { super("set", "Removes all other groups the object inherits already and adds them to the one given", - Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicate.notInRange(1, 3), + Permission.USER_PARENT_SET, Permission.GROUP_PARENT_SET, Predicates.notInRange(1, 3), Arg.list( Arg.create("group", true, "the group to set to"), Arg.create("server", false, "the server to set the group on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java index 533f17ab5..98df29e2d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheck.java @@ -23,20 +23,24 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class PermissionCheck extends SecondarySubCommand { public PermissionCheck() { super("check", "Checks to see if the object has a certain permission node", Permission.USER_PERM_CHECK, Permission.GROUP_PERM_CHECK, - Predicate.notInRange(1, 3), + Predicates.notInRange(1, 3), Arg.list( Arg.create("node", true, "the permission node to check for"), Arg.create("server", false, "the server to check on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java index 4447d0354..ec6f66c4c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionCheckInherits.java @@ -23,7 +23,10 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; @@ -31,13 +34,14 @@ import me.lucko.luckperms.common.core.InheritanceInfo; import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class PermissionCheckInherits extends SecondarySubCommand { public PermissionCheckInherits() { super("checkinherits", "Checks to see if the object inherits a certain permission node", Permission.USER_PERM_CHECK_INHERITS, Permission.GROUP_PERM_CHECK_INHERITS, - Predicate.notInRange(1, 3), + Predicates.notInRange(1, 3), Arg.list( Arg.create("node", true, "the permission node to check for"), Arg.create("server", false, "the server to check on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java index 32ac641b5..9c37ee37d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionInfo.java @@ -24,19 +24,19 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class PermissionInfo extends SecondarySubCommand { public PermissionInfo() { - super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicate.alwaysFalse(), null); + super("info", "Lists the permission nodes the object has", Permission.USER_PERM_INFO, Permission.GROUP_PERM_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java index dd9161a25..09f95a34b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSet.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -33,6 +32,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; @@ -41,7 +41,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete; public class PermissionSet extends SecondarySubCommand { public PermissionSet() { - super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, Predicate.notInRange(2, 4), + super("set", "Sets a permission for the object", Permission.USER_PERM_SET, Permission.GROUP_PERM_SET, Predicates.notInRange(2, 4), Arg.list( Arg.create("node", true, "the permission node to set"), Arg.create("true|false", true, "the value of the node"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java index a410d06df..c10df85c0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionSetTemp.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -34,6 +33,7 @@ import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; @@ -43,7 +43,7 @@ import static me.lucko.luckperms.common.commands.SubCommand.getBoolTabComplete; public class PermissionSetTemp extends SecondarySubCommand { public PermissionSetTemp() { super("settemp", "Sets a permission for the object temporarily", Permission.USER_PERM_SETTEMP, Permission.GROUP_PERM_SETTEMP, - Predicate.notInRange(3, 5), + Predicates.notInRange(3, 5), Arg.list( Arg.create("node", true, "the permission node to set"), Arg.create("true|false", true, "the value of the node"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java index 5d15b0c65..5bfaa99b1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnset.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -33,13 +32,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; public class PermissionUnset extends SecondarySubCommand { public PermissionUnset() { - super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, Predicate.notInRange(1, 3), + super("unset", "Unsets a permission for the object", Permission.USER_PERM_UNSET, Permission.GROUP_PERM_UNSET, Predicates.notInRange(1, 3), Arg.list( Arg.create("node", true, "the permission node to unset"), Arg.create("server", false, "the server to remove the permission node on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java index 12b92aaf1..99da61f5d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/permission/PermissionUnsetTemp.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.common.commands.generic.permission; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.Arg; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.generic.SecondarySubCommand; import me.lucko.luckperms.common.constants.Message; @@ -33,6 +32,7 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; @@ -40,7 +40,7 @@ import java.util.List; public class PermissionUnsetTemp extends SecondarySubCommand { public PermissionUnsetTemp() { super("unsettemp", "Unsets a temporary permission for the object", Permission.USER_PERM_UNSETTEMP, Permission.GROUP_PERM_UNSETTEMP, - Predicate.notInRange(1, 3), + Predicates.notInRange(1, 3), Arg.list( Arg.create("node", true, "the permission node to unset"), Arg.create("server", false, "the server to remove the permission node on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupBulkChange.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupBulkChange.java index 74adc5199..09ad61051 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupBulkChange.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupBulkChange.java @@ -24,11 +24,15 @@ package me.lucko.luckperms.common.commands.group.subcommands; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.groups.Group; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -39,7 +43,7 @@ import java.util.Set; public class GroupBulkChange extends SubCommand { public GroupBulkChange() { - super("bulkchange", "Applies a bulk permission change to the group's permissions", Permission.GROUP_BULKCHANGE, Predicate.not(3), + super("bulkchange", "Applies a bulk permission change to the group's permissions", Permission.GROUP_BULKCHANGE, Predicates.not(3), Arg.list( Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClear.java index df87e74b2..fb9bd72dd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClear.java @@ -23,19 +23,23 @@ package me.lucko.luckperms.common.commands.group.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.stream.Collectors; public class GroupClear extends SubCommand { public GroupClear() { - super("clear", "Clears the group's permissions and parent groups", Permission.GROUP_CLEAR, Predicate.notInRange(0, 2), + super("clear", "Clears the group's permissions and parent groups", Permission.GROUP_CLEAR, Predicates.notInRange(0, 2), Arg.list( Arg.create("server", false, "the server name to filter by"), Arg.create("world", false, "the world name to filter by") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClone.java index 362cb7f69..fe47677f0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupClone.java @@ -23,18 +23,22 @@ package me.lucko.luckperms.common.commands.group.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupClone extends SubCommand { public GroupClone() { - super("clone", "Clone the group", Permission.GROUP_CLONE, Predicate.not(1), + super("clone", "Clone the group", Permission.GROUP_CLONE, Predicates.not(1), Arg.list(Arg.create("name", true, "the name of the clone")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupInfo.java index 7f4f61561..c9bb51d82 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupInfo.java @@ -24,18 +24,18 @@ package me.lucko.luckperms.common.commands.group.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.groups.Group; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupInfo extends SubCommand { public GroupInfo() { - super("info", "Gives info about the group", Permission.GROUP_INFO, Predicate.alwaysFalse(), null); + super("info", "Gives info about the group", Permission.GROUP_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupRename.java index c0df717f6..b399a1a37 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/group/subcommands/GroupRename.java @@ -23,18 +23,22 @@ package me.lucko.luckperms.common.commands.group.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class GroupRename extends SubCommand { public GroupRename() { - super("rename", "Rename the group", Permission.GROUP_RENAME, Predicate.not(1), + super("rename", "Rename the group", Permission.GROUP_RENAME, Predicates.not(1), Arg.list(Arg.create("name", true, "the new name")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogExport.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogExport.java index 1210941b7..e9cad6b3b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogExport.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogExport.java @@ -24,10 +24,14 @@ package me.lucko.luckperms.common.commands.log.subcommands; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.utils.Predicates; import java.io.File; import java.io.IOException; @@ -38,7 +42,7 @@ import java.util.List; public class LogExport extends SubCommand { public LogExport() { - super("export", "Export the log to a file", Permission.LOG_EXPORT, Predicate.not(1), + super("export", "Export the log to a file", Permission.LOG_EXPORT, Predicates.not(1), Arg.list(Arg.create("file", true, "the name of the file")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogGroupHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogGroupHistory.java index ba24e4e50..fc795b24c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogGroupHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogGroupHistory.java @@ -24,12 +24,16 @@ package me.lucko.luckperms.common.commands.log.subcommands; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; @@ -37,7 +41,7 @@ import java.util.SortedMap; public class LogGroupHistory extends SubCommand { public LogGroupHistory() { - super("grouphistory", "View an group's history", Permission.LOG_GROUP_HISTORY, Predicate.notInRange(1, 2), + super("grouphistory", "View an group's history", Permission.LOG_GROUP_HISTORY, Predicates.notInRange(1, 2), Arg.list( Arg.create("group", true, "the name of the group"), Arg.create("page", false, "the page number to view") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogNotify.java index cc91151e3..0dfae5295 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogNotify.java @@ -23,10 +23,14 @@ package me.lucko.luckperms.common.commands.log.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Set; @@ -34,7 +38,7 @@ import java.util.UUID; public class LogNotify extends SubCommand { public LogNotify() { - super("notify", "Toggle notifications", Permission.LOG_NOTIFY, Predicate.notInRange(0, 1), + super("notify", "Toggle notifications", Permission.LOG_NOTIFY, Predicates.notInRange(0, 1), Arg.list(Arg.create("on|off", false, "whether to toggle on or off")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogRecent.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogRecent.java index 95b28a30d..b92dd9303 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogRecent.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogRecent.java @@ -30,6 +30,7 @@ import me.lucko.luckperms.common.constants.Patterns; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; @@ -38,7 +39,7 @@ import java.util.UUID; public class LogRecent extends SubCommand { public LogRecent() { - super("recent", "View recent actions", Permission.LOG_RECENT, Predicate.notInRange(0, 2), + super("recent", "View recent actions", Permission.LOG_RECENT, Predicates.notInRange(0, 2), Arg.list( Arg.create("user", false, "the name/uuid of the user to filter by"), Arg.create("page", false, "the page number to view") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogSearch.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogSearch.java index 277f471f5..fed27f965 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogSearch.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogSearch.java @@ -24,11 +24,15 @@ package me.lucko.luckperms.common.commands.log.subcommands; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; @@ -37,7 +41,7 @@ import java.util.stream.Collectors; public class LogSearch extends SubCommand { public LogSearch() { - super("search", "Search the log for an entry", Permission.LOG_SEARCH, Predicate.is(0), + super("search", "Search the log for an entry", Permission.LOG_SEARCH, Predicates.is(0), Arg.list( Arg.create("query", true, "the query to search by"), Arg.create("page", false, "the page number to view") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogTrackHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogTrackHistory.java index aed4d136d..854d8794c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogTrackHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogTrackHistory.java @@ -24,12 +24,16 @@ package me.lucko.luckperms.common.commands.log.subcommands; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.utils.ArgumentChecker; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; @@ -37,7 +41,7 @@ import java.util.SortedMap; public class LogTrackHistory extends SubCommand { public LogTrackHistory() { - super("trackhistory", "View a track's history", Permission.LOG_TRACK_HISTORY, Predicate.notInRange(1, 2), + super("trackhistory", "View a track's history", Permission.LOG_TRACK_HISTORY, Predicates.notInRange(1, 2), Arg.list( Arg.create("track", true, "the name of the track"), Arg.create("page", false, "the page number to view") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogUserHistory.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogUserHistory.java index e502520c2..1f81f9c21 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogUserHistory.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/subcommands/LogUserHistory.java @@ -30,6 +30,7 @@ import me.lucko.luckperms.common.constants.Patterns; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.utils.DateUtil; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.Map; @@ -38,7 +39,7 @@ import java.util.UUID; public class LogUserHistory extends SubCommand { public LogUserHistory() { - super("userhistory", "View a user's history", Permission.LOG_USER_HISTORY, Predicate.notInRange(1, 2), + super("userhistory", "View a user's history", Permission.LOG_USER_HISTORY, Predicates.notInRange(1, 2), Arg.list( Arg.create("user", true, "the name/uuid of the user"), Arg.create("page", false, "the page number to view") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackAppend.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackAppend.java index c360fa8cb..92fc72a02 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackAppend.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackAppend.java @@ -30,13 +30,14 @@ import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class TrackAppend extends SubCommand { public TrackAppend() { - super("append", "Appends a group onto the end of the track", Permission.TRACK_APPEND, Predicate.not(1), + super("append", "Appends a group onto the end of the track", Permission.TRACK_APPEND, Predicates.not(1), Arg.list(Arg.create("group", true, "the group to append")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClear.java index 942ee2925..8110f17d5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClear.java @@ -24,19 +24,19 @@ package me.lucko.luckperms.common.commands.track.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.tracks.Track; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackClear extends SubCommand { public TrackClear() { - super("clear", "Clears the groups on the track", Permission.TRACK_CLEAR, Predicate.alwaysFalse(), null); + super("clear", "Clears the groups on the track", Permission.TRACK_CLEAR, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClone.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClone.java index 4dfc0e116..b6efa8c25 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClone.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackClone.java @@ -23,18 +23,22 @@ package me.lucko.luckperms.common.commands.track.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackClone extends SubCommand { public TrackClone() { - super("clone", "Clone the track", Permission.TRACK_CLONE, Predicate.not(1), + super("clone", "Clone the track", Permission.TRACK_CLONE, Predicates.not(1), Arg.list(Arg.create("name", true, "the name of the clone")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInfo.java index 36953292a..11161bf55 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInfo.java @@ -23,16 +23,20 @@ package me.lucko.luckperms.common.commands.track.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.tracks.Track; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackInfo extends SubCommand { public TrackInfo() { - super("info", "Gives info about the track", Permission.TRACK_INFO, Predicate.alwaysFalse(), null); + super("info", "Gives info about the track", Permission.TRACK_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInsert.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInsert.java index 87d145810..ce4ea19f4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInsert.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackInsert.java @@ -30,13 +30,14 @@ import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class TrackInsert extends SubCommand { public TrackInsert() { - super("insert", "Inserts a group at a given position along the track", Permission.TRACK_INSERT, Predicate.not(2), + super("insert", "Inserts a group at a given position along the track", Permission.TRACK_INSERT, Predicates.not(2), Arg.list( Arg.create("group", true, "the group to insert"), Arg.create("position", true, "the position to insert the group at (the first position on the track is 1)") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRemove.java index 996aa186e..0f52f879e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRemove.java @@ -29,13 +29,14 @@ import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectLacksException; import java.util.List; public class TrackRemove extends SubCommand { public TrackRemove() { - super("remove", "Removes a group from the track", Permission.TRACK_REMOVE, Predicate.not(1), + super("remove", "Removes a group from the track", Permission.TRACK_REMOVE, Predicates.not(1), Arg.list(Arg.create("group", true, "the group to remove")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRename.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRename.java index 27ca01062..4e7ccc785 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRename.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/subcommands/TrackRename.java @@ -23,18 +23,22 @@ package me.lucko.luckperms.common.commands.track.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class TrackRename extends SubCommand { public TrackRename() { - super("rename", "Rename the track", Permission.TRACK_RENAME, Predicate.not(1), + super("rename", "Rename the track", Permission.TRACK_RENAME, Predicates.not(1), Arg.list(Arg.create("name", true, "the new name")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserBulkChange.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserBulkChange.java index 2335d0776..3e4ba0e51 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserBulkChange.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserBulkChange.java @@ -24,11 +24,15 @@ package me.lucko.luckperms.common.commands.user.subcommands; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -39,7 +43,7 @@ import java.util.Set; public class UserBulkChange extends SubCommand { public UserBulkChange() { - super("bulkchange", "Applies a bulk permission change to the user's permissions", Permission.USER_BULKCHANGE, Predicate.not(3), + super("bulkchange", "Applies a bulk permission change to the user's permissions", Permission.USER_BULKCHANGE, Predicates.not(3), Arg.list( Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), Arg.create("from", true, "the server/world to be changed from. can be 'global' or 'null' respectively"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserClear.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserClear.java index 3d283ca8e..b3925f72c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserClear.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserClear.java @@ -23,19 +23,23 @@ package me.lucko.luckperms.common.commands.user.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; import java.util.stream.Collectors; public class UserClear extends SubCommand { public UserClear() { - super("clear", "Clears the user's permissions and groups", Permission.USER_CLEAR, Predicate.notInRange(0, 2), + super("clear", "Clears the user's permissions and groups", Permission.USER_CLEAR, Predicates.notInRange(0, 2), Arg.list( Arg.create("server", false, "the server name to filter by"), Arg.create("world", false, "the world name to filter by") diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java index 27a964d89..a8aefa023 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserDemote.java @@ -37,6 +37,7 @@ import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -48,7 +49,7 @@ import java.util.stream.Collectors; public class UserDemote extends SubCommand { public UserDemote() { - super("demote", "Demotes the user down a track", Permission.USER_DEMOTE, Predicate.notInRange(1, 3), + super("demote", "Demotes the user down a track", Permission.USER_DEMOTE, Predicates.notInRange(1, 3), Arg.list( Arg.create("track", true, "the track to demote the user down"), Arg.create("server", false, "the server to promote on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserGetUUID.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserGetUUID.java index 632f8e361..232d52761 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserGetUUID.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserGetUUID.java @@ -24,18 +24,18 @@ package me.lucko.luckperms.common.commands.user.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class UserGetUUID extends SubCommand { public UserGetUUID() { - super("getuuid", "Displays the user's internal LuckPerms unique id", Permission.USER_GETUUID, Predicate.alwaysFalse(), null); + super("getuuid", "Displays the user's internal LuckPerms unique id", Permission.USER_GETUUID, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserInfo.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserInfo.java index e5e0378dc..05d56fcba 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserInfo.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserInfo.java @@ -24,18 +24,18 @@ package me.lucko.luckperms.common.commands.user.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.commands.CommandResult; -import me.lucko.luckperms.common.commands.Predicate; import me.lucko.luckperms.common.commands.Sender; import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import java.util.List; public class UserInfo extends SubCommand { public UserInfo() { - super("info", "Shows info about the user", Permission.USER_INFO, Predicate.alwaysFalse(), null); + super("info", "Shows info about the user", Permission.USER_INFO, Predicates.alwaysFalse(), null); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java index 40c345052..def7d944c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserPromote.java @@ -37,6 +37,7 @@ import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.tracks.Track; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.ArgumentChecker; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -48,7 +49,7 @@ import java.util.stream.Collectors; public class UserPromote extends SubCommand { public UserPromote() { - super("promote", "Promotes the user up a track", Permission.USER_PROMOTE, Predicate.notInRange(1, 3), + super("promote", "Promotes the user up a track", Permission.USER_PROMOTE, Predicates.notInRange(1, 3), Arg.list( Arg.create("track", true, "the track to promote the user up"), Arg.create("server", false, "the server to promote on"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java index be3201a22..07f281725 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/user/subcommands/UserSetPrimaryGroup.java @@ -23,19 +23,23 @@ package me.lucko.luckperms.common.commands.user.subcommands; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.data.LogEntry; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import java.util.List; public class UserSetPrimaryGroup extends SubCommand { public UserSetPrimaryGroup() { - super("setprimarygroup", "Sets the user's primary group", Permission.USER_SETPRIMARYGROUP, Predicate.not(1), + super("setprimarygroup", "Sets the user's primary group", Permission.USER_SETPRIMARYGROUP, Predicates.not(1), Arg.list(Arg.create("group", true, "the group to set as the primary group")) ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java index 5f98e092e..a0c9b8e49 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditGroup.java @@ -24,12 +24,16 @@ package me.lucko.luckperms.common.commands.usersbulkedit.subcommands; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.storage.Datastore; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -37,7 +41,7 @@ import java.util.*; public class BulkEditGroup extends SubCommand { public BulkEditGroup() { - super("group", "Bulk edit group memberships", Permission.USER_BULKCHANGE, Predicate.not(4), + super("group", "Bulk edit group memberships", Permission.USER_BULKCHANGE, Predicates.not(4), Arg.list( Arg.create("group|null", true, "the group to edit ('null' to select and edit all groups)"), Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditPermission.java b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditPermission.java index 451f59b7e..225c61919 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditPermission.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/usersbulkedit/subcommands/BulkEditPermission.java @@ -24,12 +24,16 @@ package me.lucko.luckperms.common.commands.usersbulkedit.subcommands; import me.lucko.luckperms.api.Node; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.Arg; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeFactory; import me.lucko.luckperms.common.storage.Datastore; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; @@ -37,7 +41,7 @@ import java.util.*; public class BulkEditPermission extends SubCommand { public BulkEditPermission() { - super("permission", "Bulk edit permissions", Permission.USER_BULKCHANGE, Predicate.not(4), + super("permission", "Bulk edit permissions", Permission.USER_BULKCHANGE, Predicates.not(4), Arg.list( Arg.create("node|null", true, "the node to edit ('null' to select and edit all nodes)"), Arg.create("server|world", true, "if the bulk change is modifying a 'server' or a 'world'"), diff --git a/common/src/main/java/me/lucko/luckperms/common/constants/Patterns.java b/common/src/main/java/me/lucko/luckperms/common/constants/Patterns.java index 95c7e88d4..76dd9d222 100644 --- a/common/src/main/java/me/lucko/luckperms/common/constants/Patterns.java +++ b/common/src/main/java/me/lucko/luckperms/common/constants/Patterns.java @@ -27,6 +27,7 @@ import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.ListenableFuture; +import com.google.common.util.concurrent.UncheckedExecutionException; import lombok.experimental.UtilityClass; import java.util.concurrent.ExecutionException; @@ -57,7 +58,7 @@ public class Patterns { public static Pattern compile(String regex) { try { return CACHE.get(regex); - } catch (ExecutionException e) { + } catch (UncheckedExecutionException | ExecutionException e) { return null; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java index fd0cf9540..7087b82d1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/data/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/data/Importer.java @@ -114,7 +114,7 @@ public class Importer { int errors = 0; for (Map.Entry e : cmdResult.entrySet()) { - if (e.getValue().getResult() != null && !e.getValue().getResult().booleanValue()) { + if (e.getValue().getResult() != null && !e.getValue().getResult().asBoolean()) { errors++; } } @@ -129,7 +129,7 @@ public class Importer { int errIndex = 1; for (Map.Entry e : cmdResult.entrySet()) { - if (e.getValue().getResult() != null && !e.getValue().getResult().booleanValue()) { + if (e.getValue().getResult() != null && !e.getValue().getResult().asBoolean()) { Message.IMPORT_END_ERROR_HEADER.send(executor, errIndex, e.getKey(), e.getValue().getCommand(), e.getValue().getResult().toString()); for (String s : e.getValue().getOutput()) { Message.IMPORT_END_ERROR_CONTENT.send(executor, s); @@ -147,7 +147,7 @@ public class Importer { int errors = 0; for (Map.Entry e : cmdResult.entrySet()) { - if (e.getValue().getResult() != null && !e.getValue().getResult().booleanValue()) { + if (e.getValue().getResult() != null && !e.getValue().getResult().asBoolean()) { errors++; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java index 3c50ca7ed..b9d2560f4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/AbstractDatastore.java @@ -24,6 +24,7 @@ package me.lucko.luckperms.common.storage; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; +import lombok.experimental.Delegate; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.LuckPermsPlugin; import me.lucko.luckperms.common.data.Log; @@ -44,13 +45,13 @@ import java.util.function.Supplier; */ @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public class AbstractDatastore implements Datastore { - public static Datastore wrap(LuckPermsPlugin plugin, AbstractBacking backing) { BufferedOutputDatastore bufferedDs = BufferedOutputDatastore.wrap(TolerantDatastore.wrap(new AbstractDatastore(backing)), 1000L); plugin.doAsyncRepeating(bufferedDs, 10L); return bufferedDs; } + @Delegate(types = Delegated.class) private final AbstractBacking backing; private LPFuture makeFuture(Supplier supplier) { @@ -62,46 +63,11 @@ public class AbstractDatastore implements Datastore { return future; } - @Override - public String getName() { - return backing.getName(); - } - - @Override - public boolean isAcceptingLogins() { - return backing.isAcceptingLogins(); - } - - @Override - public void setAcceptingLogins(boolean acceptingLogins) { - backing.setAcceptingLogins(acceptingLogins); - } - - @Override - public void doAsync(Runnable r) { - backing.doAsync(r); - } - - @Override - public void doSync(Runnable r) { - backing.doSync(r); - } - @Override public Datastore force() { return this; } - @Override - public void init() { - backing.init(); - } - - @Override - public void shutdown() { - backing.shutdown(); - } - @Override public LPFuture logAction(LogEntry entry) { return makeFuture(() -> backing.logAction(entry)); @@ -196,4 +162,14 @@ public class AbstractDatastore implements Datastore { public LPFuture getName(UUID uuid) { return makeFuture(() -> backing.getName(uuid)); } + + private interface Delegated { + String getName(); + boolean isAcceptingLogins(); + void setAcceptingLogins(boolean b); + void doAsync(Runnable r); + void doSync(Runnable r); + void init(); + void shutdown(); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/BufferedOutputDatastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/BufferedOutputDatastore.java index f9f5fec95..d28418b1b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/BufferedOutputDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/BufferedOutputDatastore.java @@ -91,6 +91,7 @@ public class BufferedOutputDatastore implements Datastore, Runnable { userOutputBuffer.flush(flushTime); } + @Override public Datastore force() { return backing; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java b/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java index 873d417dd..b06f3dcda 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/TolerantDatastore.java @@ -24,6 +24,7 @@ package me.lucko.luckperms.common.storage; import lombok.AccessLevel; import lombok.RequiredArgsConstructor; +import lombok.experimental.Delegate; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.common.data.Log; import me.lucko.luckperms.common.groups.Group; @@ -46,44 +47,16 @@ public class TolerantDatastore implements Datastore { return new TolerantDatastore(datastore); } + @Delegate(types = Delegated.class) private final Datastore backing; + private final Phaser phaser = new Phaser(); - @Override - public String getName() { - return backing.getName(); - } - - @Override - public boolean isAcceptingLogins() { - return backing.isAcceptingLogins(); - } - - @Override - public void setAcceptingLogins(boolean acceptingLogins) { - backing.setAcceptingLogins(acceptingLogins); - } - - @Override - public void doAsync(Runnable r) { - backing.doAsync(r); - } - - @Override - public void doSync(Runnable r) { - backing.doSync(r); - } - @Override public Datastore force() { return this; } - @Override - public void init() { - backing.init(); - } - @Override public void shutdown() { // Wait for other threads to finish. @@ -285,4 +258,13 @@ public class TolerantDatastore implements Datastore { phaser.arriveAndDeregister(); } } + + private interface Delegated { + String getName(); + boolean isAcceptingLogins(); + void setAcceptingLogins(boolean b); + void doAsync(Runnable r); + void doSync(Runnable r); + void init(); + } } diff --git a/common/src/main/java/me/lucko/luckperms/common/tracks/Track.java b/common/src/main/java/me/lucko/luckperms/common/tracks/Track.java index 67817b42c..4c5100eeb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/tracks/Track.java +++ b/common/src/main/java/me/lucko/luckperms/common/tracks/Track.java @@ -22,6 +22,7 @@ package me.lucko.luckperms.common.tracks; +import com.google.common.collect.ImmutableList; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.RequiredArgsConstructor; @@ -66,7 +67,7 @@ public class Track implements Identifiable { * @return am ordered {@link List} of the groups on this track */ public List getGroups() { - return Collections.unmodifiableList(groups); + return ImmutableList.copyOf(groups); } public void setGroups(List groups) { diff --git a/common/src/main/java/me/lucko/luckperms/common/users/User.java b/common/src/main/java/me/lucko/luckperms/common/users/User.java index 513971014..3bf5600ec 100644 --- a/common/src/main/java/me/lucko/luckperms/common/users/User.java +++ b/common/src/main/java/me/lucko/luckperms/common/users/User.java @@ -99,7 +99,7 @@ public class User extends PermissionHolder implements Identifiable { public static UserIdentifier of(UUID uuid, String username) { @@ -45,17 +43,4 @@ public class UserIdentifier implements Identifiable { public UUID getId() { return getUuid(); } - - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof UserIdentifier)) return false; - final UserIdentifier other = (UserIdentifier) o; - final Object thisUuid = this.getUuid(); - final Object otherUuid = other.getUuid(); - return thisUuid == null ? otherUuid == null : thisUuid.equals(otherUuid); - } - - public int hashCode() { - return 59 + (this.getUuid() == null ? 43 : this.getUuid().hashCode()); - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/users/UserManager.java b/common/src/main/java/me/lucko/luckperms/common/users/UserManager.java index 947c7a470..08f8829de 100644 --- a/common/src/main/java/me/lucko/luckperms/common/users/UserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/users/UserManager.java @@ -42,7 +42,6 @@ public class UserManager extends AbstractManager { * @param name The name to search by * @return a {@link User} object if the user is loaded, returns null if the user is not loaded */ - @SuppressWarnings("OptionalGetWithoutIsPresent") public User get(String name) { for (User user : getAll().values()) { if (user.getName().equalsIgnoreCase(name)) { diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/Buffer.java b/common/src/main/java/me/lucko/luckperms/common/utils/Buffer.java index 95ea2b19c..ffe1703b0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/Buffer.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Buffer.java @@ -22,10 +22,7 @@ package me.lucko.luckperms.common.utils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NonNull; -import lombok.Setter; +import lombok.*; import java.util.LinkedList; import java.util.List; @@ -96,29 +93,15 @@ public abstract class Buffer implements Runnable { flush(DEFAULT_FLUSH_TIME); } + @Getter + @EqualsAndHashCode(of = "object") @AllArgsConstructor private static class BufferedObject { - @Getter @Setter private long bufferTime; - - @Getter private final T object; - - @Getter private final AbstractFuture future; - public boolean equals(Object o) { - if (o == this) return true; - if (!(o instanceof Buffer.BufferedObject)) return false; - - final BufferedObject other = (BufferedObject) o; - return this.getObject() == null ? other.getObject() == null : this.getObject().equals(other.getObject()); - } - - public int hashCode() { - return 59 + (this.getObject() == null ? 43 : this.getObject().hashCode()); - } } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/Predicate.java b/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java similarity index 71% rename from common/src/main/java/me/lucko/luckperms/common/commands/Predicate.java rename to common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java index b5733e446..e0b4cf80f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/Predicate.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/Predicates.java @@ -20,38 +20,39 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.commands; +package me.lucko.luckperms.common.utils; import lombok.experimental.UtilityClass; import java.util.Set; +import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.IntStream; @SuppressWarnings({"WeakerAccess", "unused"}) @UtilityClass -public class Predicate { - public static java.util.function.Predicate alwaysFalse() { +public class Predicates { + public static Predicate alwaysFalse() { return t -> false; } - public static java.util.function.Predicate alwaysTrue() { + public static Predicate alwaysTrue() { return t -> true; } - public static java.util.function.Predicate notInRange(Integer start, Integer end) { + public static Predicate notInRange(Integer start, Integer end) { return inverse(inRange(start, end)); } - public static java.util.function.Predicate inRange(Integer start, Integer end) { + public static Predicate inRange(Integer start, Integer end) { return isOneOf(IntStream.rangeClosed(start, end).boxed().collect(Collectors.toSet())); } - public static java.util.function.Predicate notOneOf(Set ts) { + public static Predicate notOneOf(Set ts) { return inverse(isOneOf(ts)); } - public static java.util.function.Predicate isOneOf(Set ta) { + public static Predicate isOneOf(Set ta) { return t -> { for (T i : ta) { if (i == t) { @@ -62,15 +63,15 @@ public class Predicate { }; } - public static java.util.function.Predicate not(T t) { + public static Predicate not(T t) { return inverse(is(t)); } - public static java.util.function.Predicate is(T t) { + public static Predicate is(T t) { return t2 -> t == t2; } - public static java.util.function.Predicate inverse(java.util.function.Predicate t) { + public static Predicate inverse(Predicate t) { return t2 -> !t.test(t2); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java index a417371b1..4658f3d02 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/LPSpongePlugin.java @@ -307,7 +307,7 @@ public class LPSpongePlugin implements LuckPermsPlugin { @Override public List getNotifyListeners() { return game.getServer().getOnlinePlayers().stream() - .map(s -> SpongeSenderFactory.get(this).wrap(s, Collections.singleton(Permission.LOG_NOTIFY))) + .map(s -> SpongeSenderFactory.get(this).wrap(s)) .filter(Permission.LOG_NOTIFY::isAuthorized) .collect(Collectors.toList()); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java index 91b0821a0..f211919e0 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java @@ -26,12 +26,16 @@ import me.lucko.luckperms.api.Logger; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.LuckPermsPlugin; -import me.lucko.luckperms.common.commands.*; +import me.lucko.luckperms.common.commands.CommandResult; +import me.lucko.luckperms.common.commands.Sender; +import me.lucko.luckperms.common.commands.SubCommand; +import me.lucko.luckperms.common.commands.Util; import me.lucko.luckperms.common.constants.Permission; import me.lucko.luckperms.common.core.NodeBuilder; import me.lucko.luckperms.common.core.PermissionHolder; import me.lucko.luckperms.common.groups.Group; import me.lucko.luckperms.common.users.User; +import me.lucko.luckperms.common.utils.Predicates; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.sponge.service.LuckPermsService; import org.spongepowered.api.Sponge; @@ -44,7 +48,7 @@ import java.util.*; public class MigrationPermissionsEx extends SubCommand { public MigrationPermissionsEx() { - super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicate.alwaysFalse(), null); + super("permissionsex", "Migration from PermissionsEx", Permission.MIGRATION, Predicates.alwaysFalse(), null); } @Override