From c9d4c7dac7ec868d4c4efdf41970bc2f883a2921 Mon Sep 17 00:00:00 2001 From: Luck Date: Wed, 17 Nov 2021 23:18:11 +0000 Subject: [PATCH] ContextSet performance improvements (#3209) A bit experimental, should be stable enough though. --- .../api/context/ImmutableContextSet.java | 2 +- .../api/context/MutableContextSet.java | 2 +- .../bukkit/context/BukkitContextManager.java | 4 +- .../context/BukkitPlayerCalculator.java | 2 +- .../permissible/LuckPermsPermissible.java | 2 +- .../bukkit/vault/LuckPermsVaultChat.java | 2 +- .../bungee/context/BungeeContextManager.java | 4 +- .../context/BungeePlayerCalculator.java | 2 +- .../bungee/context/RedisBungeeCalculator.java | 2 +- .../api/implementation/ApiContextManager.java | 2 +- .../implementation/ApiContextSetFactory.java | 4 +- .../api/implementation/ApiPlayerAdapter.java | 2 +- .../common/command/utils/ArgumentList.java | 4 +- .../commands/generic/other/HolderEditor.java | 2 +- .../parent/UserSwitchPrimaryGroup.java | 2 +- .../common/commands/log/LogNotify.java | 2 +- .../common/commands/misc/EditorCommand.java | 2 +- .../common/commands/track/TrackEditor.java | 2 +- .../luckperms/common/config/ConfigKeys.java | 2 +- .../luckperms/common/config/ContextsFile.java | 4 +- .../{contextset => }/AbstractContextSet.java | 58 +---- .../context/{contextset => }/ContextImpl.java | 11 +- .../ImmutableContextSetImpl.java | 208 +++++++++++------- .../MutableContextSetImpl.java | 94 ++++---- .../ConfigurationContextCalculator.java | 4 +- .../ForwardingContextCalculator.java | 2 +- .../{ => calculator}/WorldNameRewriter.java | 2 +- .../context/comparator/ContextComparator.java | 75 +++++++ .../ContextSetComparator.java | 27 +-- .../context/{ => manager}/ContextManager.java | 5 +- .../{ => manager}/QueryOptionsCache.java | 2 +- .../{ => manager}/QueryOptionsSupplier.java | 2 +- .../ContextSetConfigurateSerializer.java | 6 +- .../ContextSetJsonSerializer.java | 6 +- .../manager/user/AbstractUserManager.java | 2 +- .../common/model/nodemap/NodeMapMutable.java | 2 +- .../common/node/AbstractNodeBuilder.java | 2 +- .../comparator/NodeWithContextComparator.java | 2 +- .../common/node/utils/NodeJsonSerializer.java | 2 +- .../plugin/AbstractLuckPermsPlugin.java | 2 +- .../common/plugin/LuckPermsPlugin.java | 2 +- .../common/query/QueryOptionsBuilderImpl.java | 2 +- .../common/query/QueryOptionsImpl.java | 2 +- .../lucko/luckperms/common/sender/Sender.java | 2 +- .../file/AbstractConfigurateStorage.java | 4 +- .../implementation/mongodb/MongoStorage.java | 2 +- .../implementation/sql/SqlStorage.java | 2 +- .../common/webeditor/WebEditorRequest.java | 4 +- .../common/webeditor/WebEditorResponse.java | 2 +- .../common/context/ContextSetTest.java | 158 +++++++++++++ .../fabric/context/FabricContextManager.java | 4 +- .../context/FabricPlayerCalculator.java | 2 +- .../fabric/mixin/ServerPlayerEntityMixin.java | 2 +- .../luckperms/fabric/model/MixinUser.java | 2 +- .../nukkit/context/NukkitContextManager.java | 4 +- .../context/NukkitPlayerCalculator.java | 2 +- .../permissible/LuckPermsPermissible.java | 2 +- .../proxy/api6/DescriptionBuilder.java | 2 +- .../service/proxy/api6/SubjectProxy.java | 2 +- .../proxy/api7/DescriptionBuilder.java | 2 +- .../service/proxy/api7/SubjectProxy.java | 2 +- .../sponge/service/CompatibilityUtil.java | 4 +- .../service/model/LPPermissionService.java | 2 +- .../sponge/context/SpongeContextManager.java | 6 +- .../context/SpongePlayerCalculator.java | 2 +- .../model/manager/SpongeGroupManager.java | 2 +- .../model/manager/SpongeUserManager.java | 2 +- .../sponge/service/LuckPermsService.java | 2 +- .../service/model/ContextCalculatorProxy.java | 2 +- .../calculated/CalculatedSubjectData.java | 2 +- .../model/persisted/PersistedCollection.java | 2 +- .../model/persisted/SubjectDataContainer.java | 4 +- .../context/VelocityContextManager.java | 6 +- .../context/VelocityPlayerCalculator.java | 2 +- .../service/PlayerPermissionProvider.java | 2 +- 75 files changed, 523 insertions(+), 287 deletions(-) rename common/src/main/java/me/lucko/luckperms/common/context/{contextset => }/AbstractContextSet.java (68%) rename common/src/main/java/me/lucko/luckperms/common/context/{contextset => }/ContextImpl.java (86%) rename common/src/main/java/me/lucko/luckperms/common/context/{contextset => }/ImmutableContextSetImpl.java (52%) rename common/src/main/java/me/lucko/luckperms/common/context/{contextset => }/MutableContextSetImpl.java (81%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => calculator}/ConfigurationContextCalculator.java (95%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => calculator}/ForwardingContextCalculator.java (96%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => calculator}/WorldNameRewriter.java (98%) create mode 100644 common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextComparator.java rename common/src/main/java/me/lucko/luckperms/common/context/{ => comparator}/ContextSetComparator.java (83%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => manager}/ContextManager.java (97%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => manager}/QueryOptionsCache.java (97%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => manager}/QueryOptionsSupplier.java (96%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => serializer}/ContextSetConfigurateSerializer.java (94%) rename common/src/main/java/me/lucko/luckperms/common/context/{ => serializer}/ContextSetJsonSerializer.java (95%) create mode 100644 common/src/test/java/me/lucko/luckperms/common/context/ContextSetTest.java diff --git a/api/src/main/java/net/luckperms/api/context/ImmutableContextSet.java b/api/src/main/java/net/luckperms/api/context/ImmutableContextSet.java index b2312fa52..ef2947ff2 100644 --- a/api/src/main/java/net/luckperms/api/context/ImmutableContextSet.java +++ b/api/src/main/java/net/luckperms/api/context/ImmutableContextSet.java @@ -119,7 +119,7 @@ public interface ImmutableContextSet extends ContextSet { } /** - * Adds of of the contexts in another {@link ContextSet} to the set. + * Adds all the contexts in another {@link ContextSet} to the set. * * @param contextSet the set to add from * @return the builder diff --git a/api/src/main/java/net/luckperms/api/context/MutableContextSet.java b/api/src/main/java/net/luckperms/api/context/MutableContextSet.java index 83bc91384..dca79d999 100644 --- a/api/src/main/java/net/luckperms/api/context/MutableContextSet.java +++ b/api/src/main/java/net/luckperms/api/context/MutableContextSet.java @@ -94,7 +94,7 @@ public interface MutableContextSet extends ContextSet { } /** - * Adds of of the contexts in another {@link ContextSet} to this set. + * Adds all the contexts in another {@link ContextSet} to this set. * * @param contextSet the set to add from * @throws NullPointerException if the contextSet is null diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitContextManager.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitContextManager.java index 738b3cfef..2065f2585 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitContextManager.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitContextManager.java @@ -30,8 +30,8 @@ import com.github.benmanes.caffeine.cache.LoadingCache; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.cache.LoadingMap; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.util.CaffeineFactory; import net.luckperms.api.context.ImmutableContextSet; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitPlayerCalculator.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitPlayerCalculator.java index 15ab0693e..0b3dcb224 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitPlayerCalculator.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/context/BukkitPlayerCalculator.java @@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.util.EnumNamer; import net.luckperms.api.context.Context; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissible.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissible.java index 8958aad92..164b8d658 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissible.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/permissible/LuckPermsPermissible.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.bukkit.calculator.DefaultsProcessor; import me.lucko.luckperms.bukkit.calculator.OpProcessor; import me.lucko.luckperms.common.calculator.result.TristateResult; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java index 470ae6122..c77d3016c 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/vault/LuckPermsVaultChat.java @@ -30,7 +30,7 @@ import com.google.common.base.Strings; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator; import me.lucko.luckperms.common.cacheddata.type.MetaCache; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.types.Meta; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeeContextManager.java b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeeContextManager.java index 3050dbdc0..73bf1112d 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeeContextManager.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeeContextManager.java @@ -28,8 +28,8 @@ package me.lucko.luckperms.bungee.context; import com.github.benmanes.caffeine.cache.LoadingCache; import me.lucko.luckperms.bungee.LPBungeePlugin; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.common.util.CaffeineFactory; import net.luckperms.api.context.ImmutableContextSet; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeePlayerCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeePlayerCalculator.java index 278a911b2..902527a3a 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeePlayerCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/context/BungeePlayerCalculator.java @@ -27,7 +27,7 @@ package me.lucko.luckperms.bungee.context; import me.lucko.luckperms.bungee.LPBungeePlugin; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextCalculator; import net.luckperms.api.context.ContextConsumer; diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java b/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java index 682d6dd78..0a610bec1 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/context/RedisBungeeCalculator.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.bungee.context; import com.imaginarycode.minecraft.redisbungee.RedisBungee; import com.imaginarycode.minecraft.redisbungee.RedisBungeeAPI; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextConsumer; import net.luckperms.api.context.ContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextManager.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextManager.java index 58d7bf3d0..7d6031e05 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextManager.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.api.implementation; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.query.QueryOptionsBuilderImpl; diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java index 55c78a7c2..becd8bc8e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiContextSetFactory.java @@ -25,8 +25,8 @@ package me.lucko.luckperms.common.api.implementation; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.MutableContextSetImpl; import net.luckperms.api.context.ContextSetFactory; import net.luckperms.api.context.ImmutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlayerAdapter.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlayerAdapter.java index f9d4a62ab..9c9d5d80d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlayerAdapter.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlayerAdapter.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.api.implementation; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.model.manager.user.UserManager; import net.luckperms.api.context.ImmutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentList.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentList.java index 09216ee66..14b663a5b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentList.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentList.java @@ -29,8 +29,8 @@ import com.google.common.collect.ForwardingList; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.commands.user.UserParentCommand; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.MutableContextSetImpl; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.DurationParser; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java index bca8c8f44..0dfaa0da2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/generic/other/HolderEditor.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; 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 41b2c6efb..f798948b8 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 @@ -35,7 +35,7 @@ import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; import me.lucko.luckperms.common.command.utils.ArgumentList; import me.lucko.luckperms.common.command.utils.StorageAssistant; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java index abffbd33e..332d9f659 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/log/LogNotify.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.common.command.abstraction.ChildCommand; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.node.types.Permission; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java index 459003b41..d96eba560 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.Track; diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackEditor.java b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackEditor.java index 77404b6d7..50af93903 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackEditor.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/track/TrackEditor.java @@ -30,7 +30,7 @@ import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentList; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index 14c97cab3..7bd64e662 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.cacheddata.type.SimpleMetaValueSelector; import me.lucko.luckperms.common.config.generic.KeyedConfiguration; import me.lucko.luckperms.common.config.generic.key.ConfigKey; import me.lucko.luckperms.common.config.generic.key.SimpleConfigKey; -import me.lucko.luckperms.common.context.WorldNameRewriter; +import me.lucko.luckperms.common.context.calculator.WorldNameRewriter; import me.lucko.luckperms.common.graph.TraversalAlgorithm; import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition; import me.lucko.luckperms.common.metastacking.StandardStackElements; diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ContextsFile.java b/common/src/main/java/me/lucko/luckperms/common/config/ContextsFile.java index 851ca18e0..be59d1946 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ContextsFile.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ContextsFile.java @@ -28,8 +28,8 @@ package me.lucko.luckperms.common.config; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.context.ContextSetJsonSerializer; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer; import me.lucko.luckperms.common.util.gson.GsonProvider; import net.luckperms.api.context.ImmutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/AbstractContextSet.java b/common/src/main/java/me/lucko/luckperms/common/context/AbstractContextSet.java similarity index 68% rename from common/src/main/java/me/lucko/luckperms/common/context/contextset/AbstractContextSet.java rename to common/src/main/java/me/lucko/luckperms/common/context/AbstractContextSet.java index b61c52e53..0acc898c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/AbstractContextSet.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/AbstractContextSet.java @@ -23,11 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context.contextset; - -import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Iterators; -import com.google.common.collect.SetMultimap; +package me.lucko.luckperms.common.context; import net.luckperms.api.context.Context; import net.luckperms.api.context.ContextSatisfyMode; @@ -36,36 +32,11 @@ import net.luckperms.api.context.DefaultContextKeys; import org.checkerframework.checker.nullness.qual.NonNull; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; import java.util.Locale; import java.util.Objects; -import java.util.Set; -import java.util.Spliterator; public abstract class AbstractContextSet implements ContextSet { - protected abstract SetMultimap backing(); - - protected abstract void copyTo(SetMultimap other); - - @Override - public boolean containsKey(@NonNull String key) { - return backing().containsKey(sanitizeKey(key)); - } - - @Override - public @NonNull Set getValues(@NonNull String key) { - Collection values = backing().asMap().get(sanitizeKey(key)); - return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of(); - } - - @Override - public boolean contains(@NonNull String key, @NonNull String value) { - return backing().containsEntry(sanitizeKey(key), sanitizeValue(value)); - } - @Override public boolean isSatisfiedBy(@NonNull ContextSet other, @NonNull ContextSatisfyMode mode) { if (this == other) { @@ -96,33 +67,6 @@ public abstract class AbstractContextSet implements ContextSet { protected abstract boolean otherContainsAll(ContextSet other, ContextSatisfyMode mode); - public abstract Context[] toArray(); - - @Override - public @NonNull Iterator iterator() { - return Iterators.forArray(toArray()); - } - - @Override - public Spliterator spliterator() { - return Arrays.spliterator(toArray()); - } - - @Override - public boolean isEmpty() { - return backing().isEmpty(); - } - - @Override - public int size() { - return backing().size(); - } - - @Override - public int hashCode() { - return backing().hashCode(); - } - static String sanitizeKey(String key) { Objects.requireNonNull(key, "key is null"); if (!Context.isValidKey(key)) { diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextImpl.java similarity index 86% rename from common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java rename to common/src/main/java/me/lucko/luckperms/common/context/ContextImpl.java index 4e7c5a13d..0d9b10752 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ContextImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextImpl.java @@ -23,13 +23,15 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context.contextset; +package me.lucko.luckperms.common.context; + +import me.lucko.luckperms.common.context.comparator.ContextComparator; import net.luckperms.api.context.Context; import org.checkerframework.checker.nullness.qual.NonNull; -public final class ContextImpl implements Context { +public final class ContextImpl implements Context, Comparable { private final String key; private final String value; @@ -48,6 +50,11 @@ public final class ContextImpl implements Context { return this.value; } + @Override + public int compareTo(@NonNull Context o) { + return ContextComparator.INSTANCE.compare(this, o); + } + @Override public boolean equals(Object obj) { if (!(obj instanceof Context)) return false; 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/ImmutableContextSetImpl.java similarity index 52% rename from common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java rename to common/src/main/java/me/lucko/luckperms/common/context/ImmutableContextSetImpl.java index 862d30ec6..e4b77685d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/ImmutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ImmutableContextSetImpl.java @@ -23,16 +23,15 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context.contextset; +package me.lucko.luckperms.common.context; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; +import com.google.common.collect.Iterators; import com.google.common.collect.Multimaps; -import com.google.common.collect.SetMultimap; -import me.lucko.luckperms.common.context.ContextSetComparator; +import me.lucko.luckperms.common.context.comparator.ContextComparator; import net.luckperms.api.context.Context; import net.luckperms.api.context.ContextSatisfyMode; @@ -44,12 +43,14 @@ import org.checkerframework.checker.nullness.qual.NonNull; import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.Spliterator; -public final class ImmutableContextSetImpl extends AbstractContextSet implements ImmutableContextSet { - public static final ImmutableContextSetImpl EMPTY = new ImmutableContextSetImpl(ImmutableSetMultimap.of()); +public final class ImmutableContextSetImpl extends AbstractContextSet implements ImmutableContextSet, ContextSet { + public static final ImmutableContextSetImpl EMPTY = new ImmutableContextSetImpl(new Context[0]); public static ImmutableContextSet of(String key, String value) { key = sanitizeKey(key); @@ -60,35 +61,19 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements return EMPTY; } - return new ImmutableContextSetImpl(ImmutableSetMultimap.of(key, sanitizeValue(value))); + return new ImmutableContextSetImpl(new Context[]{new ContextImpl(key, value)}); } - private final ImmutableSetMultimap map; private final Context[] array; + private final int size; private final int hashCode; - ImmutableContextSetImpl(ImmutableSetMultimap contexts) { - this.map = contexts; - this.hashCode = this.map.hashCode(); + private ImmutableSetMultimap cachedMap; - Set> entries = this.map.entries(); - this.array = new Context[entries.size()]; - int i = 0; - for (Map.Entry e : entries) { - this.array[i++] = new ContextImpl(e.getKey(), e.getValue()); - } - // sort the array at construction so the comparator doesn't need to - Arrays.sort(this.array, ContextSetComparator.CONTEXT_COMPARATOR); - } - - @Override - protected SetMultimap backing() { - return this.map; - } - - @Override - protected void copyTo(SetMultimap other) { - other.putAll(this.map); + ImmutableContextSetImpl(Context[] contexts) { + this.array = contexts; // always sorted + this.size = this.array.length; + this.hashCode = Arrays.hashCode(this.array); } @Override @@ -102,9 +87,20 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements return this; } + public ImmutableSetMultimap toMultimap() { + if (this.cachedMap == null) { + ImmutableSetMultimap.Builder builder = ImmutableSetMultimap.builder(); + for (Context entry : this.array) { + builder.put(entry.getKey(), entry.getValue()); + } + this.cachedMap = builder.build(); + } + return this.cachedMap; + } + @Override public @NonNull MutableContextSet mutableCopy() { - return new MutableContextSetImpl(this.map); + return new MutableContextSetImpl(toMultimap()); } @Override @@ -114,22 +110,21 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements @Override public @NonNull Map> toMap() { - return Multimaps.asMap(this.map); + return Multimaps.asMap(toMultimap()); } @Deprecated @Override public @NonNull Map toFlattenedMap() { ImmutableMap.Builder m = ImmutableMap.builder(); - for (Map.Entry e : this.map.entries()) { + for (Context e : this.array) { m.put(e.getKey(), e.getValue()); } return m.build(); } - @Override public Context[] toArray() { - return this.array; + return this.array; // only used read-only & internally } @Override @@ -137,8 +132,7 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements switch (mode) { // Use other.contains case ALL_VALUES_PER_KEY: { - Set> entries = this.map.entries(); - for (Map.Entry e : entries) { + for (Context e : this.array) { if (!other.contains(e.getKey(), e.getValue())) { return false; } @@ -148,12 +142,26 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements // Use other.containsAny case AT_LEAST_ONE_VALUE_PER_KEY: { - Set>> entries = this.map.asMap().entrySet(); - for (Map.Entry> e : entries) { - if (!other.containsAny(e.getKey(), e.getValue())) { - return false; + // exploit the ordered nature to only scan through the array once. + Context[] array = this.array; + for (int i = 0, len = array.length; i < len; i++) { + Context e = array[i]; + + boolean otherContains = other.contains(e.getKey(), e.getValue()); + if (otherContains) { + // skip forward past any other entries with the same key + while (i+1 < len && array[i+1].getKey().equals(e.getKey())) { + i++; + } + } else { + // if this is the last one of the key, return false + int next = i + 1; + if (next >= len || !array[next].getKey().equals(e.getKey())) { + return false; + } } } + return true; } default: @@ -171,21 +179,10 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements if (that instanceof ImmutableContextSetImpl) { ImmutableContextSetImpl immutableThat = (ImmutableContextSetImpl) that; if (this.hashCode != immutableThat.hashCode) return false; + return Arrays.equals(this.array, immutableThat.array); } - final Multimap thatBacking; - if (that instanceof AbstractContextSet) { - thatBacking = ((AbstractContextSet) that).backing(); - } else { - Map> thatMap = that.toMap(); - ImmutableSetMultimap.Builder thatBuilder = ImmutableSetMultimap.builder(); - for (Map.Entry> e : thatMap.entrySet()) { - thatBuilder.putAll(e.getKey(), e.getValue()); - } - thatBacking = thatBuilder.build(); - } - - return backing().equals(thatBacking); + return this.size() == that.size() && otherContainsAll(that, ContextSatisfyMode.ALL_VALUES_PER_KEY); } @Override @@ -195,57 +192,116 @@ public final class ImmutableContextSetImpl extends AbstractContextSet implements @Override public String toString() { - return "ImmutableContextSet(contexts=" + this.map + ")"; + return "ImmutableContextSet(" + Arrays.toString(this.array) + ")"; + } + + @Override + public boolean containsKey(@NonNull String key) { + Objects.requireNonNull(key, "key"); + return Arrays.binarySearch(this.array, new ContextImpl(key, null), ContextComparator.ONLY_KEY) >= 0; + } + + @Override + public @NonNull Set getValues(@NonNull String key) { + Collection values = toMap().get(sanitizeKey(key)); + return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of(); + } + + @Override + public boolean contains(@NonNull Context entry) { + Objects.requireNonNull(entry, "entry"); + return Arrays.binarySearch(this.array, entry) >= 0; + } + + @Override + public boolean contains(@NonNull String key, @NonNull String value) { + Objects.requireNonNull(key, "key"); + Objects.requireNonNull(value, "value"); + return contains(new ContextImpl(key, value)); + } + + @Override + public @NonNull Iterator iterator() { + return Iterators.forArray(this.array); + } + + @Override + public Spliterator spliterator() { + return Arrays.spliterator(this.array); + } + + @Override + public boolean isEmpty() { + return this.size == 0; + } + + @Override + public int size() { + return this.size; } public static final class BuilderImpl implements ImmutableContextSet.Builder { - private ImmutableSetMultimap.Builder builder; + private static final int INITIAL_SIZE = 16; + private Context[] builder = EMPTY.array; + private int size = 0; public BuilderImpl() { } - private synchronized ImmutableSetMultimap.Builder builder() { - if (this.builder == null) { - this.builder = ImmutableSetMultimap.builder(); - } - return this.builder; - } - private void put(String key, String value) { - // special case for server=global and world=global - if (isGlobalServerWorldEntry(key, value)) { + ContextImpl context = new ContextImpl(key, value); + + int pos = Arrays.binarySearch(this.builder, 0, this.size, context); + if (pos >= 0) { return; } - builder().put(key, value); + + int insertPos = -pos - 1; + + Context[] dest; + if (this.builder.length == this.size) { + // grow + dest = new Context[Math.max(this.builder.length * 2, INITIAL_SIZE)]; + System.arraycopy(this.builder, 0, dest, 0, insertPos); + } else { + dest = this.builder; + } + + System.arraycopy(this.builder, insertPos, dest, insertPos + 1, this.size - insertPos); // shift + dest[insertPos] = context; // insert + + this.size++; + this.builder = dest; } @Override public @NonNull BuilderImpl add(@NonNull String key, @NonNull String value) { - put(sanitizeKey(key), sanitizeValue(value)); + key = sanitizeKey(key); + value = sanitizeValue(value); + + // special case for server=global and world=global + if (isGlobalServerWorldEntry(key, value)) { + return this; + } + + put(key, value); return this; } @Override public @NonNull BuilderImpl addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); - if (contextSet instanceof AbstractContextSet) { - AbstractContextSet other = (AbstractContextSet) contextSet; - if (!other.isEmpty()) { - builder().putAll(other.backing()); - } - } else { - addAll(contextSet.toSet()); - } + addAll(contextSet.toSet()); return this; } @Override public @NonNull ImmutableContextSet build() { - if (this.builder == null) { + if (this.builder.length == 0) { return EMPTY; } else { - return new ImmutableContextSetImpl(this.builder.build()); + return new ImmutableContextSetImpl(Arrays.copyOf(this.builder, this.size)); } } } 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/MutableContextSetImpl.java similarity index 81% rename from common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java rename to common/src/main/java/me/lucko/luckperms/common/context/MutableContextSetImpl.java index 76a2c86cb..1bb2ffcd2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/MutableContextSetImpl.java @@ -23,13 +23,12 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context.contextset; +package me.lucko.luckperms.common.context; import com.google.common.collect.HashMultimap; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.ImmutableSetMultimap; -import com.google.common.collect.Multimap; +import com.google.common.collect.Iterators; import com.google.common.collect.Multimaps; import com.google.common.collect.SetMultimap; @@ -41,12 +40,15 @@ import net.luckperms.api.context.MutableContextSet; import org.checkerframework.checker.nullness.qual.NonNull; +import java.util.Arrays; import java.util.Collection; +import java.util.Iterator; import java.util.Map; import java.util.Objects; import java.util.Set; +import java.util.Spliterator; -public final class MutableContextSetImpl extends AbstractContextSet implements MutableContextSet { +public final class MutableContextSetImpl extends AbstractContextSet implements MutableContextSet, ContextSet { private final SetMultimap map; public MutableContextSetImpl() { @@ -57,18 +59,6 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M this.map = Multimaps.synchronizedSetMultimap(HashMultimap.create(other)); } - @Override - protected SetMultimap backing() { - return this.map; - } - - @Override - protected void copyTo(SetMultimap other) { - synchronized (this.map) { - other.putAll(this.map); - } - } - @Override public boolean isImmutable() { return false; @@ -80,9 +70,10 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M if (this.map.isEmpty()) { return ImmutableContextSetImpl.EMPTY; } - synchronized (this.map) { - return new ImmutableContextSetImpl(ImmutableSetMultimap.copyOf(this.map)); - } + + Context[] arr = toArray(); + Arrays.sort(arr); + return new ImmutableContextSetImpl(arr); } @Override @@ -129,11 +120,10 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M return builder.build(); } - @Override public Context[] toArray() { - Set> entries = this.map.entries(); Context[] array; synchronized (this.map) { + Set> entries = this.map.entries(); array = new Context[entries.size()]; int i = 0; for (Map.Entry e : entries) { @@ -143,6 +133,42 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M return array; } + @Override + public boolean containsKey(@NonNull String key) { + return this.map.containsKey(sanitizeKey(key)); + } + + @Override + public @NonNull Set getValues(@NonNull String key) { + Collection values = this.map.asMap().get(sanitizeKey(key)); + return values != null ? ImmutableSet.copyOf(values) : ImmutableSet.of(); + } + + @Override + public boolean contains(@NonNull String key, @NonNull String value) { + return this.map.containsEntry(sanitizeKey(key), sanitizeValue(value)); + } + + @Override + public @NonNull Iterator iterator() { + return Iterators.forArray(toArray()); + } + + @Override + public Spliterator spliterator() { + return Arrays.spliterator(toArray()); + } + + @Override + public boolean isEmpty() { + return this.map.isEmpty(); + } + + @Override + public int size() { + return this.map.size(); + } + @Override public void add(@NonNull String key, @NonNull String value) { key = sanitizeKey(key); @@ -159,12 +185,7 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M @Override public void addAll(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); - if (contextSet instanceof AbstractContextSet) { - AbstractContextSet other = (AbstractContextSet) contextSet; - other.copyTo(this.map); - } else { - addAll(contextSet.toSet()); - } + addAll(contextSet.toSet()); } @Override @@ -221,23 +242,16 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M if (!(o instanceof ContextSet)) return false; final ContextSet that = (ContextSet) o; - final Multimap thatBacking; - if (that instanceof AbstractContextSet) { - thatBacking = ((AbstractContextSet) that).backing(); - } else { - Map> thatMap = that.toMap(); - ImmutableSetMultimap.Builder thatBuilder = ImmutableSetMultimap.builder(); - for (Map.Entry> e : thatMap.entrySet()) { - thatBuilder.putAll(e.getKey(), e.getValue()); - } - thatBacking = thatBuilder.build(); - } + return this.size() == that.size() && otherContainsAll(that, ContextSatisfyMode.ALL_VALUES_PER_KEY); + } - return backing().equals(thatBacking); + @Override + public int hashCode() { + return this.map.hashCode(); } @Override public String toString() { - return "MutableContextSet(contexts=" + this.map + ")"; + return "MutableContextSet(" + this.map + ")"; } } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ConfigurationContextCalculator.java b/common/src/main/java/me/lucko/luckperms/common/context/calculator/ConfigurationContextCalculator.java similarity index 95% rename from common/src/main/java/me/lucko/luckperms/common/context/ConfigurationContextCalculator.java rename to common/src/main/java/me/lucko/luckperms/common/context/calculator/ConfigurationContextCalculator.java index d499ce499..065896df4 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ConfigurationContextCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/calculator/ConfigurationContextCalculator.java @@ -23,11 +23,11 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.calculator; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.LuckPermsConfiguration; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextConsumer; import net.luckperms.api.context.ContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ForwardingContextCalculator.java b/common/src/main/java/me/lucko/luckperms/common/context/calculator/ForwardingContextCalculator.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/context/ForwardingContextCalculator.java rename to common/src/main/java/me/lucko/luckperms/common/context/calculator/ForwardingContextCalculator.java index 0b3a99c0a..187db01ae 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ForwardingContextCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/calculator/ForwardingContextCalculator.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.calculator; import net.luckperms.api.context.ContextCalculator; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/WorldNameRewriter.java b/common/src/main/java/me/lucko/luckperms/common/context/calculator/WorldNameRewriter.java similarity index 98% rename from common/src/main/java/me/lucko/luckperms/common/context/WorldNameRewriter.java rename to common/src/main/java/me/lucko/luckperms/common/context/calculator/WorldNameRewriter.java index cc52ca597..98c1123c7 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/WorldNameRewriter.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/calculator/WorldNameRewriter.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.calculator; import me.lucko.luckperms.common.config.ConfigKeys; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextComparator.java b/common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextComparator.java new file mode 100644 index 000000000..ba56de8d1 --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextComparator.java @@ -0,0 +1,75 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.context.comparator; + +import net.luckperms.api.context.Context; + +import java.util.Comparator; + +public class ContextComparator implements Comparator { + + public static final ContextComparator INSTANCE = new ContextComparator(false); + + public static final ContextComparator ONLY_KEY = new ContextComparator(true); + + private final boolean onlyKeys; + + public ContextComparator(boolean onlyKeys) { + this.onlyKeys = onlyKeys; + } + + @Override + public int compare(Context o1, Context o2) { + if (o1 == o2) { + return 0; + } + + int i = compareStringsFast(o1.getKey(), o2.getKey()); + if (i != 0) { + return i; + } + + if (this.onlyKeys) { + return 0; + } + + return compareStringsFast(o1.getValue(), o2.getValue()); + } + + public int compare(Context o1, String o2Key, String o2Value) { + int i = compareStringsFast(o1.getKey(), o2Key); + if (i != 0) { + return i; + } + + return compareStringsFast(o1.getValue(), o2Value); + } + + @SuppressWarnings("StringEquality") + private static int compareStringsFast(String o1, String o2) { + return o1 == o2 ? 0 : o1.compareTo(o2); + } +} diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java b/common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextSetComparator.java similarity index 83% rename from common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java rename to common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextSetComparator.java index 66eb8e132..a91e34724 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/comparator/ContextSetComparator.java @@ -23,9 +23,9 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.comparator; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.Context; import net.luckperms.api.context.DefaultContextKeys; @@ -90,7 +90,7 @@ public class ContextSetComparator implements Comparator { Context ent1 = o1Array[i]; Context ent2 = o2Array[i]; - result = compareContexts(ent1, ent2); + result = ContextComparator.INSTANCE.compare(ent1, ent2); if (result != 0) { return result; } @@ -99,29 +99,10 @@ public class ContextSetComparator implements Comparator { throw new AssertionError("sets are equal? " + o1 + " - " + o2); } - public static final Comparator CONTEXT_COMPARATOR = ContextSetComparator::compareContexts; - private static Context[] toArray(ImmutableContextSet set) { Context[] array = set.toSet().toArray(new Context[0]); - Arrays.sort(array, CONTEXT_COMPARATOR); + Arrays.sort(array, ContextComparator.INSTANCE); return array; } - private static int compareContexts(Context o1, Context o2) { - if (o1 == o2) { - return 0; - } - - int i = compareStringsFast(o1.getKey(), o2.getKey()); - if (i != 0) { - return i; - } - - return compareStringsFast(o1.getValue(), o2.getValue()); - } - - @SuppressWarnings("StringEquality") - private static int compareStringsFast(String o1, String o2) { - return o1 == o2 ? 0 : o1.compareTo(o2); - } } diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java b/common/src/main/java/me/lucko/luckperms/common/context/manager/ContextManager.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java rename to common/src/main/java/me/lucko/luckperms/common/context/manager/ContextManager.java index 779763ae2..d5eeffe1f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/manager/ContextManager.java @@ -23,11 +23,12 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.manager; import me.lucko.luckperms.common.cache.ExpiringCache; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.calculator.ForwardingContextCalculator; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.luckperms.api.context.ContextCalculator; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsCache.java b/common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsCache.java similarity index 97% rename from common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsCache.java rename to common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsCache.java index 457969b70..15228ce27 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsCache.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.manager; import me.lucko.luckperms.common.cache.ExpiringCache; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsSupplier.java b/common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsSupplier.java similarity index 96% rename from common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsSupplier.java rename to common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsSupplier.java index 351fb25f1..7e5af3acc 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/QueryOptionsSupplier.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/manager/QueryOptionsSupplier.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.manager; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.query.QueryOptions; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetConfigurateSerializer.java similarity index 94% rename from common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java rename to common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetConfigurateSerializer.java index dffaf87b5..f9b5bbada 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetConfigurateSerializer.java @@ -23,12 +23,12 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.serializer; import com.google.common.base.Preconditions; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.MutableContextSetImpl; import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.MutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetJsonSerializer.java similarity index 95% rename from common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java rename to common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetJsonSerializer.java index bcee83d31..70b4b83b5 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/serializer/ContextSetJsonSerializer.java @@ -23,7 +23,7 @@ * SOFTWARE. */ -package me.lucko.luckperms.common.context; +package me.lucko.luckperms.common.context.serializer; import com.google.common.base.Preconditions; import com.google.gson.Gson; @@ -32,8 +32,8 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; -import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.MutableContextSetImpl; import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.MutableContextSet; 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 c25c76798..53a647f34 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,7 +26,7 @@ package me.lucko.luckperms.common.model.manager.user; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.manager.AbstractManager; import me.lucko.luckperms.common.model.manager.group.GroupManager; diff --git a/common/src/main/java/me/lucko/luckperms/common/model/nodemap/NodeMapMutable.java b/common/src/main/java/me/lucko/luckperms/common/model/nodemap/NodeMapMutable.java index 9b500c15f..8ec1d828e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/model/nodemap/NodeMapMutable.java +++ b/common/src/main/java/me/lucko/luckperms/common/model/nodemap/NodeMapMutable.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.model.nodemap; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextSetComparator; +import me.lucko.luckperms.common.context.comparator.ContextSetComparator; import me.lucko.luckperms.common.model.InheritanceOrigin; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.model.nodemap.MutateResult.ChangeType; diff --git a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNodeBuilder.java b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNodeBuilder.java index 00fde5c4d..8840dcde0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/AbstractNodeBuilder.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/AbstractNodeBuilder.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.node; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.ImmutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java b/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java index 2b84a53c5..16f405857 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/comparator/NodeWithContextComparator.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.node.comparator; -import me.lucko.luckperms.common.context.ContextSetComparator; +import me.lucko.luckperms.common.context.comparator.ContextSetComparator; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.node.Node; diff --git a/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeJsonSerializer.java index a75afada9..138bc55ea 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/utils/NodeJsonSerializer.java @@ -29,7 +29,7 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.context.ContextSetJsonSerializer; +import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer; import me.lucko.luckperms.common.node.factory.NodeBuilders; import net.luckperms.api.node.Node; diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index aa1eedca3..f058a478d 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -32,7 +32,7 @@ import me.lucko.luckperms.common.calculator.CalculatorFactory; import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.config.LuckPermsConfiguration; import me.lucko.luckperms.common.config.generic.adapter.ConfigurationAdapter; -import me.lucko.luckperms.common.context.ConfigurationContextCalculator; +import me.lucko.luckperms.common.context.calculator.ConfigurationContextCalculator; import me.lucko.luckperms.common.dependencies.Dependency; import me.lucko.luckperms.common.dependencies.DependencyManager; import me.lucko.luckperms.common.event.AbstractEventBus; diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java index d002d2ece..25fc4b544 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/LuckPermsPlugin.java @@ -31,7 +31,7 @@ import me.lucko.luckperms.common.calculator.CalculatorFactory; import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.command.abstraction.Command; import me.lucko.luckperms.common.config.LuckPermsConfiguration; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.dependencies.DependencyManager; import me.lucko.luckperms.common.event.EventDispatcher; import me.lucko.luckperms.common.extension.SimpleExtensionManager; diff --git a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsBuilderImpl.java b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsBuilderImpl.java index 539a97432..868bc5c50 100644 --- a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsBuilderImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsBuilderImpl.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.common.query; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.ImmutableContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java index 7eab66e99..ef93f4fe1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/query/QueryOptionsImpl.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.common.query; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import net.luckperms.api.context.ContextSatisfyMode; import net.luckperms.api.context.ContextSet; diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java index 92d177e15..a4287a7d0 100644 --- a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java +++ b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.common.sender; import me.lucko.luckperms.common.command.access.CommandPermission; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import net.kyori.adventure.text.Component; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/AbstractConfigurateStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/AbstractConfigurateStorage.java index e812e83ad..908dab15c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/AbstractConfigurateStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/file/AbstractConfigurateStorage.java @@ -29,8 +29,8 @@ import com.google.common.collect.Iterables; import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; -import me.lucko.luckperms.common.context.ContextSetConfigurateSerializer; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.serializer.ContextSetConfigurateSerializer; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; import me.lucko.luckperms.common.model.Track; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java index 79e9bb0eb..3375ec411 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/mongodb/MongoStorage.java @@ -40,7 +40,7 @@ import com.mongodb.client.model.ReplaceOptions; import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; -import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; +import me.lucko.luckperms.common.context.MutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.HolderType; diff --git a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java index d1a4e60db..aab52eb1b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java +++ b/common/src/main/java/me/lucko/luckperms/common/storage/implementation/sql/SqlStorage.java @@ -34,7 +34,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.bulkupdate.BulkUpdate; import me.lucko.luckperms.common.bulkupdate.BulkUpdateStatistics; import me.lucko.luckperms.common.bulkupdate.PreparedStatementBuilder; -import me.lucko.luckperms.common.context.ContextSetJsonSerializer; +import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java index ca286e34a..868303c57 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java +++ b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorRequest.java @@ -29,8 +29,8 @@ import com.google.common.base.Preconditions; import com.google.gson.JsonObject; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextSetJsonSerializer; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer; import me.lucko.luckperms.common.http.AbstractHttpClient; import me.lucko.luckperms.common.http.UnsuccessfulRequestException; import me.lucko.luckperms.common.locale.Message; diff --git a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java index 54af73721..6791f56a1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java +++ b/common/src/main/java/me/lucko/luckperms/common/webeditor/WebEditorResponse.java @@ -33,7 +33,7 @@ import me.lucko.luckperms.common.actionlog.LoggedAction; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.utils.StorageAssistant; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; diff --git a/common/src/test/java/me/lucko/luckperms/common/context/ContextSetTest.java b/common/src/test/java/me/lucko/luckperms/common/context/ContextSetTest.java new file mode 100644 index 000000000..94079867c --- /dev/null +++ b/common/src/test/java/me/lucko/luckperms/common/context/ContextSetTest.java @@ -0,0 +1,158 @@ +/* + * This file is part of LuckPerms, licensed under the MIT License. + * + * Copyright (c) lucko (Luck) + * Copyright (c) contributors + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package me.lucko.luckperms.common.context; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; + +import net.luckperms.api.context.Context; +import net.luckperms.api.context.ContextSatisfyMode; +import net.luckperms.api.context.ImmutableContextSet; + +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.function.Consumer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class ContextSetTest { + + @Test + public void testImmutableBuilder() { + List> tests = ImmutableList.of( + builder -> { + builder.add("test", "a"); + builder.add("test", "b"); + builder.add("test", "c"); + }, + builder -> { + builder.add("test", "c"); + builder.add("test", "b"); + builder.add("test", "a"); + }, + builder -> { + builder.add("test", "b"); + builder.add("test", "a"); + builder.add("test", "c"); + }, + builder -> { + builder.add("test", "b"); + builder.add("test", "c"); + builder.add("test", "a"); + }, + builder -> { + builder.add("test", "a"); + builder.add("test", "a"); + builder.add("test", "b"); + builder.add("test", "c"); + } + ); + + for (Consumer action : tests) { + ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl(); + action.accept(builder); + ImmutableContextSet set = builder.build(); + + ImmutableSet expected = ImmutableSet.of( + new ContextImpl("test", "a"), + new ContextImpl("test", "b"), + new ContextImpl("test", "c") + ); + + assertEquals(expected, set.toSet()); + assertEquals(3, set.size()); + + assertTrue(set.contains("test", "a")); + assertTrue(set.contains("test", "b")); + assertTrue(set.contains("test", "c")); + } + } + + @Test + public void testImmutableContains() { + ImmutableContextSet set = new ImmutableContextSetImpl.BuilderImpl() + .add("test", "a") + .add("test", "a") + .add("test", "b") + .add("test", "c") + .build(); + + assertTrue(set.contains("test", "a")); + assertFalse(set.contains("test", "z")); + assertFalse(set.contains("aaa", "a")); + + assertTrue(set.containsKey("test")); + assertFalse(set.containsKey("aaa")); + } + + @Test + public void testImmutableContainsAll() { + ImmutableContextSetImpl set = (ImmutableContextSetImpl) new ImmutableContextSetImpl.BuilderImpl() + .add("test", "a") + .add("test", "b") + .add("test", "c") + .add("other", "a") + .add("other", "b") + .build(); + + List> trueTests = ImmutableList.of( + builder -> builder.add("test", "a").add("other", "a"), + builder -> builder.add("test", "b").add("other", "a"), + builder -> builder.add("test", "c").add("other", "a"), + builder -> builder.add("test", "c").add("other", "b") + ); + + for (Consumer test : trueTests) { + ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl(); + test.accept(builder); + assertTrue(set.otherContainsAll( + builder.build(), + ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY) + ); + } + + List> falseTests = ImmutableList.of( + builder -> builder.add("test", "a").add("other", "z"), + builder -> builder.add("test", "b").add("other", "z"), + builder -> builder.add("test", "b"), + builder -> builder.add("test", "c"), + builder -> {} + ); + + for (Consumer test : falseTests) { + ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl(); + test.accept(builder); + assertFalse(set.otherContainsAll( + builder.build(), + ContextSatisfyMode.AT_LEAST_ONE_VALUE_PER_KEY) + ); + } + } + +} diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricContextManager.java b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricContextManager.java index eac3eddfc..39498db5b 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricContextManager.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricContextManager.java @@ -26,8 +26,8 @@ package me.lucko.luckperms.fabric.context; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.fabric.model.MixinUser; diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java index 7214d071b..193e73e3c 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/context/FabricPlayerCalculator.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.fabric.context; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.util.EnumNamer; import me.lucko.luckperms.fabric.LPFabricPlugin; import me.lucko.luckperms.fabric.event.PlayerChangeWorldCallback; 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 d7b5c3a21..cc30d1e9c 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 @@ -26,7 +26,7 @@ package me.lucko.luckperms.fabric.mixin; import me.lucko.luckperms.common.cacheddata.type.PermissionCache; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.locale.TranslationManager; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; diff --git a/fabric/src/main/java/me/lucko/luckperms/fabric/model/MixinUser.java b/fabric/src/main/java/me/lucko/luckperms/fabric/model/MixinUser.java index 4215908d6..2a6911615 100644 --- a/fabric/src/main/java/me/lucko/luckperms/fabric/model/MixinUser.java +++ b/fabric/src/main/java/me/lucko/luckperms/fabric/model/MixinUser.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.fabric.model; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.fabric.context.FabricContextManager; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitContextManager.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitContextManager.java index 9514862af..4cacd3c5c 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitContextManager.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitContextManager.java @@ -29,8 +29,8 @@ import com.github.benmanes.caffeine.cache.LoadingCache; import me.lucko.luckperms.common.cache.LoadingMap; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.util.CaffeineFactory; import me.lucko.luckperms.nukkit.LPNukkitPlugin; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitPlayerCalculator.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitPlayerCalculator.java index a31fab60b..82df303b5 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitPlayerCalculator.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/context/NukkitPlayerCalculator.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.nukkit.context; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.nukkit.LPNukkitPlugin; import net.luckperms.api.context.Context; diff --git a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissible.java b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissible.java index 05b934770..b7296a4b6 100644 --- a/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissible.java +++ b/nukkit/src/main/java/me/lucko/luckperms/nukkit/inject/permissible/LuckPermsPermissible.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.calculator.result.TristateResult; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent; import me.lucko.luckperms.nukkit.LPNukkitPlugin; diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java index f1c4c8bf3..f6d3bd583 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/DescriptionBuilder.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.service.proxy.api6; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; diff --git a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java index 1457784cb..237362660 100644 --- a/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java +++ b/sponge/sponge-service-api6/src/main/java/me/lucko/luckperms/sponge/service/proxy/api6/SubjectProxy.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.service.proxy.api6; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.common.util.ImmutableCollectors; import me.lucko.luckperms.sponge.service.CompatibilityUtil; import me.lucko.luckperms.sponge.service.model.LPPermissionService; diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java index 40b50a730..cccb156f9 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/DescriptionBuilder.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.service.proxy.api7; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.sponge.service.model.LPPermissionDescription; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; diff --git a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java index 91d30e85d..e8492738c 100644 --- a/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java +++ b/sponge/sponge-service-api7/src/main/java/me/lucko/luckperms/sponge/service/proxy/api7/SubjectProxy.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.service.proxy.api7; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.sponge.service.CompatibilityUtil; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java index 8eabb3b26..7cd3111d6 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/CompatibilityUtil.java @@ -27,8 +27,8 @@ package me.lucko.luckperms.sponge.service; import com.google.common.collect.ImmutableSet; -import me.lucko.luckperms.common.context.contextset.ContextImpl; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ContextImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.sponge.service.context.ForwardingContextSet; import me.lucko.luckperms.sponge.service.context.ForwardingImmutableContextSet; diff --git a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPPermissionService.java b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPPermissionService.java index 74ea0d264..8b4159bf6 100644 --- a/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPPermissionService.java +++ b/sponge/sponge-service/src/main/java/me/lucko/luckperms/sponge/service/model/LPPermissionService.java @@ -28,7 +28,7 @@ package me.lucko.luckperms.sponge.service.model; import com.google.common.collect.ImmutableCollection; import com.google.common.collect.ImmutableMap; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.sponge.service.reference.SubjectReferenceFactory; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeContextManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeContextManager.java index 90b415837..25b47dca2 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeContextManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongeContextManager.java @@ -27,9 +27,9 @@ package me.lucko.luckperms.sponge.context; import com.github.benmanes.caffeine.cache.LoadingCache; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsCache; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.common.util.CaffeineFactory; import me.lucko.luckperms.sponge.LPSpongePlugin; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongePlayerCalculator.java b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongePlayerCalculator.java index c2103b057..92af5d750 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongePlayerCalculator.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/context/SpongePlayerCalculator.java @@ -26,7 +26,7 @@ package me.lucko.luckperms.sponge.context; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.sponge.LPSpongePlugin; import net.luckperms.api.context.Context; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeGroupManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeGroupManager.java index aababb710..735ebe38f 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeGroupManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeGroupManager.java @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.manager.group.AbstractGroupManager; import me.lucko.luckperms.common.node.matcher.StandardNodeMatchers; import me.lucko.luckperms.common.storage.misc.DataConstraints; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeUserManager.java b/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeUserManager.java index fe200f929..330dd9913 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeUserManager.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/model/manager/SpongeUserManager.java @@ -32,7 +32,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Maps; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.manager.user.AbstractUserManager; import me.lucko.luckperms.common.model.manager.user.UserHousekeeper; import me.lucko.luckperms.common.node.matcher.StandardNodeMatchers; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsService.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsService.java index 9d9590ca2..8e87e41bf 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsService.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsService.java @@ -29,7 +29,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import me.lucko.luckperms.common.cache.LoadingMap; -import me.lucko.luckperms.common.context.ContextManager; +import me.lucko.luckperms.common.context.manager.ContextManager; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.sponge.LPSpongePlugin; import me.lucko.luckperms.sponge.model.manager.SpongeGroupManager; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/ContextCalculatorProxy.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/ContextCalculatorProxy.java index cb43a76f2..8deb8f9e3 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/ContextCalculatorProxy.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/ContextCalculatorProxy.java @@ -25,7 +25,7 @@ package me.lucko.luckperms.sponge.service.model; -import me.lucko.luckperms.common.context.ForwardingContextCalculator; +import me.lucko.luckperms.common.context.calculator.ForwardingContextCalculator; import net.luckperms.api.context.ContextConsumer; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/calculated/CalculatedSubjectData.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/calculated/CalculatedSubjectData.java index 8c1ab6dfb..74e6b881c 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/calculated/CalculatedSubjectData.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/calculated/CalculatedSubjectData.java @@ -30,7 +30,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.ContextSetComparator; +import me.lucko.luckperms.common.context.comparator.ContextSetComparator; import me.lucko.luckperms.sponge.service.ProxyFactory; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubject; diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/PersistedCollection.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/PersistedCollection.java index 9aad7faf1..c88252895 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/PersistedCollection.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/model/persisted/PersistedCollection.java @@ -31,7 +31,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import me.lucko.luckperms.common.cache.LoadingMap; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.common.util.ImmutableCollectors; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; 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 a3efda34e..a26626aac 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 @@ -32,8 +32,8 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import me.lucko.luckperms.common.context.ContextSetComparator; -import me.lucko.luckperms.common.context.ContextSetJsonSerializer; +import me.lucko.luckperms.common.context.comparator.ContextSetComparator; +import me.lucko.luckperms.common.context.serializer.ContextSetJsonSerializer; import me.lucko.luckperms.sponge.service.model.LPPermissionService; import me.lucko.luckperms.sponge.service.model.LPSubjectData; import me.lucko.luckperms.sponge.service.model.LPSubjectReference; diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityContextManager.java b/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityContextManager.java index ee76620ff..33ed407b0 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityContextManager.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityContextManager.java @@ -28,9 +28,9 @@ package me.lucko.luckperms.velocity.context; import com.github.benmanes.caffeine.cache.LoadingCache; import com.velocitypowered.api.proxy.Player; -import me.lucko.luckperms.common.context.ContextManager; -import me.lucko.luckperms.common.context.QueryOptionsCache; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.ContextManager; +import me.lucko.luckperms.common.context.manager.QueryOptionsCache; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.common.util.CaffeineFactory; import me.lucko.luckperms.velocity.LPVelocityPlugin; diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityPlayerCalculator.java b/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityPlayerCalculator.java index 7153e8c71..1287a166f 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityPlayerCalculator.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/context/VelocityPlayerCalculator.java @@ -33,7 +33,7 @@ import com.velocitypowered.api.proxy.ServerConnection; import com.velocitypowered.api.proxy.server.RegisteredServer; import me.lucko.luckperms.common.config.ConfigKeys; -import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.ImmutableContextSetImpl; import me.lucko.luckperms.velocity.LPVelocityPlugin; import net.luckperms.api.context.ContextCalculator; diff --git a/velocity/src/main/java/me/lucko/luckperms/velocity/service/PlayerPermissionProvider.java b/velocity/src/main/java/me/lucko/luckperms/velocity/service/PlayerPermissionProvider.java index a3ca824cd..5287f04db 100644 --- a/velocity/src/main/java/me/lucko/luckperms/velocity/service/PlayerPermissionProvider.java +++ b/velocity/src/main/java/me/lucko/luckperms/velocity/service/PlayerPermissionProvider.java @@ -32,7 +32,7 @@ import com.velocitypowered.api.permission.PermissionSubject; import com.velocitypowered.api.permission.Tristate; import com.velocitypowered.api.proxy.Player; -import me.lucko.luckperms.common.context.QueryOptionsSupplier; +import me.lucko.luckperms.common.context.manager.QueryOptionsSupplier; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.verbose.event.PermissionCheckEvent;