diff --git a/api/src/main/java/net/luckperms/api/extension/ExtensionManager.java b/api/src/main/java/net/luckperms/api/extension/ExtensionManager.java index b0954b8df..33780aa5a 100644 --- a/api/src/main/java/net/luckperms/api/extension/ExtensionManager.java +++ b/api/src/main/java/net/luckperms/api/extension/ExtensionManager.java @@ -1,5 +1,5 @@ /* - * This file is part of luckperms, licensed under the MIT License. + * This file is part of LuckPerms, licensed under the MIT License. * * Copyright (c) lucko (Luck) * Copyright (c) contributors diff --git a/api/src/main/java/net/luckperms/api/query/DefaultQueryOptions.java b/api/src/main/java/net/luckperms/api/query/DefaultQueryOptions.java index 6ab4d8a85..d785749a1 100644 --- a/api/src/main/java/net/luckperms/api/query/DefaultQueryOptions.java +++ b/api/src/main/java/net/luckperms/api/query/DefaultQueryOptions.java @@ -37,9 +37,28 @@ final class DefaultQueryOptions { throw new AssertionError(); } + private static boolean setup = false; private static final EnumSet DEFAULT_FLAGS = EnumSet.allOf(Flag.class); + private static QueryOptions contextual; + private static QueryOptions nonContextual; - static final QueryOptions CONTEXTUAL = QueryOptions.contextual(ImmutableContextSet.empty(), DEFAULT_FLAGS); - static final QueryOptions NON_CONTEXTUAL = QueryOptions.nonContextual(DEFAULT_FLAGS); + private static void setup() { + if (setup) { + return; + } + setup = true; + contextual = QueryOptions.contextual(ImmutableContextSet.empty(), DEFAULT_FLAGS); + nonContextual = QueryOptions.nonContextual(DEFAULT_FLAGS); + } + + static QueryOptions contextual() { + setup(); + return contextual; + } + + static QueryOptions nonContextual() { + setup(); + return nonContextual; + } } diff --git a/api/src/main/java/net/luckperms/api/query/QueryOptions.java b/api/src/main/java/net/luckperms/api/query/QueryOptions.java index 1906850ac..4d072766a 100644 --- a/api/src/main/java/net/luckperms/api/query/QueryOptions.java +++ b/api/src/main/java/net/luckperms/api/query/QueryOptions.java @@ -94,7 +94,7 @@ public interface QueryOptions { * @return the default non contextual query options */ static @NonNull QueryOptions nonContextual() { - return DefaultQueryOptions.NON_CONTEXTUAL; + return DefaultQueryOptions.nonContextual(); } /** @@ -107,7 +107,7 @@ public interface QueryOptions { * @return the default contextual query options */ static @NonNull QueryOptions defaultContextualOptions() { - return DefaultQueryOptions.CONTEXTUAL; + return DefaultQueryOptions.contextual(); } /** diff --git a/bukkit/build.gradle b/bukkit/build.gradle index 934014f89..686f8d582 100644 --- a/bukkit/build.gradle +++ b/bukkit/build.gradle @@ -46,6 +46,7 @@ shadowJar { archiveName = "LuckPerms-Bukkit-${project.ext.fullVersion}.jar" dependencies { + include(dependency('net.luckperms:.*')) include(dependency('me.lucko.luckperms:.*')) } 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 afca59dd7..1bcf63154 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 @@ -32,6 +32,7 @@ import me.lucko.luckperms.common.cacheddata.type.MetaAccumulator; import me.lucko.luckperms.common.cacheddata.type.MetaCache; import me.lucko.luckperms.common.command.CommandManager; import me.lucko.luckperms.common.config.ConfigKeys; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.PermissionHolder; import me.lucko.luckperms.common.node.factory.NodeFactory; @@ -313,7 +314,7 @@ public class LuckPermsVaultChat extends AbstractVaultChat { } private QueryOptions createQueryOptionsForWorldSet(String world) { - ImmutableContextSet.Builder context = ImmutableContextSet.builder(); + ImmutableContextSet.Builder context = new ImmutableContextSetImpl.BuilderImpl(); if (world != null && !world.equals("") && !world.equalsIgnoreCase("global")) { context.add(DefaultContextKeys.WORLD_KEY, world.toLowerCase()); } diff --git a/bungee/build.gradle b/bungee/build.gradle index 13e1030d7..d466bbf23 100644 --- a/bungee/build.gradle +++ b/bungee/build.gradle @@ -32,6 +32,7 @@ shadowJar { archiveName = "LuckPerms-Bungee-${project.ext.fullVersion}.jar" dependencies { + include(dependency('net.luckperms:.*')) include(dependency('me.lucko.luckperms:.*')) } diff --git a/common/src/main/java/me/lucko/luckperms/common/api/MinimalApiProvider.java b/common/src/main/java/me/lucko/luckperms/common/api/MinimalApiProvider.java new file mode 100644 index 000000000..4c6f27ebc --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/common/api/MinimalApiProvider.java @@ -0,0 +1,153 @@ +/* + * 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.api; + +import me.lucko.luckperms.common.actionlog.LoggedAction; +import me.lucko.luckperms.common.api.implementation.ApiContextSetFactory; +import me.lucko.luckperms.common.api.implementation.ApiNodeBuilderRegistry; +import me.lucko.luckperms.common.query.QueryOptionsBuilderImpl; + +import net.luckperms.api.LuckPerms; +import net.luckperms.api.actionlog.Action; +import net.luckperms.api.actionlog.ActionLog; +import net.luckperms.api.actionlog.ActionLogger; +import net.luckperms.api.context.ContextCalculator; +import net.luckperms.api.context.ContextManager; +import net.luckperms.api.context.ContextSetFactory; +import net.luckperms.api.context.ImmutableContextSet; +import net.luckperms.api.event.EventBus; +import net.luckperms.api.messaging.MessagingService; +import net.luckperms.api.messenger.MessengerProvider; +import net.luckperms.api.metastacking.MetaStackFactory; +import net.luckperms.api.model.group.GroupManager; +import net.luckperms.api.model.user.User; +import net.luckperms.api.model.user.UserManager; +import net.luckperms.api.node.NodeBuilderRegistry; +import net.luckperms.api.platform.Platform; +import net.luckperms.api.platform.PluginMetadata; +import net.luckperms.api.query.QueryMode; +import net.luckperms.api.query.QueryOptions; +import net.luckperms.api.track.TrackManager; + +import org.checkerframework.checker.nullness.qual.NonNull; + +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; + +/** + * Implements the LuckPerms API using the plugin instance + */ +public class MinimalApiProvider implements LuckPerms { + public static final MinimalApiProvider INSTANCE = new MinimalApiProvider(); + + private MinimalApiProvider() { + + } + + private static UnsupportedOperationException exception() { + return new UnsupportedOperationException("API is not fully loaded yet - current implementation is minimal."); + } + + @Override + public @NonNull ActionLogger getActionLogger() { + return MinimalActionLogger.INSTANCE; + } + + @Override + public @NonNull ContextManager getContextManager() { + return MinimalContextManager.INSTANCE; + } + + @Override + public @NonNull NodeBuilderRegistry getNodeBuilderRegistry() { + return ApiNodeBuilderRegistry.INSTANCE; + } + + @Override public @NonNull String getServerName() { throw exception(); } + @Override public @NonNull UserManager getUserManager() { throw exception(); } + @Override public @NonNull GroupManager getGroupManager() { throw exception(); } + @Override public @NonNull TrackManager getTrackManager() { throw exception(); } + @Override public @NonNull Platform getPlatform() { throw exception(); } + @Override public @NonNull PluginMetadata getPluginMetadata() { throw exception(); } + @Override public @NonNull EventBus getEventBus() { throw exception(); } + @Override public @NonNull Optional getMessagingService() { throw exception(); } + @Override public @NonNull MetaStackFactory getMetaStackFactory() { throw exception(); } + @Override public @NonNull CompletableFuture runUpdateTask() { throw exception(); } + @Override public void registerMessengerProvider(@NonNull MessengerProvider messengerProvider) { throw exception(); } + @Override public @NonNull Collection getKnownPermissions() { throw exception(); } + + private static final class MinimalActionLogger implements ActionLogger { + private static final MinimalActionLogger INSTANCE = new MinimalActionLogger(); + + private MinimalActionLogger() { + + } + + @Override + public Action.@NonNull Builder actionBuilder() { + return LoggedAction.build(); + } + + @Override public @NonNull CompletableFuture getLog() { throw exception(); } + @Override public @NonNull CompletableFuture submit(@NonNull Action entry) { throw exception(); } + @Override public @NonNull CompletableFuture submitToStorage(@NonNull Action entry) { throw exception(); } + @Override public @NonNull CompletableFuture broadcastAction(@NonNull Action entry) { throw exception(); } + } + + private static final class MinimalContextManager implements ContextManager { + private static final MinimalContextManager INSTANCE = new MinimalContextManager(); + + private MinimalContextManager() { + + } + + @Override + public QueryOptions.@NonNull Builder queryOptionsBuilder(@NonNull QueryMode mode) { + Objects.requireNonNull(mode, "mode"); + return new QueryOptionsBuilderImpl(mode); + } + + @Override + public @NonNull ContextSetFactory getContextSetFactory() { + return ApiContextSetFactory.INSTANCE; + } + + @Override public @NonNull ImmutableContextSet getContext(@NonNull Object subject) { throw exception(); } + @Override public @NonNull Optional lookupContext(@NonNull User user) { throw exception(); } + @Override public @NonNull ImmutableContextSet getStaticContext() { throw exception(); } + @Override public @NonNull QueryOptions getQueryOptions(@NonNull Object subject) { throw exception(); } + @Override public @NonNull Optional lookupQueryOptions(@NonNull User user) { throw exception(); } + @Override public @NonNull QueryOptions getStaticQueryOptions() { throw exception(); } + @Override public @NonNull QueryOptions formQueryOptions(@NonNull Object subject, @NonNull ImmutableContextSet contextSet) { throw exception(); } + @Override public @NonNull QueryOptions formQueryOptions(@NonNull ImmutableContextSet contextSet) { throw exception(); } + @Override public void registerCalculator(@NonNull ContextCalculator calculator) { throw exception(); } + @Override public void unregisterCalculator(@NonNull ContextCalculator calculator) { throw exception(); } + @Override public void invalidateCache(@NonNull Object subject) { throw exception(); } + } + +} diff --git a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java index 129153f63..0fe6948bd 100644 --- a/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java +++ b/common/src/main/java/me/lucko/luckperms/common/command/utils/ArgumentParser.java @@ -27,6 +27,8 @@ package me.lucko.luckperms.common.command.utils; import me.lucko.luckperms.common.command.abstraction.CommandException; import me.lucko.luckperms.common.commands.user.UserMainCommand; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.storage.misc.DataConstraints; @@ -152,7 +154,7 @@ public class ArgumentParser { public static MutableContextSet parseContext(int fromIndex, List args, LuckPermsPlugin plugin) throws CommandException { if (args.size() > fromIndex) { - MutableContextSet set = MutableContextSet.create(); + MutableContextSet set = new MutableContextSetImpl(); List contexts = args.subList(fromIndex, args.size()); @@ -244,10 +246,10 @@ public class ArgumentParser { public static ImmutableContextSet parseContextSponge(int fromIndex, List args) { if (args.size() <= fromIndex) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } - MutableContextSet contextSet = MutableContextSet.create(); + MutableContextSet contextSet = new MutableContextSetImpl(); List toQuery = args.subList(fromIndex, args.size()); for (String s : toQuery) { int index = s.indexOf('='); 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 27078df47..e06ebb747 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 @@ -32,6 +32,7 @@ import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.ArgumentPermissions; import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.config.ConfigKeys; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; @@ -48,7 +49,6 @@ import net.kyori.text.TextComponent; import net.kyori.text.event.ClickEvent; import net.kyori.text.event.HoverEvent; import net.kyori.text.format.TextColor; -import net.luckperms.api.context.ImmutableContextSet; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -66,7 +66,7 @@ public class HolderEditor extends SubCommand { @Override public CommandResult execute(LuckPermsPlugin plugin, Sender sender, T holder, List args, String label) { - if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), holder) || ArgumentPermissions.checkGroup(plugin, sender, holder, ImmutableContextSet.empty())) { + if (ArgumentPermissions.checkViewPerms(plugin, sender, getPermission().get(), holder) || ArgumentPermissions.checkGroup(plugin, sender, holder, ImmutableContextSetImpl.EMPTY)) { Message.COMMAND_NO_PERMISSION.send(sender); return CommandResult.NO_PERMISSION; } 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 782daaac8..8d940b336 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 @@ -34,6 +34,7 @@ import me.lucko.luckperms.common.command.tabcomplete.TabCompleter; import me.lucko.luckperms.common.command.tabcomplete.TabCompletions; 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.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; @@ -45,7 +46,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.model.DataType; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeEqualityPredicate; @@ -80,9 +80,9 @@ public class UserSwitchPrimaryGroup extends SharedSubCommand { return CommandResult.INVALID_ARGS; } - if (ArgumentPermissions.checkContext(plugin, sender, permission, ImmutableContextSet.empty()) || - ArgumentPermissions.checkGroup(plugin, sender, holder, ImmutableContextSet.empty()) || - ArgumentPermissions.checkGroup(plugin, sender, group, ImmutableContextSet.empty()) || + if (ArgumentPermissions.checkContext(plugin, sender, permission, ImmutableContextSetImpl.EMPTY) || + ArgumentPermissions.checkGroup(plugin, sender, holder, ImmutableContextSetImpl.EMPTY) || + ArgumentPermissions.checkGroup(plugin, sender, group, ImmutableContextSetImpl.EMPTY) || ArgumentPermissions.checkArguments(plugin, sender, permission, group.getName())) { Message.COMMAND_NO_PERMISSION.send(sender); return CommandResult.NO_PERMISSION; 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 697044d1f..693c076b5 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 @@ -29,6 +29,7 @@ import me.lucko.luckperms.common.actionlog.Log; import me.lucko.luckperms.common.command.CommandResult; import me.lucko.luckperms.common.command.abstraction.SubCommand; import me.lucko.luckperms.common.command.access.CommandPermission; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.locale.LocaleManager; import me.lucko.luckperms.common.locale.command.CommandSpec; import me.lucko.luckperms.common.locale.message.Message; @@ -38,7 +39,6 @@ import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; import me.lucko.luckperms.common.util.Predicates; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.model.DataType; import net.luckperms.api.node.Node; @@ -59,7 +59,7 @@ public class LogNotify extends SubCommand { return false; } - Optional ret = user.normalData().immutable().get(ImmutableContextSet.empty()).stream() + Optional ret = user.normalData().immutable().get(ImmutableContextSetImpl.EMPTY).stream() .filter(n -> n.getKey().equalsIgnoreCase(IGNORE_NODE)) .findFirst(); @@ -79,7 +79,7 @@ public class LogNotify extends SubCommand { user.setPermission(DataType.NORMAL, NodeFactory.make(IGNORE_NODE), true); } else { // remove the perm - user.removeIf(DataType.NORMAL, ImmutableContextSet.empty(), n -> n.getKey().equalsIgnoreCase(IGNORE_NODE), null); + user.removeIf(DataType.NORMAL, ImmutableContextSetImpl.EMPTY, n -> n.getKey().equalsIgnoreCase(IGNORE_NODE), null); } plugin.getStorage().saveUser(user).join(); 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 e74d9b85c..54d8a1774 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 @@ -28,6 +28,7 @@ package me.lucko.luckperms.common.config; import com.google.common.collect.ImmutableMap; import me.lucko.luckperms.common.command.utils.ArgumentParser; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.graph.TraversalAlgorithm; import me.lucko.luckperms.common.metastacking.SimpleMetaStackDefinition; import me.lucko.luckperms.common.metastacking.StandardStackElements; @@ -41,7 +42,6 @@ import me.lucko.luckperms.common.storage.implementation.split.SplitStorageType; import me.lucko.luckperms.common.storage.misc.StorageCredentials; import me.lucko.luckperms.common.util.ImmutableCollectors; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.metastacking.DuplicateRemovalFunction; import net.luckperms.api.metastacking.MetaStackDefinition; import net.luckperms.api.model.TemporaryMergeBehaviour; @@ -108,7 +108,7 @@ public final class ConfigKeys { if (c.getBoolean("apply-global-world-groups", true)) { flags.add(Flag.APPLY_INHERITANCE_NODES_WITHOUT_WORLD_CONTEXT); } - return QueryOptions.contextual(ImmutableContextSet.empty(), flags); + return QueryOptions.contextual(ImmutableContextSetImpl.EMPTY, flags); }); /** 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 9d5d00c06..2e8c89556 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 @@ -29,6 +29,7 @@ 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.util.gson.GsonProvider; import net.luckperms.api.context.ImmutableContextSet; @@ -46,8 +47,8 @@ import java.nio.file.Path; public class ContextsFile { private final LuckPermsConfiguration configuration; - private ImmutableContextSet staticContexts = ImmutableContextSet.empty(); - private ImmutableContextSet defaultContexts = ImmutableContextSet.empty(); + private ImmutableContextSet staticContexts = ImmutableContextSetImpl.EMPTY; + private ImmutableContextSet defaultContexts = ImmutableContextSetImpl.EMPTY; public ContextsFile(LuckPermsConfiguration configuration) { this.configuration = configuration; diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java index 261f15e2c..50b2c188b 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextManager.java @@ -29,6 +29,7 @@ import com.google.common.collect.ImmutableList; 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.plugin.LuckPermsPlugin; import net.luckperms.api.context.ContextCalculator; @@ -119,7 +120,7 @@ public abstract class ContextManager { } protected QueryOptions calculate(T subject) { - ImmutableContextSet.Builder accumulator = ImmutableContextSet.builder(); + ImmutableContextSet.Builder accumulator = new ImmutableContextSetImpl.BuilderImpl(); for (ContextCalculator calculator : this.calculators) { try { @@ -134,7 +135,7 @@ public abstract class ContextManager { } QueryOptions calculateStatic() { - ImmutableContextSet.Builder accumulator = ImmutableContextSet.builder(); + ImmutableContextSet.Builder accumulator = new ImmutableContextSetImpl.BuilderImpl(); for (StaticContextCalculator calculator : this.staticCalculators) { try { diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java index 2d3d00180..325346022 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetConfigurateSerializer.java @@ -27,8 +27,10 @@ package me.lucko.luckperms.common.context; import com.google.common.base.Preconditions; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; + import net.luckperms.api.context.ContextSet; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.context.MutableContextSet; import ninja.leaping.configurate.ConfigurationNode; @@ -65,10 +67,10 @@ public final class ContextSetConfigurateSerializer { Map dataMap = data.getChildrenMap(); if (dataMap.isEmpty()) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } - MutableContextSet map = MutableContextSet.create(); + MutableContextSet map = new MutableContextSetImpl(); for (Map.Entry e : dataMap.entrySet()) { String k = e.getKey().toString(); ConfigurationNode v = e.getValue(); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java index 8adcb6c8f..787dee16a 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/ContextSetJsonSerializer.java @@ -32,8 +32,10 @@ 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 net.luckperms.api.context.ContextSet; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.context.MutableContextSet; import java.util.ArrayList; @@ -70,12 +72,12 @@ public final class ContextSetJsonSerializer { public static ContextSet deserializeContextSet(Gson gson, String json) { Objects.requireNonNull(json, "json"); if (json.equals("{}")) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } JsonObject context = gson.fromJson(json, JsonObject.class); if (context == null) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } return deserializeContextSet(context); @@ -86,10 +88,10 @@ public final class ContextSetJsonSerializer { JsonObject data = element.getAsJsonObject(); if (data.entrySet().isEmpty()) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } - MutableContextSet map = MutableContextSet.create(); + MutableContextSet map = new MutableContextSetImpl(); for (Map.Entry e : data.entrySet()) { String k = e.getKey(); JsonElement v = e.getValue(); diff --git a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java index 59273cbcb..bb304603f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java +++ b/common/src/main/java/me/lucko/luckperms/common/context/contextset/MutableContextSetImpl.java @@ -80,7 +80,7 @@ public final class MutableContextSetImpl extends AbstractContextSet implements M public @NonNull ImmutableContextSet immutableCopy() { // if the map is empty, don't create a new instance if (this.map.isEmpty()) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } synchronized (this.map) { return new ImmutableContextSetImpl(ImmutableSetMultimap.copyOf(this.map)); 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 63466e98b..5a618b9ac 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 @@ -28,13 +28,13 @@ package me.lucko.luckperms.common.model.manager.user; import com.google.common.collect.ImmutableCollection; import me.lucko.luckperms.common.config.ConfigKeys; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.User; import me.lucko.luckperms.common.model.UserIdentifier; import me.lucko.luckperms.common.model.manager.AbstractManager; import me.lucko.luckperms.common.node.factory.NodeFactory; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.model.DataType; import net.luckperms.api.node.Node; import net.luckperms.api.node.NodeType; @@ -91,7 +91,7 @@ public abstract class AbstractUserManager extends AbstractManage String pg = user.getPrimaryGroup().getValue(); boolean has = false; - for (Node node : user.normalData().immutable().get(ImmutableContextSet.empty())) { + for (Node node : user.normalData().immutable().get(ImmutableContextSetImpl.EMPTY)) { if (node instanceof InheritanceNode && ((InheritanceNode) node).getGroupName().equalsIgnoreCase(pg)) { has = true; break; @@ -100,7 +100,7 @@ public abstract class AbstractUserManager extends AbstractManage // need to find a new primary group for the user. if (!has) { - String group = user.normalData().immutable().get(ImmutableContextSet.empty()).stream() + String group = user.normalData().immutable().get(ImmutableContextSetImpl.EMPTY).stream() .filter(NodeType.INHERITANCE::matches) .map(NodeType.INHERITANCE::cast) .findFirst() 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 6b05fbe41..2d48547cb 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,6 +25,8 @@ package me.lucko.luckperms.common.node; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; + import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.DefaultContextKeys; import net.luckperms.api.context.ImmutableContextSet; @@ -50,14 +52,14 @@ public abstract class AbstractNodeBuilder, B extends protected AbstractNodeBuilder() { this.value = true; this.expireAt = 0L; - this.context = ImmutableContextSet.builder(); + this.context = new ImmutableContextSetImpl.BuilderImpl(); this.metadata = new IdentityHashMap<>(); } protected AbstractNodeBuilder(boolean value, long expireAt, ImmutableContextSet context, Map, Object> metadata) { this.value = value; this.expireAt = expireAt; - this.context = ImmutableContextSet.builder().addAll(context); + this.context = new ImmutableContextSetImpl.BuilderImpl().addAll(context); this.metadata = new IdentityHashMap<>(metadata); } @@ -98,7 +100,7 @@ public abstract class AbstractNodeBuilder, B extends @Override public @NonNull B context(@NonNull ContextSet contextSet) { Objects.requireNonNull(contextSet, "contextSet"); - this.context = ImmutableContextSet.builder().addAll(contextSet); + this.context = new ImmutableContextSetImpl.BuilderImpl().addAll(contextSet); return (B) this; } diff --git a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeTypes.java b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeTypes.java index d1580cca4..df23a3c15 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeTypes.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/factory/NodeTypes.java @@ -28,6 +28,7 @@ package me.lucko.luckperms.common.node.factory; import com.google.common.base.Splitter; import me.lucko.luckperms.common.cache.PatternCache; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.node.types.DisplayName; import me.lucko.luckperms.common.node.types.Inheritance; import me.lucko.luckperms.common.node.types.Meta; @@ -104,10 +105,10 @@ public final class NodeTypes { private static ImmutableContextSet formContextSet(ContextSet contexts, String server, String world) { if ((contexts == null || contexts.isEmpty()) && server == null && world == null) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } - ImmutableContextSet.Builder builder = ImmutableContextSet.builder(); + ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl(); if (contexts != null) { builder.addAll(contexts); diff --git a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeDataContainer.java b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeDataContainer.java index 3ce23bf33..8341a686e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/node/model/NodeDataContainer.java +++ b/common/src/main/java/me/lucko/luckperms/common/node/model/NodeDataContainer.java @@ -25,6 +25,7 @@ package me.lucko.luckperms.common.node.model; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.node.factory.NodeFactory; import net.luckperms.api.context.ContextSet; @@ -85,7 +86,7 @@ public final class NodeDataContainer { } public static NodeDataContainer of(String permission) { - return of(permission, true, "global", "global", 0L, ImmutableContextSet.empty()); + return of(permission, true, "global", "global", 0L, ImmutableContextSetImpl.EMPTY); } private final String permission; 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 b8762c264..55570fb37 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 @@ -28,6 +28,7 @@ package me.lucko.luckperms.common.plugin; import me.lucko.luckperms.common.actionlog.LogDispatcher; import me.lucko.luckperms.common.api.ApiRegistrationUtil; import me.lucko.luckperms.common.api.LuckPermsApiProvider; +import me.lucko.luckperms.common.api.MinimalApiProvider; import me.lucko.luckperms.common.calculator.CalculatorFactory; import me.lucko.luckperms.common.config.AbstractConfiguration; import me.lucko.luckperms.common.config.ConfigKeys; @@ -103,6 +104,9 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { // send the startup banner displayBanner(getConsoleSender()); + // minimal api + ApiRegistrationUtil.registerProvider(MinimalApiProvider.INSTANCE); + // load some utilities early this.verboseHandler = new VerboseHandler(getBootstrap().getScheduler()); this.permissionRegistry = new PermissionRegistry(getBootstrap().getScheduler()); 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 6bb90d50f..efe3c17d3 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,6 +25,8 @@ package me.lucko.luckperms.common.query; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; + import net.luckperms.api.context.ContextSet; import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.query.Flag; @@ -51,7 +53,7 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder { public QueryOptionsBuilderImpl(QueryMode mode) { this.mode = mode; - this.context = mode == QueryMode.CONTEXTUAL ? ImmutableContextSet.empty() : null; + this.context = mode == QueryMode.CONTEXTUAL ? ImmutableContextSetImpl.EMPTY : null; this.flags = 0; this.flagsSet = null; this.options = null; @@ -74,7 +76,7 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder { } this.mode = mode; - this.context = this.mode == QueryMode.CONTEXTUAL ? ImmutableContextSet.empty() : null; + this.context = this.mode == QueryMode.CONTEXTUAL ? ImmutableContextSetImpl.EMPTY : null; return this; } @@ -149,14 +151,16 @@ public class QueryOptionsBuilderImpl implements QueryOptions.Builder { if (this.options == null) { if (this.mode == QueryMode.NON_CONTEXTUAL) { QueryOptionsImpl defaults = (QueryOptionsImpl) QueryOptions.nonContextual(); - if (defaults.getFlagsByte() == flags) { + //noinspection ConstantConditions + if (defaults != null && defaults.getFlagsByte() == flags) { // mode same, contexts null, flags same, options null // so therefore, equal to default - return that instead! return defaults; } } else if (this.mode == QueryMode.CONTEXTUAL) { QueryOptionsImpl defaults = (QueryOptionsImpl) QueryOptions.defaultContextualOptions(); - if (defaults.getFlagsByte() == flags && this.context.isEmpty()) { + //noinspection ConstantConditions + if (defaults != null && defaults.getFlagsByte() == flags && this.context.isEmpty()) { // mode same, contexts empty, flags same, options null // so therefore, equal to default - return that instead! return defaults; 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 574064d2b..020bb8b7c 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 @@ -32,6 +32,7 @@ import com.google.common.collect.Maps; 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.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -462,7 +463,7 @@ public abstract class AbstractConfigurateStorage implements StorageImplementatio String world = attributes.getNode("world").getString("global"); long expiry = attributes.getNode("expiry").getLong(0L); - ImmutableContextSet context = ImmutableContextSet.empty(); + ImmutableContextSet context = ImmutableContextSetImpl.EMPTY; ConfigurationNode contextMap = attributes.getNode("context"); if (!contextMap.isVirtual() && contextMap.hasMapChildren()) { context = ContextSetConfigurateSerializer.deserializeContextSet(contextMap).immutableCopy(); @@ -477,7 +478,7 @@ public abstract class AbstractConfigurateStorage implements StorageImplementatio String world = attributes.getNode("world").getString("global"); long expiry = attributes.getNode("expiry").getLong(0L); - ImmutableContextSet context = ImmutableContextSet.empty(); + ImmutableContextSet context = ImmutableContextSetImpl.EMPTY; ConfigurationNode contextMap = attributes.getNode("context"); if (!contextMap.isVirtual() && contextMap.hasMapChildren()) { context = ContextSetConfigurateSerializer.deserializeContextSet(contextMap).immutableCopy(); 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 98f8152ec..9644c36da 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 @@ -41,6 +41,8 @@ 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.bulkupdate.comparison.Constraint; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; +import me.lucko.luckperms.common.context.contextset.MutableContextSetImpl; import me.lucko.luckperms.common.model.Group; import me.lucko.luckperms.common.model.Track; import me.lucko.luckperms.common.model.User; @@ -734,7 +736,7 @@ public class MongoStorage implements StorageImplementation { String server = "global"; String world = "global"; long expiry = 0L; - ImmutableContextSet context = ImmutableContextSet.empty(); + ImmutableContextSet context = ImmutableContextSetImpl.EMPTY; if (document.containsKey("value")) { value = document.getBoolean("value"); @@ -767,7 +769,7 @@ public class MongoStorage implements StorageImplementation { } private static MutableContextSet docsToContextSet(List documents) { - MutableContextSet map = MutableContextSet.create(); + MutableContextSet map = new MutableContextSetImpl(); for (Document doc : documents) { map.add(doc.getString("key"), doc.getString("value")); } diff --git a/nukkit/build.gradle b/nukkit/build.gradle index 8e2c00327..6431d33b5 100644 --- a/nukkit/build.gradle +++ b/nukkit/build.gradle @@ -24,6 +24,7 @@ shadowJar { archiveName = "LuckPerms-Nukkit-${project.ext.fullVersion}.jar" dependencies { + include(dependency('net.luckperms:.*')) include(dependency('me.lucko.luckperms:.*')) } diff --git a/sponge/build.gradle b/sponge/build.gradle index 5d8e399de..65db93bac 100644 --- a/sponge/build.gradle +++ b/sponge/build.gradle @@ -37,6 +37,7 @@ shadowJar { archiveName = "LuckPerms-Sponge-${project.ext.fullVersion}.jar" dependencies { + include(dependency('net.luckperms:.*')) include(dependency('me.lucko.luckperms:.*')) } 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 000123430..b433b4ef6 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,13 +25,13 @@ package me.lucko.luckperms.sponge.service.proxy.api6; +import me.lucko.luckperms.common.context.contextset.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; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; import me.lucko.luckperms.sponge.service.model.ProxiedServiceObject; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.node.Tristate; import org.checkerframework.checker.nullness.qual.NonNull; @@ -97,7 +97,7 @@ public final class DescriptionBuilder implements PermissionDescription.Builder, LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE); for (Map.Entry assignment : this.roles.entrySet()) { LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join(); - roleSubject.getTransientSubjectData().setPermission(ImmutableContextSet.empty(), this.id, assignment.getValue()); + roleSubject.getTransientSubjectData().setPermission(ImmutableContextSetImpl.EMPTY, this.id, assignment.getValue()); } // null stuff so this instance can be reused 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 b4f2f2a9d..05ecf90d7 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,13 +25,13 @@ package me.lucko.luckperms.sponge.service.proxy.api7; +import me.lucko.luckperms.common.context.contextset.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; import me.lucko.luckperms.sponge.service.model.LPSubjectCollection; import me.lucko.luckperms.sponge.service.model.ProxiedServiceObject; -import net.luckperms.api.context.ImmutableContextSet; import net.luckperms.api.node.Tristate; import org.checkerframework.checker.nullness.qual.NonNull; @@ -96,7 +96,7 @@ public final class DescriptionBuilder implements PermissionDescription.Builder, LPSubjectCollection subjects = this.service.getCollection(PermissionService.SUBJECTS_ROLE_TEMPLATE); for (Map.Entry assignment : this.roles.entrySet()) { LPSubject roleSubject = subjects.loadSubject(assignment.getKey()).join(); - roleSubject.getTransientSubjectData().setPermission(ImmutableContextSet.empty(), this.id, assignment.getValue()); + roleSubject.getTransientSubjectData().setPermission(ImmutableContextSetImpl.EMPTY, this.id, assignment.getValue()); } // null stuff so this instance can be reused 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 492428b7e..f4de0fd4e 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 @@ -28,6 +28,7 @@ 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.sponge.service.context.DelegatingContextSet; import me.lucko.luckperms.sponge.service.context.DelegatingImmutableContextSet; @@ -57,10 +58,10 @@ public final class CompatibilityUtil { } if (contexts.isEmpty()) { - return ImmutableContextSet.empty(); + return ImmutableContextSetImpl.EMPTY; } - ImmutableContextSet.Builder builder = ImmutableContextSet.builder(); + ImmutableContextSet.Builder builder = new ImmutableContextSetImpl.BuilderImpl(); for (Map.Entry entry : contexts) { builder.add(new ContextImpl(entry.getKey(), entry.getValue())); } 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 cfbd3ac1e..65f2577c7 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 @@ -34,6 +34,7 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.common.bulkupdate.comparison.Constraint; import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.manager.group.AbstractGroupManager; import me.lucko.luckperms.common.storage.misc.DataConstraints; import me.lucko.luckperms.common.util.ImmutableCollectors; @@ -194,7 +195,7 @@ public class SpongeGroupManager extends AbstractGroupManager implem List> lookup = this.plugin.getStorage().getGroupsWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join(); for (HeldNode holder : lookup) { - if (holder.getNode().getContexts().equals(ImmutableContextSet.empty())) { + if (holder.getNode().getContexts().equals(ImmutableContextSetImpl.EMPTY)) { ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder()), holder.getNode().getValue()); } } @@ -223,7 +224,7 @@ public class SpongeGroupManager extends AbstractGroupManager implem public ImmutableMap getLoadedWithPermission(String permission) { return getAll().values().stream() .map(SpongeGroup::sponge) - .map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSet.empty(), permission))) + .map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSetImpl.EMPTY, permission))) .filter(pair -> pair.getValue() != Tristate.UNDEFINED) .collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean())); } 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 731df5209..89a70c538 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 @@ -34,6 +34,7 @@ import com.google.common.collect.Maps; import me.lucko.luckperms.common.bulkupdate.comparison.Constraint; import me.lucko.luckperms.common.bulkupdate.comparison.StandardComparison; +import me.lucko.luckperms.common.context.contextset.ImmutableContextSetImpl; import me.lucko.luckperms.common.model.UserIdentifier; import me.lucko.luckperms.common.model.manager.user.AbstractUserManager; import me.lucko.luckperms.common.model.manager.user.UserHousekeeper; @@ -216,7 +217,7 @@ public class SpongeUserManager extends AbstractUserManager implement List> lookup = this.plugin.getStorage().getUsersWithPermission(Constraint.of(StandardComparison.EQUAL, permission)).join(); for (HeldNode holder : lookup) { - if (holder.getNode().getContexts().equals(ImmutableContextSet.empty())) { + if (holder.getNode().getContexts().equals(ImmutableContextSetImpl.EMPTY)) { ret.put(getService().getReferenceFactory().obtain(getIdentifier(), holder.getHolder().toString()), holder.getNode().getValue()); } } @@ -245,7 +246,7 @@ public class SpongeUserManager extends AbstractUserManager implement public ImmutableMap getLoadedWithPermission(String permission) { return getAll().values().stream() .map(SpongeUser::sponge) - .map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSet.empty(), permission))) + .map(sub -> Maps.immutableEntry(sub, sub.getPermissionValue(ImmutableContextSetImpl.EMPTY, permission))) .filter(pair -> pair.getValue() != Tristate.UNDEFINED) .collect(ImmutableCollectors.toMap(Map.Entry::getKey, sub -> sub.getValue().asBoolean())); } 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 325a6fc9f..ac6c83244 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,6 +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.util.ImmutableCollectors; import me.lucko.luckperms.common.util.Predicates; import me.lucko.luckperms.sponge.service.LuckPermsService; @@ -175,7 +176,7 @@ public class PersistedCollection implements LPSubjectCollection { public ImmutableMap getLoadedWithPermission(String permission) { ImmutableMap.Builder m = ImmutableMap.builder(); for (LPSubject subject : this.subjects.values()) { - Tristate ts = subject.getPermissionValue(ImmutableContextSet.empty(), permission); + Tristate ts = subject.getPermissionValue(ImmutableContextSetImpl.EMPTY, permission); if (ts != Tristate.UNDEFINED) { m.put(subject, ts.asBoolean()); } diff --git a/velocity/build.gradle b/velocity/build.gradle index 3bf6bd768..3c7c7f6bd 100644 --- a/velocity/build.gradle +++ b/velocity/build.gradle @@ -23,6 +23,7 @@ shadowJar { archiveName = "LuckPerms-Velocity-${project.ext.fullVersion}.jar" dependencies { + include(dependency('net.luckperms:.*')) include(dependency('me.lucko.luckperms:.*')) }