From cb9e0899fce3db343b8d2c610baca2b967590b87 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 10 Feb 2021 11:12:30 +0000 Subject: [PATCH] Misc refactoring and tidying up --- .../java/net/luckperms/api/node/NodeType.java | 18 +++++++++--------- .../bukkit/BukkitCommandExecutor.java | 2 +- .../bukkit/calculator/DefaultsProcessor.java | 2 +- .../LuckPermsPermissionAttachment.java | 2 +- .../permissible/PermissibleInjector.java | 2 +- .../inject/server/LuckPermsPermissionMap.java | 2 +- .../server/LuckPermsSubscriptionMap.java | 2 +- .../BungeePermissionCheckListener.java | 4 ++-- .../common/actionlog/LogDispatcher.java | 2 +- .../luckperms/common/backup/Importer.java | 2 +- .../luckperms/common/cache/ExpiringCache.java | 2 +- .../common/cacheddata/UsageTracked.java | 2 +- .../processor/WildcardProcessor.java | 2 +- .../common/command/CommandManager.java | 2 +- .../command/access/ArgumentPermissions.java | 12 ++++++------ .../common/command/spec/CommandSpec.java | 2 +- .../command/tabcomplete/TabCompleter.java | 2 +- .../common/command/utils/StorageAssistant.java | 4 ++-- .../common/commands/generic/meta/MetaInfo.java | 2 +- .../generic/parent/ParentClearTrack.java | 2 +- .../commands/generic/parent/ParentRemove.java | 2 +- .../generic/parent/ParentSetTrack.java | 2 +- .../generic/parent/UserSwitchPrimaryGroup.java | 2 +- .../contextset/ImmutableContextSetImpl.java | 2 +- .../contextset/MutableContextSetImpl.java | 2 +- .../common/event/AbstractEventBus.java | 2 +- .../common/graph/TraversalAlgorithm.java | 2 +- .../inheritance/InheritanceComparator.java | 2 +- .../lucko/luckperms/common/locale/Message.java | 2 +- .../luckperms/common/node/AbstractNode.java | 2 +- .../node/factory/NodeCommandFactory.java | 2 +- .../common/node/utils/ShorthandParser.java | 2 +- .../luckperms/common/query/FlagUtils.java | 4 ++-- .../storage/implementation/sql/SqlRowId.java | 2 +- .../connection/file/H2ConnectionFactory.java | 2 +- .../file/SqliteConnectionFactory.java | 2 +- .../common/treeview/ImmutableTreeNode.java | 2 +- .../luckperms/common/treeview/TreeView.java | 2 +- .../lucko/luckperms/common/util/Paginated.java | 2 +- .../expression/BooleanExpressionCompiler.java | 2 +- .../event/PlayerChangeWorldCallback.java | 2 +- .../fabric/mixin/ServerPlayerEntityMixin.java | 2 +- .../nukkit/calculator/DefaultsProcessor.java | 2 +- .../LuckPermsPermissionAttachment.java | 2 +- .../permissible/PermissibleInjector.java | 2 +- .../inject/server/LuckPermsPermissionMap.java | 2 +- .../server/LuckPermsSubscriptionMap.java | 2 +- .../reference/CachedSubjectReference.java | 2 +- .../reference/SubjectReferenceFactory.java | 2 +- .../sponge/SpongeCommandExecutor.java | 2 +- .../listeners/SpongePlatformListener.java | 2 +- .../inheritance/SubjectInheritanceGraph.java | 2 +- .../PermissionHolderSubjectData.java | 4 ++-- .../model/persisted/SubjectDataContainer.java | 2 +- 54 files changed, 71 insertions(+), 71 deletions(-) diff --git a/api/src/main/java/net/luckperms/api/node/NodeType.java b/api/src/main/java/net/luckperms/api/node/NodeType.java index 71c7d2d46..57c9a02f7 100644 --- a/api/src/main/java/net/luckperms/api/node/NodeType.java +++ b/api/src/main/java/net/luckperms/api/node/NodeType.java @@ -48,47 +48,47 @@ public interface NodeType { /** * Node type for {@link PermissionNode}. */ - NodeType PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> ((PermissionNode) n)); + NodeType PERMISSION = new SimpleNodeType<>("PERMISSION", n -> n instanceof PermissionNode, n -> (PermissionNode) n); /** * Node type for {@link RegexPermissionNode}. */ - NodeType REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> ((RegexPermissionNode) n)); + NodeType REGEX_PERMISSION = new SimpleNodeType<>("REGEX_PERMISSION", n -> n instanceof RegexPermissionNode, n -> (RegexPermissionNode) n); /** * Node type for {@link InheritanceNode}. */ - NodeType INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> ((InheritanceNode) n)); + NodeType INHERITANCE = new SimpleNodeType<>("INHERITANCE", n -> n instanceof InheritanceNode, n -> (InheritanceNode) n); /** * Node type for {@link PrefixNode}. */ - NodeType PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> ((PrefixNode) n)); + NodeType PREFIX = new SimpleNodeType<>("PREFIX", n -> n instanceof PrefixNode, n -> (PrefixNode) n); /** * Node type for {@link SuffixNode}. */ - NodeType SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> ((SuffixNode) n)); + NodeType SUFFIX = new SimpleNodeType<>("SUFFIX", n -> n instanceof SuffixNode, n -> (SuffixNode) n); /** * Node type for {@link MetaNode}. */ - NodeType META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> ((MetaNode) n)); + NodeType META = new SimpleNodeType<>("META", n -> n instanceof MetaNode, n -> (MetaNode) n); /** * Node type for {@link WeightNode}. */ - NodeType WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> ((WeightNode) n)); + NodeType WEIGHT = new SimpleNodeType<>("WEIGHT", n -> n instanceof WeightNode, n -> (WeightNode) n); /** * Node type for {@link DisplayNameNode}. */ - NodeType DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> ((DisplayNameNode) n)); + NodeType DISPLAY_NAME = new SimpleNodeType<>("DISPLAY_NAME", n -> n instanceof DisplayNameNode, n -> (DisplayNameNode) n); /** * Node type for {@link ChatMetaNode}. */ - NodeType> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode, n -> ((ChatMetaNode) n)); + NodeType> CHAT_META = new SimpleNodeType<>("CHAT_META", n -> n instanceof ChatMetaNode, n -> (ChatMetaNode) n); /** * Node type for {@link ChatMetaNode} or {@link MetaNode}. diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java index ad98b415f..25e9940d4 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitCommandExecutor.java @@ -140,7 +140,7 @@ public class BukkitCommandExecutor extends CommandManager implements TabExecutor try { matchedPlayers = this.plugin.getBootstrap().getServer().selectEntities(sender, arg).stream() .filter(e -> e instanceof Player) - .map(e -> ((Player) e)) + .map(e -> (Player) e) .collect(Collectors.toList()); } catch (IllegalArgumentException e) { this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + sender + " executing " + args, e); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/calculator/DefaultsProcessor.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/calculator/DefaultsProcessor.java index a395bdd35..4f0a6a846 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/calculator/DefaultsProcessor.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/calculator/DefaultsProcessor.java @@ -67,7 +67,7 @@ public class DefaultsProcessor implements PermissionProcessor { Permission defPerm = this.plugin.getPermissionMap().get(permission); if (defPerm != null) { PermissionDefault def = defPerm.getDefault(); - if (def == PermissionDefault.FALSE || (this.isOp && def == PermissionDefault.NOT_OP)) { + if (def == PermissionDefault.FALSE || this.isOp && def == PermissionDefault.NOT_OP) { return PERMISSION_MAP_RESULT_FACTORY.result(Tristate.FALSE, "permission map (overriding wildcard): " + prev.cause()); } } diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissionAttachment.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissionAttachment.java index 6f60052a7..3624658dc 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissionAttachment.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissionAttachment.java @@ -331,7 +331,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment { return null; } - String permission = ((String) key); + String permission = (String) key; // grab the previous result, so we can still satisfy the method signature of Map Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java index 35afea017..7196b5196 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/PermissibleInjector.java @@ -127,7 +127,7 @@ public final class PermissibleInjector { // only uninject if the permissible was a luckperms one. if (permissible instanceof LuckPermsPermissible) { - LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible); + LuckPermsPermissible lpPermissible = (LuckPermsPermissible) permissible; // clear all permissions lpPermissible.clearPermissions(); diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java index 451b946e2..7e1791bc6 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/server/LuckPermsPermissionMap.java @@ -133,7 +133,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap { - boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || (sender != null && s.getUniqueId().equals(sender.getUniqueId())); + boolean shouldCancel = LogNotify.isIgnoring(this.plugin, s.getUniqueId()) || sender != null && s.getUniqueId().equals(sender.getUniqueId()); return !this.plugin.getEventDispatcher().dispatchLogNotify(shouldCancel, entry, origin, s); }) .forEach(s -> Message.LOG.send(s, entry)); diff --git a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java index 8cd81e13b..2d5844c9d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java +++ b/common/src/main/java/me/lucko/luckperms/common/backup/Importer.java @@ -241,7 +241,7 @@ public class Importer implements Runnable { } private void sendProgress(int processedCount, int total) { - int percent = (processedCount * 100) / total; + int percent = processedCount * 100 / total; this.notify.forEach(s -> Message.IMPORT_PROGRESS.send(s, percent, processedCount, total)); } diff --git a/common/src/main/java/me/lucko/luckperms/common/cache/ExpiringCache.java b/common/src/main/java/me/lucko/luckperms/common/cache/ExpiringCache.java index a7f061b64..fb807f810 100644 --- a/common/src/main/java/me/lucko/luckperms/common/cache/ExpiringCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/cache/ExpiringCache.java @@ -68,7 +68,7 @@ public abstract class ExpiringCache implements Supplier { nanos = now + this.durationNanos; // In the very unlikely event that nanos is 0, set it to 1; // no one will notice 1 ns of tardiness. - this.expirationNanos = (nanos == 0) ? 1 : nanos; + this.expirationNanos = nanos == 0 ? 1 : nanos; return t; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/cacheddata/UsageTracked.java b/common/src/main/java/me/lucko/luckperms/common/cacheddata/UsageTracked.java index b901528eb..602d9cacd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/cacheddata/UsageTracked.java +++ b/common/src/main/java/me/lucko/luckperms/common/cacheddata/UsageTracked.java @@ -33,6 +33,6 @@ public abstract class UsageTracked { } public boolean usedSince(long duration) { - return this.lastUsed > (System.currentTimeMillis() - duration); + return this.lastUsed > System.currentTimeMillis() - duration; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/calculator/processor/WildcardProcessor.java b/common/src/main/java/me/lucko/luckperms/common/calculator/processor/WildcardProcessor.java index 2b6823c89..fbb0faab9 100644 --- a/common/src/main/java/me/lucko/luckperms/common/calculator/processor/WildcardProcessor.java +++ b/common/src/main/java/me/lucko/luckperms/common/calculator/processor/WildcardProcessor.java @@ -47,7 +47,7 @@ public class WildcardProcessor extends AbstractPermissionProcessor implements Pe } public static boolean isWildcardPermission(String permission) { - return isRootWildcard(permission) || (permission.endsWith(WILDCARD_SUFFIX) && permission.length() > 2); + return isRootWildcard(permission) || permission.endsWith(WILDCARD_SUFFIX) && permission.length() > 2; } private Map wildcardPermissions = Collections.emptyMap(); diff --git a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java index f0cec28b8..c35a8c57d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java @@ -150,7 +150,7 @@ public class CommandManager { applyConvenienceAliases(arguments, true); // Handle no arguments - if (arguments.isEmpty() || (arguments.size() == 1 && arguments.get(0).trim().isEmpty())) { + if (arguments.isEmpty() || arguments.size() == 1 && arguments.get(0).trim().isEmpty()) { sender.sendMessage(Message.prefixed(Component.text() .color(NamedTextColor.DARK_GREEN) .append(Component.text("Running ")) diff --git a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java index d00a2e945..1e04ce33d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/access/ArgumentPermissions.java @@ -107,7 +107,7 @@ public final class ArgumentPermissions { } if (target instanceof User) { - User targetUser = ((User) target); + User targetUser = (User) target; if (targetUser.getUniqueId().equals(sender.getUniqueId())) { // the sender is trying to edit themselves @@ -131,7 +131,7 @@ public final class ArgumentPermissions { } } } else if (target instanceof Group) { - Group targetGroup = ((Group) target); + Group targetGroup = (Group) target; Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetGroup.getName()); if (state != Tristate.UNDEFINED) { @@ -142,7 +142,7 @@ public final class ArgumentPermissions { return !globalState.asBoolean(); } } else if (target instanceof Track) { - Track targetTrack = ((Track) target); + Track targetTrack = (Track) target; Tristate state = sender.getPermissionValue(base.getPermission() + ".modify." + targetTrack.getName()); if (state != Tristate.UNDEFINED) { @@ -172,7 +172,7 @@ public final class ArgumentPermissions { } if (target instanceof User) { - User targetUser = ((User) target); + User targetUser = (User) target; if (targetUser.getUniqueId().equals(sender.getUniqueId())) { // the sender is trying to view themselves @@ -196,7 +196,7 @@ public final class ArgumentPermissions { } } } else if (target instanceof Group) { - Group targetGroup = ((Group) target); + Group targetGroup = (Group) target; Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetGroup.getName()); if (state != Tristate.UNDEFINED) { @@ -207,7 +207,7 @@ public final class ArgumentPermissions { return !globalState.asBoolean(); } } else if (target instanceof Track) { - Track targetTrack = ((Track) target); + Track targetTrack = (Track) target; Tristate state = sender.getPermissionValue(base.getPermission() + ".view." + targetTrack.getName()); if (state != Tristate.UNDEFINED) { diff --git a/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java index 4da7153f0..ebf9f665c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java @@ -110,7 +110,7 @@ public enum CommandSpec { USER_INFO, USER_SWITCHPRIMARYGROUP( - (arg("group", true)) + arg("group", true) ), USER_PROMOTE( arg("track", false), diff --git a/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java b/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java index 134d7b82d..07a9b5e4a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/tabcomplete/TabCompleter.java @@ -82,7 +82,7 @@ public class TabCompleter { String partial; // nothing entered yet - if (args.isEmpty() || (partial = args.get((lastIndex = args.size() - 1))).trim().isEmpty()) { + if (args.isEmpty() || (partial = args.get(lastIndex = args.size() - 1)).trim().isEmpty()) { return getCompletions(lastIndex, ""); } diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java index f20d4cb21..7cc180d56 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/StorageAssistant.java @@ -126,10 +126,10 @@ public final class StorageAssistant { public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { if (holder.getType() == HolderType.USER) { - User user = ((User) holder); + User user = (User) holder; save(user, sender, plugin); } else if (holder.getType() == HolderType.GROUP) { - Group group = ((Group) holder); + Group group = (Group) holder; save(group, sender, plugin); } else { throw new IllegalArgumentException(); 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 2712ae22e..41d2d8f2d 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 @@ -80,7 +80,7 @@ public class MetaInfo extends GenericChildCommand { SuffixNode sn = (SuffixNode) node; suffixes.add(Maps.immutableEntry(sn.getPriority(), sn)); } else if (node instanceof MetaNode) { - meta.add(((MetaNode) node)); + meta.add((MetaNode) node); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java index 8a7ed90d1..37b54c4cf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentClearTrack.java @@ -94,7 +94,7 @@ public class ParentClearTrack extends GenericChildCommand { target.removeIf(DataType.NORMAL, context.isEmpty() ? null : context, NodeType.INHERITANCE.predicate(n -> track.containsGroup(n.getGroupName())), false); if (target.getType() == HolderType.USER) { - plugin.getUserManager().giveDefaultIfNeeded(((User) target)); + plugin.getUserManager().giveDefaultIfNeeded((User) target); } int changed = before - target.normalData().size(); 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 ced77c54c..eb73e6cd2 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 @@ -101,7 +101,7 @@ public class ParentRemove extends GenericChildCommand { .build().submit(plugin, sender); if (target.getType() == HolderType.USER) { - plugin.getUserManager().giveDefaultIfNeeded(((User) target)); + plugin.getUserManager().giveDefaultIfNeeded((User) target); } StorageAssistant.save(target, sender, plugin); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java index dbf8f180e..fa5ae962e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/ParentSetTrack.java @@ -84,7 +84,7 @@ public class ParentSetTrack extends GenericChildCommand { String groupName; if (index > 0) { List trackGroups = track.getGroups(); - if ((index - 1) >= trackGroups.size()) { + if (index - 1 >= trackGroups.size()) { Message.DOES_NOT_EXIST.send(sender, String.valueOf(index)); return CommandResult.INVALID_ARGS; } diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java index 5d5b1ec9e..dae9af0a8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/parent/UserSwitchPrimaryGroup.java @@ -63,7 +63,7 @@ public class UserSwitchPrimaryGroup extends GenericChildCommand { // cast to user // although this command is build as a sharedsubcommand, // it is only added to the listings for users. - User user = ((User) target); + User user = (User) target; if (ArgumentPermissions.checkModifyPerms(plugin, sender, permission, user)) { Message.COMMAND_NO_PERMISSION.send(sender); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java index 3e001d61d..bbc7fa7bf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java @@ -225,7 +225,7 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements public @NonNull BuilderImpl addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); if (contextSet instanceof AbstractContextSet) { - AbstractContextSet other = ((AbstractContextSet) contextSet); + AbstractContextSet other = (AbstractContextSet) contextSet; if (!other.isEmpty()) { builder().putAll(other.backing()); } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java index 6f59291da..76a2c86cb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java @@ -160,7 +160,7 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M public void addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); if (contextSet instanceof AbstractContextSet) { - AbstractContextSet other = ((AbstractContextSet) contextSet); + AbstractContextSet other = (AbstractContextSet) contextSet; other.copyTo(this.map); } else { addAll(contextSet.toSet()); diff --git a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java index 1ee804366..08f22ed98 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/AbstractEventBus.java @@ -163,7 +163,7 @@ public abstract class AbstractEventBus

implements EventBus, AutoCloseable { //noinspection unchecked return super.subscribers().values().stream() .filter(s -> s instanceof EventSubscription && ((EventSubscription) s).getEventClass().isAssignableFrom(eventClass)) - .map(s -> ((EventSubscription) s)) + .map(s -> (EventSubscription) s) .collect(Collectors.toSet()); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/graph/TraversalAlgorithm.java b/common/src/main/java/me/lucko/luckperms/common/graph/TraversalAlgorithm.java index 29b2691b0..42e235cfb 100644 --- a/common/src/main/java/me/lucko/luckperms/common/graph/TraversalAlgorithm.java +++ b/common/src/main/java/me/lucko/luckperms/common/graph/TraversalAlgorithm.java @@ -173,7 +173,7 @@ public enum TraversalAlgorithm { NodeAndSuccessors node = this.stack.getFirst(); boolean firstVisit = this.visited.add(node.node); boolean lastVisit = !node.successorIterator.hasNext(); - boolean produceNode = (firstVisit && this.order == Order.PRE_ORDER) || (lastVisit && this.order == Order.POST_ORDER); + boolean produceNode = firstVisit && this.order == Order.PRE_ORDER || lastVisit && this.order == Order.POST_ORDER; if (lastVisit) { this.stack.pop(); } else { diff --git a/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceComparator.java b/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceComparator.java index 724fe052c..7c2d51e35 100644 --- a/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/inheritance/InheritanceComparator.java @@ -41,7 +41,7 @@ public class InheritanceComparator implements Comparator { public static Comparator getFor(PermissionHolder origin) { if (origin.getType() == HolderType.USER) { - return new InheritanceComparator(((User) origin)).reversed(); + return new InheritanceComparator((User) origin).reversed(); } return NULL_ORIGIN; } diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index 13fc0ebf6..c52d9a11e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -2797,7 +2797,7 @@ public interface Message { // "&aInstalling language {}..." .key("luckperms.command.translations.installing-specific") .color(GREEN) - .args(text((name))) + .args(text(name)) ); Args0 TRANSLATIONS_INSTALL_COMPLETE = () -> prefixed(translatable() diff --git a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java index 736c768e7..32e02e297 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNode.java @@ -138,7 +138,7 @@ public abstract class AbstractNode, B extends NodeBui public boolean equals(Object o) { if (o == this) return true; if (!(o instanceof Node)) return false; - return NodeEquality.KEY_VALUE_EXPIRY_CONTEXTS.equals(this, ((AbstractNode) o)); + return NodeEquality.KEY_VALUE_EXPIRY_CONTEXTS.equals(this, (AbstractNode) o); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeCommandFactory.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeCommandFactory.java index d7b271672..47212c29a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeCommandFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeCommandFactory.java @@ -52,7 +52,7 @@ public final class NodeCommandFactory { // value sb.append(((InheritanceNode) node).getGroupName()); - } else if (node.getValue() && (node instanceof ChatMetaNode)) { + } else if (node.getValue() && node instanceof ChatMetaNode) { ChatMetaNode chatNode = (ChatMetaNode) node; // command diff --git a/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java b/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java index 21a12b793..86c67720d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/utils/ShorthandParser.java @@ -45,7 +45,7 @@ public enum ShorthandParser { @Override public Iterator extract(String input) throws NumberFormatException { int index = input.indexOf(RANGE_SEPARATOR); - if (index == -1 || index == 0 || index == (input.length() - 1)) { + if (index == -1 || index == 0 || index == input.length() - 1) { return null; } diff --git a/common/src/main/java/me/lucko/luckperms/common/query/FlagUtils.java b/common/src/main/java/me/lucko/luckperms/common/query/FlagUtils.java index a27f896fe..6b0be4495 100644 --- a/common/src/main/java/me/lucko/luckperms/common/query/FlagUtils.java +++ b/common/src/main/java/me/lucko/luckperms/common/query/FlagUtils.java @@ -40,7 +40,7 @@ final class FlagUtils { /* bitwise utility methods */ static boolean read(byte b, Flag setting) { - return ((b >> setting.ordinal()) & 1) == 1; + return (b >> setting.ordinal() & 1) == 1; } static byte toByte(Set settings) { @@ -54,7 +54,7 @@ final class FlagUtils { private static byte toByte0(Set settings) { byte b = 0; for (Flag setting : settings) { - b |= (1 << setting.ordinal()); + b |= 1 << setting.ordinal(); } return b; } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlRowId.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlRowId.java index 9e1bc01cb..ae9ba4862 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlRowId.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlRowId.java @@ -42,7 +42,7 @@ public final class SqlRowId { @Override public boolean equals(Object o) { - return this == o || (o instanceof SqlRowId && this.rowId == ((SqlRowId) o).rowId); + return this == o || o instanceof SqlRowId && this.rowId == ((SqlRowId) o).rowId; } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/H2ConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/H2ConnectionFactory.java index 7ca1f417d..ddae98fa8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/H2ConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/H2ConnectionFactory.java @@ -68,7 +68,7 @@ public class H2ConnectionFactory extends FlatfileConnectionFactory { return (Connection) this.connectionConstructor.newInstance("jdbc:h2:" + file.toString(), new Properties()); } catch (ReflectiveOperationException e) { if (e.getCause() instanceof SQLException) { - throw ((SQLException) e.getCause()); + throw (SQLException) e.getCause(); } throw new RuntimeException(e); } diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/SqliteConnectionFactory.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/SqliteConnectionFactory.java index e5caf4d75..85c82036a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/SqliteConnectionFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/connection/file/SqliteConnectionFactory.java @@ -68,7 +68,7 @@ public class SqliteConnectionFactory extends FlatfileConnectionFactory { return (Connection) this.connectionConstructor.newInstance("jdbc:sqlite:" + file.toString(), file.toString(), new Properties()); } catch (ReflectiveOperationException e) { if (e.getCause() instanceof SQLException) { - throw ((SQLException) e.getCause()); + throw (SQLException) e.getCause(); } throw new RuntimeException(e); } diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java b/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java index 406428d58..ba8aeb7c3 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/ImmutableTreeNode.java @@ -118,6 +118,6 @@ public class ImmutableTreeNode implements Comparable { @Override public int compareTo(@NonNull ImmutableTreeNode o) { - return (this.children != null) == o.getChildren().isPresent() ? 0 : (this.children != null ? 1 : -1); + return (this.children != null) == o.getChildren().isPresent() ? 0 : this.children != null ? 1 : -1; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java index 5509ed13b..a015e5920 100644 --- a/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java +++ b/common/src/main/java/me/lucko/luckperms/common/treeview/TreeView.java @@ -139,7 +139,7 @@ public class TreeView { // work out the prefix to apply // since the view is relative, we need to prepend this to all permissions - String prefix = this.rootPosition.equals(".") ? "" : (this.rootPosition + "."); + String prefix = this.rootPosition.equals(".") ? "" : this.rootPosition + "."; JsonObject jsonTree = this.view.toJson(prefix); JObject metadata = new JObject() diff --git a/common/src/main/java/me/lucko/luckperms/common/util/Paginated.java b/common/src/main/java/me/lucko/luckperms/common/util/Paginated.java index 2523b6172..dd4dcf81a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/util/Paginated.java +++ b/common/src/main/java/me/lucko/luckperms/common/util/Paginated.java @@ -56,7 +56,7 @@ public class Paginated { throw new IllegalArgumentException("pageNo cannot be less than 1: " + pageNo); } - int first = ((pageNo - 1) * pageSize); + int first = (pageNo - 1) * pageSize; if (this.content.size() <= first) { throw new IllegalStateException("Content does not contain that many elements. (requested page: " + pageNo + ", page size: " + pageSize + ", page first index: " + first + ", content size: " + this.content.size() + ")"); diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/expression/BooleanExpressionCompiler.java b/common/src/main/java/me/lucko/luckperms/common/verbose/expression/BooleanExpressionCompiler.java index 1e7d242ea..a1604c63b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/verbose/expression/BooleanExpressionCompiler.java +++ b/common/src/main/java/me/lucko/luckperms/common/verbose/expression/BooleanExpressionCompiler.java @@ -256,7 +256,7 @@ public class BooleanExpressionCompiler { case '!': return ConstantToken.NOT; default: - throw new LexerException("Unknown token: " + ((char) token) + "(" + token + ")"); + throw new LexerException("Unknown token: " + (char) token + "(" + token + ")"); } } catch (IOException e) { throw new LexerException(e); diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/event/PlayerChangeWorldCallback.java b/fabric/src/main/java/me/lucko/luckperms/fabric/event/PlayerChangeWorldCallback.java index 555dfb3a4..2d919ea1b 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/event/PlayerChangeWorldCallback.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/event/PlayerChangeWorldCallback.java @@ -32,7 +32,7 @@ import net.minecraft.server.world.ServerWorld; // TODO: Use Fabric API alternative when merged. public interface PlayerChangeWorldCallback { - Event EVENT = EventFactory.createArrayBacked(PlayerChangeWorldCallback.class, (callbacks) -> (originalWorld, destination, player) -> { + Event EVENT = EventFactory.createArrayBacked(PlayerChangeWorldCallback.class, callbacks -> (originalWorld, destination, player) -> { for (PlayerChangeWorldCallback callback : callbacks) { callback.onChangeWorld(originalWorld, destination, player); } diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java b/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java index e47738fe1..aa262396e 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/mixin/ServerPlayerEntityMixin.java @@ -85,7 +85,7 @@ public abstract class ServerPlayerEntityMixin implements MixinUser { @Override public QueryOptionsCache getQueryOptionsCache(FabricContextManager contextManager) { if (this.luckperms$queryOptions == null) { - this.luckperms$queryOptions = contextManager.newQueryOptionsCache(((ServerPlayerEntity) (Object) this)); + this.luckperms$queryOptions = contextManager.newQueryOptionsCache((ServerPlayerEntity) (Object) this); } return this.luckperms$queryOptions; } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/calculator/DefaultsProcessor.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/calculator/DefaultsProcessor.java index 9266f2284..b619f3c1b 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/calculator/DefaultsProcessor.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/calculator/DefaultsProcessor.java @@ -64,7 +64,7 @@ public class DefaultsProcessor implements PermissionProcessor { if (canOverrideWildcard(prev)) { PermissionDefault def = PermissionDefault.fromPermission(this.plugin.getPermissionMap().get(permission)); if (def != null) { - if (def == PermissionDefault.FALSE || (this.isOp && def == PermissionDefault.NOT_OP)) { + if (def == PermissionDefault.FALSE || this.isOp && def == PermissionDefault.NOT_OP) { return PERMISSION_MAP_RESULT_FACTORY.result(Tristate.FALSE, "permission map (overriding wildcard): " + prev.cause()); } } diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissionAttachment.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissionAttachment.java index 6a7d32815..f9da6795f 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissionAttachment.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissionAttachment.java @@ -360,7 +360,7 @@ public class LuckPermsPermissionAttachment extends PermissionAttachment { return null; } - String permission = ((String) key); + String permission = (String) key; // grab the previous result, so we can still satisfy the method signature of Map Boolean previous = LuckPermsPermissionAttachment.this.perms.get(permission); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java index 549133939..895ae6032 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/PermissibleInjector.java @@ -117,7 +117,7 @@ public final class PermissibleInjector { // only uninject if the permissible was a luckperms one. if (permissible instanceof LuckPermsPermissible) { - LuckPermsPermissible lpPermissible = ((LuckPermsPermissible) permissible); + LuckPermsPermissible lpPermissible = (LuckPermsPermissible) permissible; // clear all permissions lpPermissible.clearPermissions(); diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java index 7e05a4af0..a0d7001e9 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/server/LuckPermsPermissionMap.java @@ -133,7 +133,7 @@ public final class LuckPermsPermissionMap extends ForwardingMap e instanceof Player) - .map(e -> ((Player) e)) + .map(e -> (Player) e) .collect(Collectors.toList()); } catch (IllegalArgumentException e) { this.plugin.getLogger().warn("Error parsing selector '" + arg + "' for " + source + " executing " + args, e); diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java index 15534a25f..6aacad42c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/listeners/SpongePlatformListener.java @@ -45,7 +45,7 @@ public class SpongePlatformListener { if (source == null) return; final String name = e.getCommand().toLowerCase(); - if (((name.equals("op") || name.equals("minecraft:op")) && source.hasPermission("minecraft.command.op")) || ((name.equals("deop") || name.equals("minecraft:deop")) && source.hasPermission("minecraft.command.deop"))) { + if ((name.equals("op") || name.equals("minecraft:op")) && source.hasPermission("minecraft.command.op") || (name.equals("deop") || name.equals("minecraft:deop")) && source.hasPermission("minecraft.command.deop")) { Message.OP_DISABLED_SPONGE.send(this.plugin.getSenderFactory().wrap(source)); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java index fbf237088..ca419d4e4 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/inheritance/SubjectInheritanceGraph.java @@ -51,7 +51,7 @@ public class SubjectInheritanceGraph implements Graph { return subject.getCombinedParents(this.queryOptions).stream() .map(ref -> ref.resolveLp().join()) .filter(p -> p instanceof CalculatedSubject) - .map(p -> ((CalculatedSubject) p)) + .map(p -> (CalculatedSubject) p) .collect(Collectors.toList()); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java index 522ad6f12..b510ef1d4 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/permissionholder/PermissionHolderSubjectData.java @@ -371,10 +371,10 @@ public class PermissionHolderSubjectData implements LPSubjectData { } if (t.getType() == HolderType.USER) { - User user = ((User) t); + User user = (User) t; return this.service.getPlugin().getStorage().saveUser(user); } else { - Group group = ((Group) t); + Group group = (Group) t; return this.service.getPlugin().getStorage().saveGroup(group); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/SubjectDataContainer.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/SubjectDataContainer.java index e33a7d5cf..a3efda34e 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/SubjectDataContainer.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/SubjectDataContainer.java @@ -101,7 +101,7 @@ public class SubjectDataContainer { return new JsonArray(); } Preconditions.checkArgument(element instanceof JsonArray); - return ((JsonArray) element); + return (JsonArray) element; } private SubjectDataContainer(LPPermissionService service, JsonObject root) {