diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java index 1f1f6282c..c99389870 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultPermission.java @@ -37,6 +37,7 @@ import me.lucko.luckperms.common.cacheddata.type.PermissionCache; import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -404,13 +405,13 @@ public class LuckPermsVaultPermission extends AbstractVaultPermission { } boolean holderSave(PermissionHolder holder) { - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { User u = (User) holder; // we don't need to join this call - the save operation // can happen in the background. this.plugin.getStorage().saveUser(u); - } else if (holder.getType().isGroup()) { + } else if (holder.getType() == HolderType.GROUP) { Group g = (Group) holder; // invalidate caches - they have potentially been affected by diff --git a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java index 32f8909de..b76150619 100644 --- a/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java +++ b/common/src/main/java/me/lucko/luckperms/common/actionlog/ExtendedLogEntry.java @@ -31,6 +31,7 @@ import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.LogEntry; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -286,11 +287,11 @@ public class ExtendedLogEntry implements LogEntry { } public Builder acted(PermissionHolder acted) { - if (acted.getType().isUser()) { + if (acted.getType() == HolderType.USER) { actedName(((User) acted).getName().orElse("null")); acted(((User) acted).getUuid()); type(Type.USER); - } else if (acted.getType().isGroup()) { + } else if (acted.getType() == HolderType.GROUP) { actedName(((Group) acted).getName()); type(Type.GROUP); } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java index 822f65cd1..488fa857c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPermissionHolder.java @@ -44,6 +44,7 @@ import me.lucko.luckperms.api.caching.CachedData; import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.NodeMapType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -217,7 +218,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol Objects.requireNonNull(group, "group"); Group g = ApiGroup.cast(group); - if (this.handle.getType().isGroup() && g.getName().equals(this.handle.getObjectName())) { + if (this.handle.getType() == HolderType.GROUP && g.getName().equals(this.handle.getObjectName())) { return true; } @@ -230,7 +231,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol Objects.requireNonNull(contextSet, "contextSet"); Group g = ApiGroup.cast(group); - if (this.handle.getType().isGroup() && g.getName().equals(this.handle.getObjectName())) { + if (this.handle.getType() == HolderType.GROUP && g.getName().equals(this.handle.getObjectName())) { return true; } @@ -279,7 +280,7 @@ public class ApiPermissionHolder implements me.lucko.luckperms.api.PermissionHol public void clearMatching(@NonNull Predicate test) { Objects.requireNonNull(test, "test"); this.handle.removeIf(test); - if (this.handle.getType().isUser()) { + if (this.handle.getType() == HolderType.USER) { this.handle.getPlugin().getUserManager().giveDefaultIfNeeded((User) this.handle, false); } } 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 198d00f35..e59530964 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 @@ -31,6 +31,7 @@ import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.common.cacheddata.type.PermissionCache; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -271,7 +272,7 @@ public final class ArgumentPermissions { * @return true if the sender should NOT be allowed to act, true if they should */ public static boolean checkGroup(LuckPermsPlugin plugin, Sender sender, PermissionHolder holder, ContextSet contextSet) { - if (holder.getType().isGroup()) { + if (holder.getType() == HolderType.GROUP) { return checkGroup(plugin, sender, ((Group) holder).getName(), contextSet); } return false; 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 5a5ef9acb..4c41a8626 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 @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.messaging.InternalMessagingService; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -166,10 +167,10 @@ public final class StorageAssistant { } public static void save(PermissionHolder holder, Sender sender, LuckPermsPlugin plugin) { - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { User user = ((User) holder); save(user, sender, plugin); - } else if (holder.getType().isGroup()) { + } else if (holder.getType() == HolderType.GROUP) { Group group = ((Group) holder); save(group, sender, plugin); } else { 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 cef3dec63..4072f6736 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 @@ -38,6 +38,7 @@ import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -166,7 +167,7 @@ public class MetaInfo extends SharedSubCommand { "¥7Click to remove this " + type.name().toLowerCase() + " from " + holder.getFormattedDisplayName() ), '¥')); - String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); return component -> { @@ -190,7 +191,7 @@ public class MetaInfo extends SharedSubCommand { "¥7Click to remove this meta pair from " + holder.getFormattedDisplayName() ), '¥')); - String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); return component -> { 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 8765a6770..4b0e9595c 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 @@ -37,6 +37,7 @@ import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; @@ -71,7 +72,7 @@ public class HolderShowTracks extends SubCommand List> lines = new ArrayList<>(); - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { // if the holder is a user, we want to query parent groups for tracks Set nodes = holder.enduringData().immutable().values().stream() .filter(Node::isGroupNode) 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 94eb25e77..6fec96c3d 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 @@ -40,6 +40,7 @@ import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -95,7 +96,7 @@ public class ParentClearTrack extends SharedSubCommand { holder.removeIf(node -> node.isGroupNode() && node.getFullContexts().equals(context) && track.containsGroup(node.getGroupName())); } - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false); } 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 47f0df745..6b120a4d2 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 @@ -39,6 +39,7 @@ import me.lucko.luckperms.common.command.utils.SortType; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -141,7 +142,7 @@ public class ParentInfo extends SharedSubCommand { "&7Click to remove this parent from " + holder.getFormattedDisplayName() ), CommandManager.AMPERSAND_CHAR)); - String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); return component -> { 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 3046df75e..c217930b9 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 @@ -42,6 +42,7 @@ import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -74,7 +75,7 @@ public class ParentRemove extends SharedSubCommand { return CommandResult.NO_PERMISSION; } - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { User user = (User) holder; boolean shouldPrevent = plugin.getConfiguration().get(ConfigKeys.PREVENT_PRIMARY_GROUP_REMOVAL) && @@ -96,7 +97,7 @@ public class ParentRemove extends SharedSubCommand { .action("parent", "remove", groupName, context) .build().submit(plugin, sender); - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { plugin.getUserManager().giveDefaultIfNeeded(((User) holder), false); } 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 9366a1941..83bffb0f5 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 @@ -41,6 +41,7 @@ import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -80,7 +81,7 @@ public class ParentSet extends SharedSubCommand { holder.clearParents(context, false); holder.setPermission(NodeFactory.buildGroupNode(group.getName()).withExtraContext(context).build()); - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { ((User) holder).getPrimaryGroup().setStoredValue(group.getName()); } 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 b5efbaedf..7a7280cac 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 @@ -39,6 +39,7 @@ import me.lucko.luckperms.common.command.utils.SortType; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.comparator.NodeWithContextComparator; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -143,7 +144,7 @@ public class PermissionInfo extends SharedSubCommand { "¥7Click to remove this node from " + holder.getFormattedDisplayName() ), '¥')); - String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType().isGroup() ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); + String command = "/" + label + " " + NodeFactory.nodeAsCommand(node, holder.getType() == HolderType.GROUP ? holder.getObjectName() : holder.getFormattedDisplayName(), holder.getType(), false, !holder.getPlugin().getConfiguration().getContextsFile().getDefaultContexts().isEmpty()); ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command); return component -> { diff --git a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java index 8585b3bf9..f70da34f8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/event/EventFactory.java @@ -78,6 +78,7 @@ import me.lucko.luckperms.common.event.model.EntitySourceImpl; import me.lucko.luckperms.common.event.model.SenderEntity; import me.lucko.luckperms.common.event.model.UnknownSource; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -267,7 +268,7 @@ public final class EventFactory { } public void handleDataRecalculate(PermissionHolder holder) { - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { User user = (User) holder; post(UserDataRecalculateEvent.class, () -> generate(UserDataRecalculateEvent.class, user.getApiDelegate(), user.getCachedData())); } 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 60ec09f0b..5c189ee0f 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 @@ -26,6 +26,7 @@ package me.lucko.luckperms.common.inheritance; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -39,7 +40,7 @@ public class InheritanceComparator implements Comparator { private static final Comparator NULL_ORIGIN = new InheritanceComparator(null); public static Comparator getFor(PermissionHolder origin) { - if (origin.getType().isUser()) { + if (origin.getType() == HolderType.USER) { return new InheritanceComparator(((User) origin)); } return NULL_ORIGIN; diff --git a/common/src/main/java/me/lucko/luckperms/common/model/HolderType.java b/common/src/main/java/me/lucko/luckperms/common/model/HolderType.java index 4678986a5..21bf3f1d7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/HolderType.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/HolderType.java @@ -26,32 +26,11 @@ package me.lucko.luckperms.common.model; public enum HolderType { - - USER(true, false), - GROUP(false, true); - - private final boolean user; - private final boolean group; - - HolderType(boolean user, boolean group) { - this.user = user; - this.group = group; - } - - public boolean matches(PermissionHolder holder) { - return holder.getType() == this; - } + USER, + GROUP; @Override public String toString() { return name().toLowerCase(); } - - public boolean isUser() { - return this.user; - } - - public boolean isGroup() { - return this.group; - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java index d744924f6..79e62cccf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/PermissionHolder.java @@ -506,7 +506,7 @@ public abstract class PermissionHolder { * @return a tristate, returns undefined if no match */ public Tristate hasPermission(NodeMapType type, Node node, NodeEqualityPredicate equalityPredicate) { - if (this.getType().isGroup() && node.isGroupNode() && node.getGroupName().equalsIgnoreCase(getObjectName())) { + if (this.getType() == HolderType.GROUP && node.isGroupNode() && node.getGroupName().equalsIgnoreCase(getObjectName())) { return Tristate.TRUE; } @@ -713,7 +713,7 @@ public abstract class PermissionHolder { public boolean clearParents(boolean giveDefault) { return removeIf(Node::isGroupNode, () -> { - if (this.getType().isUser() && giveDefault) { + if (this.getType() == HolderType.USER && giveDefault) { this.plugin.getUserManager().giveDefaultIfNeeded((User) this, false); } }); @@ -721,7 +721,7 @@ public abstract class PermissionHolder { public boolean clearParents(ContextSet contextSet, boolean giveDefault) { return removeIf(contextSet, Node::isGroupNode, () -> { - if (this.getType().isUser() && giveDefault) { + if (this.getType() == HolderType.USER && giveDefault) { this.plugin.getUserManager().giveDefaultIfNeeded((User) this, false); } }); diff --git a/common/src/main/java/me/lucko/luckperms/common/model/manager/user/AbstractUserManager.java b/common/src/main/java/me/lucko/luckperms/common/model/manager/user/AbstractUserManager.java index 1b21e71ee..a0b2adcef 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/manager/user/AbstractUserManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/manager/user/AbstractUserManager.java @@ -26,6 +26,7 @@ package me.lucko.luckperms.common.model.manager.user; import com.google.common.collect.ImmutableCollection; +import com.google.common.collect.Streams; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; @@ -42,6 +43,7 @@ import java.util.Optional; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; public abstract class AbstractUserManager extends AbstractManager implements UserManager { @@ -152,7 +154,12 @@ public abstract class AbstractUserManager extends AbstractManage @Override public CompletableFuture updateAllUsers() { return CompletableFuture.runAsync( - () -> this.plugin.getBootstrap().getOnlinePlayers().forEach(u -> this.plugin.getStorage().loadUser(u, null).join()), + () -> { + Stream.concat( + getAll().keySet().stream().map(UserIdentifier::getUuid), + this.plugin.getBootstrap().getOnlinePlayers() + ).forEach(u -> this.plugin.getStorage().loadUser(u, null).join()); + }, this.plugin.getBootstrap().getScheduler().async() ); } diff --git a/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java b/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java index 079302ab0..70a88fb16 100644 --- a/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java +++ b/common/src/main/java/me/lucko/luckperms/common/tasks/SyncTask.java @@ -72,7 +72,6 @@ public class SyncTask implements Runnable { this.plugin.getStorage().loadAllTracks().join(); // Refresh all online users. - this.plugin.getUserManager().invalidateAllUserCaches(); CompletableFuture userUpdateFut = this.plugin.getUserManager().updateAllUsers(); if (!this.initialUpdate) { userUpdateFut.join(); diff --git a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java index 2f34b4b1b..332417d5f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/web/WebEditor.java @@ -34,6 +34,7 @@ import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.common.context.ContextSetJsonSerializer; import me.lucko.luckperms.common.locale.message.Message; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.model.NodeDataContainer; @@ -74,7 +75,7 @@ public final class WebEditor { .add("id", getHolderIdentifier(holder)) .add("friendly", holder.getPlainDisplayName()) .consume(obj -> { - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { obj.add("uuid", ((User) holder).getUuid().toString()); } })) @@ -111,7 +112,7 @@ public final class WebEditor { } private static String getHolderIdentifier(PermissionHolder holder) { - if (holder.getType().isUser()) { + if (holder.getType() == HolderType.USER) { User user = ((User) holder); return USER_ID_PATTERN + user.getUuid().toString(); } else { diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/calculator/SpongeCalculatorFactory.java b/sponge/src/main/java/me/lucko/luckperms/sponge/calculator/SpongeCalculatorFactory.java index a0f5934f0..c82a2fef9 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/calculator/SpongeCalculatorFactory.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/calculator/SpongeCalculatorFactory.java @@ -36,6 +36,7 @@ import me.lucko.luckperms.common.calculator.processor.PermissionProcessor; import me.lucko.luckperms.common.calculator.processor.RegexProcessor; import me.lucko.luckperms.common.calculator.processor.WildcardProcessor; import me.lucko.luckperms.common.config.ConfigKeys; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.sponge.LPSpongePlugin; public class SpongeCalculatorFactory implements CalculatorFactory { @@ -64,9 +65,9 @@ public class SpongeCalculatorFactory implements CalculatorFactory { } if (this.plugin.getConfiguration().get(ConfigKeys.APPLY_SPONGE_DEFAULT_SUBJECTS)) { - if (metadata.getHolderType().isUser()) { + if (metadata.getHolderType() == HolderType.USER) { processors.add(new UserDefaultsProcessor(this.plugin.getService(), contexts.getContexts().makeImmutable())); - } else if (metadata.getHolderType().isGroup()) { + } else if (metadata.getHolderType() == HolderType.GROUP) { processors.add(new GroupDefaultsProcessor(this.plugin.getService(), contexts.getContexts().makeImmutable())); } } 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 d5e49e9a6..81a7d9288 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 @@ -36,6 +36,7 @@ import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.api.context.ImmutableContextSet; import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator; import me.lucko.luckperms.common.model.Group; +import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.NodeMapType; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.User; @@ -157,7 +158,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { return CompletableFuture.completedFuture(false); } - if (this.holder.getType().isUser()) { + if (this.holder.getType() == HolderType.USER) { this.service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) this.holder), false); } @@ -183,7 +184,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { return CompletableFuture.completedFuture(false); } - if (this.holder.getType().isUser()) { + if (this.holder.getType() == HolderType.USER) { this.service.getPlugin().getUserManager().giveDefaultIfNeeded(((User) this.holder), false); } @@ -471,7 +472,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { private CompletableFuture save(PermissionHolder t) { // if the holder is a group, invalidate caches. - if (t.getType().isGroup()) { + if (t.getType() == HolderType.GROUP) { this.service.getPlugin().getGroupManager().invalidateAllGroupCaches(); this.service.getPlugin().getUserManager().invalidateAllUserCaches(); return CompletableFuture.completedFuture(null); @@ -482,7 +483,7 @@ public class PermissionHolderSubjectData implements LPSubjectData { return CompletableFuture.completedFuture(null); } - if (t.getType().isUser()) { + if (t.getType() == HolderType.USER) { User user = ((User) t); return this.service.getPlugin().getStorage().saveUser(user); } else {