diff --git a/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java b/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java index b3e305a41..cd6807cb1 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java +++ b/common/src/main/java/me/lucko/luckperms/commands/CommandManager.java @@ -177,8 +177,7 @@ public class CommandManager { } private void sendCommandUsage(Sender sender, String label) { - sender.sendMessage(Util.color("&6Running &bLuckPerms v" + plugin.getVersion() + "&6.")); - + Util.sendPluginMessage(sender, "&6Running &bLuckPerms v" + plugin.getVersion() + "&6."); mainCommands.stream() .filter(c -> c.isAuthorized(sender)) .forEach(c -> Util.sendPluginMessage(sender, "&e-> &d" + String.format(c.getUsage(), label))); diff --git a/common/src/main/java/me/lucko/luckperms/contexts/ServerCalculator.java b/common/src/main/java/me/lucko/luckperms/contexts/ServerCalculator.java index b4f1ef391..7d541a760 100644 --- a/common/src/main/java/me/lucko/luckperms/contexts/ServerCalculator.java +++ b/common/src/main/java/me/lucko/luckperms/contexts/ServerCalculator.java @@ -39,6 +39,6 @@ public class ServerCalculator extends ContextCalculator { @Override public boolean isContextApplicable(T subject, Map.Entry context) { - return context.getKey().equals("server") && server.equals(context.getValue()); + return context.getKey().equals("server") && server.equalsIgnoreCase(context.getValue()); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java index 6e4fbd24c..34484f769 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsUserSubject.java @@ -39,6 +39,7 @@ import org.spongepowered.api.util.Tristate; import java.util.*; import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Function; import java.util.stream.Collectors; public class LuckPermsUserSubject extends LuckPermsSubject { @@ -62,7 +63,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject { @Override public Tristate getPermissionValue(@NonNull Set contexts, @NonNull String permission) { Map context = contexts.stream().collect(Collectors.toMap(Context::getKey, Context::getValue)); - ContextData cd = contextData.computeIfAbsent(context, this::calculatePermissions); + ContextData cd = contextData.computeIfAbsent(context, map -> calculatePermissions(map, false)); me.lucko.luckperms.api.Tristate t = cd.getPermissionValue(permission); if (t != me.lucko.luckperms.api.Tristate.UNDEFINED) { @@ -72,7 +73,7 @@ public class LuckPermsUserSubject extends LuckPermsSubject { } } - public ContextData calculatePermissions(Map context) { + public ContextData calculatePermissions(Map context, boolean apply) { Map toApply = user.exportNodes( new Contexts( context, @@ -88,7 +89,9 @@ public class LuckPermsUserSubject extends LuckPermsSubject { ContextData existing = contextData.get(context); if (existing == null) { existing = new ContextData(this, context, service); - contextData.put(context, existing); + if (apply) { + contextData.put(context, existing); + } } boolean different = false; @@ -113,13 +116,13 @@ public class LuckPermsUserSubject extends LuckPermsSubject { return existing; } - public void calculatePermissions(Set contexts) { + public void calculatePermissions(Set contexts, boolean apply) { Map context = contexts.stream().collect(Collectors.toMap(Context::getKey, Context::getValue)); - calculatePermissions(context); + calculatePermissions(context, apply); } - public void calculateActivePermissions() { - calculatePermissions(getActiveContexts()); + public void calculateActivePermissions(boolean apply) { + calculatePermissions(getActiveContexts(), apply); } diff --git a/sponge/src/main/java/me/lucko/luckperms/contexts/ContextUpdateTask.java b/sponge/src/main/java/me/lucko/luckperms/contexts/ContextUpdateTask.java index 1b7638542..373385eda 100644 --- a/sponge/src/main/java/me/lucko/luckperms/contexts/ContextUpdateTask.java +++ b/sponge/src/main/java/me/lucko/luckperms/contexts/ContextUpdateTask.java @@ -38,7 +38,7 @@ public class ContextUpdateTask implements Runnable { public void run() { for (LuckPermsUserSubject subject : userCollection.getUsers().values()) { Set> contexts = new HashSet<>(subject.getContextData().keySet()); - contexts.forEach(subject::calculatePermissions); + contexts.forEach(map -> subject.calculatePermissions(map, true)); } } diff --git a/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java b/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java index 37b3610cf..641ba65c2 100644 --- a/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java +++ b/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java @@ -49,6 +49,6 @@ class SpongeUser extends User { } LuckPermsUserSubject us = uc.getUsers().get(getUuid()); - us.calculateActivePermissions(); + us.calculateActivePermissions(true); } }