From 0a4d337a53f70dba267e3639d2d8d83573197463 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 27 Oct 2016 16:32:14 +0100 Subject: [PATCH] Cache context lookups & refactor Sponge subjects --- .../bukkit/inject/LPPermissible.java | 3 +- .../luckperms/bungee/BungeeListener.java | 3 +- .../common/contexts/ContextManager.java | 42 ++++--- .../luckperms/sponge/SpongeListener.java | 7 +- .../migration/MigrationPermissionsEx.java | 2 +- .../sponge/service/LuckPermsGroupSubject.java | 60 +++++----- .../sponge/service/LuckPermsService.java | 4 +- .../sponge/service/LuckPermsSubject.java | 103 ++++++++++++++++++ .../sponge/service/LuckPermsUserSubject.java | 52 ++++----- .../service/persisted/PersistedSubject.java | 3 +- .../sponge/service/simple/SimpleSubject.java | 3 +- 11 files changed, 183 insertions(+), 99 deletions(-) create mode 100644 sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubject.java diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/LPPermissible.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/LPPermissible.java index 49e02516..23f0d7ee 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/LPPermissible.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/inject/LPPermissible.java @@ -26,7 +26,6 @@ import lombok.Getter; import lombok.NonNull; import me.lucko.luckperms.api.Contexts; import me.lucko.luckperms.api.Tristate; -import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.bukkit.LPBukkitPlugin; import me.lucko.luckperms.common.users.User; import org.bukkit.Bukkit; @@ -67,7 +66,7 @@ public class LPPermissible extends PermissibleBase { public Contexts calculateContexts() { return new Contexts( - plugin.getContextManager().giveApplicableContext(parent, new MutableContextSet()), + plugin.getContextManager().getApplicableContext(parent), plugin.getConfiguration().isIncludingGlobalPerms(), plugin.getConfiguration().isIncludingGlobalWorldPerms(), true, diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java index 089a34ee..25788359 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java @@ -23,7 +23,6 @@ package me.lucko.luckperms.bungee; import me.lucko.luckperms.api.Contexts; -import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.api.event.events.UserFirstLoginEvent; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.core.UuidCache; @@ -72,7 +71,7 @@ public class BungeeListener extends AbstractListener implements Listener { } Contexts contexts = new Contexts( - plugin.getContextManager().giveApplicableContext(player, MutableContextSet.empty()), + plugin.getContextManager().getApplicableContext(player), plugin.getConfiguration().isIncludingGlobalPerms(), plugin.getConfiguration().isIncludingGlobalWorldPerms(), true, diff --git a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java index db85500e..a0de9743 100644 --- a/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java +++ b/common/src/main/java/me/lucko/luckperms/common/contexts/ContextManager.java @@ -22,19 +22,43 @@ package me.lucko.luckperms.common.contexts; +import com.google.common.cache.CacheBuilder; +import com.google.common.cache.CacheLoader; +import com.google.common.cache.LoadingCache; import me.lucko.luckperms.api.context.ContextListener; +import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.api.context.IContextCalculator; import me.lucko.luckperms.api.context.MutableContextSet; import java.util.List; -import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.TimeUnit; public class ContextManager { private final List> calculators = new CopyOnWriteArrayList<>(); private final List> listeners = new CopyOnWriteArrayList<>(); + private final LoadingCache cache = CacheBuilder.newBuilder() + .expireAfterWrite(50L, TimeUnit.MILLISECONDS) + .build(new CacheLoader() { + @Override + public ContextSet load(T t) { + return calculateApplicableContext(t, MutableContextSet.empty()).makeImmutable(); + } + }); + + private MutableContextSet calculateApplicableContext(T subject, MutableContextSet accumulator) { + for (IContextCalculator calculator : calculators) { + calculator.giveApplicableContext(subject, accumulator); + } + return accumulator; + } + + public ContextSet getApplicableContext(T subject) { + return cache.getUnchecked(subject); + } + public void registerCalculator(IContextCalculator calculator) { listeners.forEach(calculator::addListener); calculators.add(calculator); @@ -47,20 +71,4 @@ public class ContextManager { listeners.add(listener); } - - public MutableContextSet giveApplicableContext(T subject, MutableContextSet accumulator) { - for (IContextCalculator calculator : calculators) { - calculator.giveApplicableContext(subject, accumulator); - } - return accumulator; - } - - public boolean isContextApplicable(T subject, Map.Entry context) { - for (IContextCalculator calculator : calculators) { - if (calculator.isContextApplicable(subject, context)) { - return true; - } - } - return false; - } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java index cf902643..29830b3b 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeListener.java @@ -27,7 +27,6 @@ import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.constants.Message; import me.lucko.luckperms.common.users.User; import me.lucko.luckperms.common.utils.AbstractListener; -import me.lucko.luckperms.sponge.service.LuckPermsService; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.network.ClientConnectionEvent; @@ -76,7 +75,7 @@ public class SpongeListener extends AbstractListener { // Attempt to pre-process some permissions for the user to save time later. Might not work, but it's better than nothing. Optional p = e.getCause().first(Player.class); if (p.isPresent()) { - MutableContextSet context = plugin.getContextManager().giveApplicableContext(p.get(), MutableContextSet.empty()); + MutableContextSet context = MutableContextSet.fromSet(plugin.getContextManager().getApplicableContext(p.get())); List worlds = plugin.getGame().getServer().getWorlds().stream() .map(World::getName) @@ -84,13 +83,13 @@ public class SpongeListener extends AbstractListener { plugin.doAsync(() -> { UserData data = user.getUserData(); - data.preCalculate(plugin.getService().calculateContexts(LuckPermsService.convertContexts(context))); + data.preCalculate(plugin.getService().calculateContexts(context)); for (String world : worlds) { MutableContextSet modified = MutableContextSet.fromSet(context); modified.removeAll("world"); modified.add("world", world); - data.preCalculate(plugin.getService().calculateContexts(LuckPermsService.convertContexts(modified))); + data.preCalculate(plugin.getService().calculateContexts(modified)); } }); } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java index 92b6aa0b..b33da81d 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/migration/MigrationPermissionsEx.java @@ -129,7 +129,7 @@ public class MigrationPermissionsEx extends SubCommand { contexts.removeAll("world"); for (Map.Entry opt : e.getValue().entrySet()) { - if (opt.getKey().equalsIgnoreCase("prefix") || opt.getKey().equalsIgnoreCase("prefix")) { + if (opt.getKey().equalsIgnoreCase("prefix") || opt.getKey().equalsIgnoreCase("suffix")) { try { holder.setPermission(new Node.Builder(opt.getKey().toLowerCase() + ".100." + opt.getValue()).setServerRaw(server).setWorld(world).withExtraContext(contexts).setValue(true).build()); } catch (ObjectAlreadyHasException ignored) {} diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsGroupSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsGroupSubject.java index 751f8de9..da541a0d 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsGroupSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsGroupSubject.java @@ -23,15 +23,14 @@ package me.lucko.luckperms.sponge.service; import com.google.common.collect.ImmutableList; +import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NonNull; import me.lucko.luckperms.api.LocalizedNode; import me.lucko.luckperms.api.Node; -import me.lucko.luckperms.api.context.MutableContextSet; +import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.common.groups.Group; import org.spongepowered.api.command.CommandSource; -import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.NodeTree; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectCollection; @@ -40,26 +39,22 @@ import org.spongepowered.api.util.Tristate; import java.util.List; import java.util.Map; import java.util.Optional; -import java.util.Set; import java.util.stream.Collectors; import static me.lucko.luckperms.api.MetaUtils.unescapeCharacters; -@EqualsAndHashCode(of = "group") -public class LuckPermsGroupSubject implements Subject { +@Getter +@EqualsAndHashCode(of = "group", callSuper = false) +public class LuckPermsGroupSubject extends LuckPermsSubject { public static LuckPermsGroupSubject wrapGroup(Group group, LuckPermsService service) { return new LuckPermsGroupSubject(group, service); } - @Getter - private Group group; - + @Getter(value = AccessLevel.NONE) private LuckPermsService service; - @Getter + private Group group; private LuckPermsSubjectData subjectData; - - @Getter private LuckPermsSubjectData transientSubjectData; private LuckPermsGroupSubject(Group group, LuckPermsService service) { @@ -85,37 +80,32 @@ public class LuckPermsGroupSubject implements Subject { } @Override - public boolean hasPermission(@NonNull Set contexts, @NonNull String node) { - return getPermissionValue(contexts, node).asBoolean(); - } - - @Override - public Tristate getPermissionValue(@NonNull Set contexts, @NonNull String node) { + protected Tristate getPermissionValue(ContextSet contexts, String permission) { Map permissions = group.getAllNodesFiltered(service.calculateContexts(contexts)).stream() .map(LocalizedNode::getNode) .collect(Collectors.toMap(Node::getPermission, Node::getValue)); - Tristate t = NodeTree.of(permissions).get(node); + Tristate t = NodeTree.of(permissions).get(permission); if (t != Tristate.UNDEFINED) { return t; } - t = service.getGroupSubjects().getDefaults().getPermissionValue(contexts, node); + t = service.getGroupSubjects().getDefaults().getPermissionValue(LuckPermsService.convertContexts(contexts), permission); if (t != Tristate.UNDEFINED) { return t; } - t = service.getDefaults().getPermissionValue(contexts, node); + t = service.getDefaults().getPermissionValue(LuckPermsService.convertContexts(contexts), permission); return t; } @Override - public boolean isChildOf(@NonNull Set contexts, @NonNull Subject parent) { + public boolean isChildOf(ContextSet contexts, Subject parent) { return parent instanceof LuckPermsGroupSubject && getPermissionValue(contexts, "group." + parent.getIdentifier()).asBoolean(); } @Override - public List getParents(@NonNull Set contexts) { + public List getParents(ContextSet contexts) { List subjects = group.getAllNodesFiltered(service.calculateContexts(contexts)).stream() .map(LocalizedNode::getNode) .filter(Node::isGroupNode) @@ -123,43 +113,43 @@ public class LuckPermsGroupSubject implements Subject { .map(s -> service.getGroupSubjects().get(s)) .collect(Collectors.toList()); - subjects.addAll(service.getGroupSubjects().getDefaults().getParents(contexts)); - subjects.addAll(service.getDefaults().getParents(contexts)); + subjects.addAll(service.getGroupSubjects().getDefaults().getParents(LuckPermsService.convertContexts(contexts))); + subjects.addAll(service.getDefaults().getParents(LuckPermsService.convertContexts(contexts))); return ImmutableList.copyOf(subjects); } @Override - public Optional getOption(Set set, String s) { + public Optional getOption(ContextSet contexts, String s) { Optional option; if (s.equalsIgnoreCase("prefix")) { - option = getChatMeta(set, true); + option = getChatMeta(contexts, true); } else if (s.equalsIgnoreCase("suffix")) { - option = getChatMeta(set, false); + option = getChatMeta(contexts, false); } else { - option = getMeta(set, s); + option = getMeta(contexts, s); } if (option.isPresent()) { return option; } - option = service.getGroupSubjects().getDefaults().getOption(set, s); + option = service.getGroupSubjects().getDefaults().getOption(LuckPermsService.convertContexts(contexts), s); if (option.isPresent()) { return option; } - return service.getDefaults().getOption(set, s); + return service.getDefaults().getOption(LuckPermsService.convertContexts(contexts), s); } @Override - public Set getActiveContexts() { - return LuckPermsService.convertContexts(service.getPlugin().getContextManager().giveApplicableContext(this, MutableContextSet.empty())); + public ContextSet getActiveContextSet() { + return service.getPlugin().getContextManager().getApplicableContext(this); } - private Optional getChatMeta(Set contexts, boolean prefix) { + private Optional getChatMeta(ContextSet contexts, boolean prefix) { int priority = Integer.MIN_VALUE; String meta = null; @@ -182,7 +172,7 @@ public class LuckPermsGroupSubject implements Subject { return meta == null ? Optional.empty() : Optional.of(unescapeCharacters(meta)); } - private Optional getMeta(Set contexts, String key) { + private Optional getMeta(ContextSet contexts, String key) { for (Node n : group.getAllNodesFiltered(service.calculateContexts(contexts))) { if (!n.getValue()) { continue; 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 b140512e..18387374 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 @@ -140,9 +140,9 @@ public class LuckPermsService implements PermissionService { plugin.getContextManager().registerCalculator(new SpongeCalculatorLink(contextCalculator)); } - public Contexts calculateContexts(Set contexts) { + public Contexts calculateContexts(ContextSet contextSet) { return new Contexts( - LuckPermsService.convertContexts(contexts), + contextSet, plugin.getConfiguration().isIncludingGlobalPerms(), plugin.getConfiguration().isIncludingGlobalWorldPerms(), true, diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubject.java new file mode 100644 index 00000000..a5f08027 --- /dev/null +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsSubject.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2016 Lucko (Luck) + * + * 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.sponge.service; + +import lombok.NonNull; +import me.lucko.luckperms.api.context.ContextSet; +import org.spongepowered.api.service.context.Context; +import org.spongepowered.api.service.permission.Subject; +import org.spongepowered.api.util.Tristate; + +import java.util.List; +import java.util.Optional; +import java.util.Set; + +public abstract class LuckPermsSubject implements Subject { + + protected abstract Tristate getPermissionValue(ContextSet contexts, String permission); + protected abstract boolean isChildOf(ContextSet contexts, Subject parent); + protected abstract List getParents(ContextSet contexts); + protected abstract Optional getOption(ContextSet contexts, String s); + protected abstract ContextSet getActiveContextSet(); + + @Override + @Deprecated + public Tristate getPermissionValue(@NonNull Set contexts, @NonNull String permission) { + return getPermissionValue(LuckPermsService.convertContexts(contexts), permission); + } + + @Override + @Deprecated + public boolean hasPermission(@NonNull Set contexts, @NonNull String permission) { + return getPermissionValue(LuckPermsService.convertContexts(contexts), permission).asBoolean(); + } + + @Override + @Deprecated + public boolean hasPermission(@NonNull String permission) { + return getPermissionValue(getActiveContextSet(), permission).asBoolean(); + } + + @Override + @Deprecated + public boolean isChildOf(@NonNull Set contexts, @NonNull Subject parent) { + return isChildOf(LuckPermsService.convertContexts(contexts), parent); + } + + @Override + @Deprecated + public boolean isChildOf(@NonNull Subject parent) { + return isChildOf(getActiveContextSet(), parent); + } + + @Override + @Deprecated + public List getParents(@NonNull Set contexts) { + return getParents(LuckPermsService.convertContexts(contexts)); + } + + @Override + @Deprecated + public List getParents() { + return getParents(getActiveContextSet()); + } + + @Override + @Deprecated + public Optional getOption(@NonNull Set contexts, @NonNull String s) { + return getOption(LuckPermsService.convertContexts(contexts), s); + } + + @Override + @Deprecated + public Optional getOption(@NonNull String key) { + return getOption(getActiveContextSet(), key); + } + + @Override + @Deprecated + public Set getActiveContexts() { + return LuckPermsService.convertContexts(getActiveContextSet()); + } + +} diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsUserSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsUserSubject.java index e314a3ae..f45175ae 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsUserSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/LuckPermsUserSubject.java @@ -23,40 +23,35 @@ package me.lucko.luckperms.sponge.service; import com.google.common.collect.ImmutableList; +import lombok.AccessLevel; import lombok.EqualsAndHashCode; import lombok.Getter; -import lombok.NonNull; import me.lucko.luckperms.api.caching.MetaData; -import me.lucko.luckperms.api.context.MutableContextSet; +import me.lucko.luckperms.api.context.ContextSet; import me.lucko.luckperms.common.users.User; import org.spongepowered.api.Sponge; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; import org.spongepowered.api.service.permission.SubjectCollection; import org.spongepowered.api.util.Tristate; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.UUID; -@EqualsAndHashCode(of = "user") -public class LuckPermsUserSubject implements Subject { +@Getter +@EqualsAndHashCode(of = "user", callSuper = false) +public class LuckPermsUserSubject extends LuckPermsSubject { public static LuckPermsUserSubject wrapUser(User user, LuckPermsService service) { return new LuckPermsUserSubject(user, service); } - @Getter - private User user; - + @Getter(value = AccessLevel.NONE) private LuckPermsService service; - @Getter + private User user; private LuckPermsSubjectData subjectData; - - @Getter private LuckPermsSubjectData transientSubjectData; private LuckPermsUserSubject(User user, LuckPermsService service) { @@ -102,26 +97,19 @@ public class LuckPermsUserSubject implements Subject { } @Override - public boolean hasPermission(Set contexts, String permission) { - return getPermissionValue(contexts, permission).asBoolean(); + protected Tristate getPermissionValue(ContextSet contexts, String permission) { + return !hasData() ? + Tristate.UNDEFINED : + LuckPermsService.convertTristate(user.getUserData().getPermissionData(service.calculateContexts(contexts)).getPermissionValue(permission)); } @Override - public Tristate getPermissionValue(@NonNull Set contexts, @NonNull String permission) { - if (hasData()) { - return LuckPermsService.convertTristate(user.getUserData().getPermissionData(service.calculateContexts(contexts)).getPermissionValue(permission)); - } - - return Tristate.UNDEFINED; - } - - @Override - public boolean isChildOf(@NonNull Set contexts, @NonNull Subject parent) { + protected boolean isChildOf(ContextSet contexts, Subject parent) { return parent instanceof LuckPermsGroupSubject && getPermissionValue(contexts, "group." + parent.getIdentifier()).asBoolean(); } @Override - public List getParents(Set contexts) { + protected List getParents(ContextSet contexts) { ImmutableList.Builder subjects = ImmutableList.builder(); if (hasData()) { @@ -137,14 +125,14 @@ public class LuckPermsUserSubject implements Subject { } } - subjects.addAll(service.getUserSubjects().getDefaults().getParents(contexts)); - subjects.addAll(service.getDefaults().getParents(contexts)); + subjects.addAll(service.getUserSubjects().getDefaults().getParents(LuckPermsService.convertContexts(contexts))); + subjects.addAll(service.getDefaults().getParents(LuckPermsService.convertContexts(contexts))); return subjects.build(); } @Override - public Optional getOption(Set contexts, String s) { + protected Optional getOption(ContextSet contexts, String s) { if (hasData()) { MetaData data = user.getUserData().getMetaData(service.calculateContexts(contexts)); if (s.equalsIgnoreCase("prefix")) { @@ -164,16 +152,16 @@ public class LuckPermsUserSubject implements Subject { } } - Optional v = service.getUserSubjects().getDefaults().getOption(contexts, s); + Optional v = service.getUserSubjects().getDefaults().getOption(LuckPermsService.convertContexts(contexts), s); if (v.isPresent()) { return v; } - return service.getDefaults().getOption(contexts, s); + return service.getDefaults().getOption(LuckPermsService.convertContexts(contexts), s); } @Override - public Set getActiveContexts() { - return LuckPermsService.convertContexts(service.getPlugin().getContextManager().giveApplicableContext(this, MutableContextSet.empty())); + protected ContextSet getActiveContextSet() { + return service.getPlugin().getContextManager().getApplicableContext(this); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java index 633b8e31..a7499bda 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/persisted/PersistedSubject.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.sponge.service.persisted; import com.google.common.collect.ImmutableList; import lombok.Getter; import lombok.NonNull; -import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.common.utils.BufferedRequest; import me.lucko.luckperms.sponge.service.LuckPermsService; import org.spongepowered.api.command.CommandSource; @@ -186,6 +185,6 @@ public class PersistedSubject implements Subject { @Override public Set getActiveContexts() { - return LuckPermsService.convertContexts(service.getPlugin().getContextManager().giveApplicableContext(this, MutableContextSet.empty())); + return LuckPermsService.convertContexts(service.getPlugin().getContextManager().getApplicableContext(this)); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java b/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java index 433565cd..71a246f3 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/service/simple/SimpleSubject.java @@ -25,7 +25,6 @@ package me.lucko.luckperms.sponge.service.simple; import com.google.common.collect.ImmutableList; import lombok.Getter; import lombok.NonNull; -import me.lucko.luckperms.api.context.MutableContextSet; import me.lucko.luckperms.sponge.service.LuckPermsService; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.service.context.Context; @@ -152,6 +151,6 @@ public class SimpleSubject implements Subject { @Override public Set getActiveContexts() { - return LuckPermsService.convertContexts(service.getPlugin().getContextManager().giveApplicableContext(this, MutableContextSet.empty())); + return LuckPermsService.convertContexts(service.getPlugin().getContextManager().getApplicableContext(this)); } }