diff --git a/bukkit/src/main/java/me/lucko/luckperms/api/vault/VaultChatHook.java b/bukkit/src/main/java/me/lucko/luckperms/api/vault/VaultChatHook.java index 8e6395e9..ed5cc09e 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/api/vault/VaultChatHook.java +++ b/bukkit/src/main/java/me/lucko/luckperms/api/vault/VaultChatHook.java @@ -30,6 +30,7 @@ import me.lucko.luckperms.core.PermissionHolder; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.users.User; +import me.lucko.luckperms.utils.Contexts; import net.milkbowl.vault.chat.Chat; import java.util.Iterator; @@ -162,7 +163,7 @@ public class VaultChatHook extends Chat { int priority = Integer.MIN_VALUE; String meta = null; - for (Node n : holder.getAllNodes(null)) { + for (Node n : holder.getAllNodes(null, Contexts.allowAll())) { if (!n.getValue()) { continue; } diff --git a/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java b/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java index 25d79ad7..6f910100 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java +++ b/bukkit/src/main/java/me/lucko/luckperms/users/BukkitUser.java @@ -28,6 +28,7 @@ import me.lucko.luckperms.LPBukkitPlugin; import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent; import me.lucko.luckperms.api.implementation.internal.UserLink; import me.lucko.luckperms.inject.LPPermissible; +import me.lucko.luckperms.utils.Contexts; import org.bukkit.permissions.Permissible; import java.util.Collections; @@ -53,18 +54,23 @@ public class BukkitUser extends User { @SuppressWarnings("unchecked") @Override - public void refreshPermissions() { + public synchronized void refreshPermissions() { if (lpPermissible == null) { return; } // Calculate the permissions that should be applied. This is done async, who cares about how long it takes or how often it's done. Map toApply = exportNodes( - getPlugin().getConfiguration().getServer(), - plugin.getUserManager().getWorldCache().get(getUuid()), - null, - plugin.getConfiguration().getIncludeGlobalPerms(), - true, + new Contexts( + getPlugin().getConfiguration().getServer(), + plugin.getUserManager().getWorldCache().get(getUuid()), + null, + getPlugin().getConfiguration().getIncludeGlobalPerms(), + getPlugin().getConfiguration().getIncludeGlobalWorldPerms(), + true, + getPlugin().getConfiguration().getApplyGlobalGroups(), + getPlugin().getConfiguration().getApplyGlobalWorldGroups() + ), Collections.emptyList() ); diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 5588efae..abe0514a 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -8,9 +8,20 @@ # The name of the server, used for server specific permissions. Set to 'global' to disable. server: global -# If users on this server should have their global permissions/groups applied. +# If users on this server should have their global permissions applied. +# If set to false, only server specific permissions will apply for users on this server include-global: true +# If users on this server should have their global world permissions applied. +# If set to false, only world specific permissions will apply for users on this server +include-global-world: true + +# If users on this server should have global (non-server specific) groups applied +apply-global-groups: true + +# If users on this server should have global (non-world specific) groups applied +apply-global-world-groups: true + # If this server is in offline or online mode. # This setting allows a player to have the same UUID across a network of offline mode/mixed servers. diff --git a/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java b/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java index 634125fa..09c90c04 100644 --- a/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java +++ b/bungee/src/main/java/me/lucko/luckperms/users/BungeeUser.java @@ -26,6 +26,7 @@ import me.lucko.luckperms.BungeePlayerCache; import me.lucko.luckperms.LPBungeePlugin; import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent; import me.lucko.luckperms.api.implementation.internal.UserLink; +import me.lucko.luckperms.utils.Contexts; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.util.Collections; @@ -46,7 +47,7 @@ public class BungeeUser extends User { } @Override - public void refreshPermissions() { + public synchronized void refreshPermissions() { ProxiedPlayer player = plugin.getProxy().getPlayer(plugin.getUuidCache().getExternalUUID(getUuid())); if (player == null) { return; @@ -61,11 +62,16 @@ public class BungeeUser extends User { // Calculate the permissions that should be applied. This is done async. Map toApply = exportNodes( - plugin.getConfiguration().getServer(), - server, - null, - plugin.getConfiguration().getIncludeGlobalPerms(), - true, + new Contexts( + plugin.getConfiguration().getServer(), + server, + null, + plugin.getConfiguration().getIncludeGlobalPerms(), + plugin.getConfiguration().getIncludeGlobalWorldPerms(), + true, + plugin.getConfiguration().getApplyGlobalGroups(), + plugin.getConfiguration().getApplyGlobalWorldGroups() + ), Collections.emptyList() ); diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index e0d65651..7a4b8e3e 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -8,9 +8,20 @@ # The name of the server, used for server specific permissions. Set to 'global' to disable. server: bungee -# If users on this server should have their global permissions/groups applied. +# If users on this server should have their global permissions applied. +# If set to false, only server specific permissions will apply for users on this server include-global: false +# If users on this server should have their global world permissions applied. +# If set to false, only world specific permissions will apply for users on this server +include-global-world: true + +# If users on this server should have global (non-server specific) groups applied +apply-global-groups: true + +# If users on this server should have global (non-world specific) groups applied +apply-global-world-groups: true + # If this server is in offline or online mode. # This setting allows a player to have the same UUID across a network of offline mode/mixed servers. diff --git a/common/src/main/java/me/lucko/luckperms/api/implementation/internal/PermissionHolderLink.java b/common/src/main/java/me/lucko/luckperms/api/implementation/internal/PermissionHolderLink.java index 2cbf0016..8e085e7c 100644 --- a/common/src/main/java/me/lucko/luckperms/api/implementation/internal/PermissionHolderLink.java +++ b/common/src/main/java/me/lucko/luckperms/api/implementation/internal/PermissionHolderLink.java @@ -29,6 +29,7 @@ import me.lucko.luckperms.api.PermissionHolder; import me.lucko.luckperms.api.Tristate; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; +import me.lucko.luckperms.utils.Contexts; import java.util.*; @@ -67,7 +68,7 @@ public class PermissionHolderLink implements PermissionHolder { @Override public Set getAllNodes() { - return Collections.unmodifiableSet(master.getAllNodes(null)); + return Collections.unmodifiableSet(master.getAllNodes(Collections.emptyList(), Contexts.allowAll())); } @Override @@ -252,7 +253,7 @@ public class PermissionHolderLink implements PermissionHolder { @Override public Map getPermissions(String server, String world, Map extraContext, boolean includeGlobal, List possibleNodes, boolean applyGroups) { - return master.exportNodes(server, world, extraContext, includeGlobal, applyGroups, possibleNodes); + return master.exportNodes(new Contexts(server, world, extraContext, includeGlobal, includeGlobal, applyGroups, true, true), possibleNodes); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupChatMeta.java b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupChatMeta.java index 868293a8..cef6a637 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/commands/group/subcommands/GroupChatMeta.java @@ -28,6 +28,7 @@ import me.lucko.luckperms.commands.*; import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Permission; import me.lucko.luckperms.groups.Group; +import me.lucko.luckperms.utils.Contexts; import java.util.*; @@ -42,7 +43,7 @@ public class GroupChatMeta extends SubCommand { SortedSet> prefixes = new TreeSet<>(Util.getMetaComparator().reversed()); SortedSet> suffixes = new TreeSet<>(Util.getMetaComparator().reversed()); - for (Node node : group.getAllNodes(null)) { + for (Node node : group.getAllNodes(null, Contexts.allowAll())) { if (!node.isSuffix() && !node.isPrefix()) { continue; } diff --git a/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java index b7039895..d711bbf5 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/commands/misc/InfoCommand.java @@ -49,6 +49,9 @@ public class InfoCommand extends SingleMainCommand { c.getServer(), c.getSyncTime(), formatBoolean(c.getIncludeGlobalPerms()), + formatBoolean(c.getIncludeGlobalWorldPerms()), + formatBoolean(c.getApplyGlobalGroups()), + formatBoolean(c.getApplyGlobalWorldGroups()), formatBoolean(c.getOnlineMode()), formatBoolean(c.getApplyWildcards()), formatBoolean(c.getApplyRegex()), diff --git a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserChatMeta.java b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserChatMeta.java index 2e47f7b0..395390b7 100644 --- a/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserChatMeta.java +++ b/common/src/main/java/me/lucko/luckperms/commands/user/subcommands/UserChatMeta.java @@ -28,6 +28,7 @@ import me.lucko.luckperms.commands.*; import me.lucko.luckperms.constants.Message; import me.lucko.luckperms.constants.Permission; import me.lucko.luckperms.users.User; +import me.lucko.luckperms.utils.Contexts; import java.util.AbstractMap.SimpleEntry; import java.util.List; @@ -46,7 +47,7 @@ public class UserChatMeta extends SubCommand { SortedSet> prefixes = new TreeSet<>(Util.getMetaComparator().reversed()); SortedSet> suffixes = new TreeSet<>(Util.getMetaComparator().reversed()); - for (Node node : user.getAllNodes(null)) { + for (Node node : user.getAllNodes(null, Contexts.allowAll())) { if (!node.isSuffix() && !node.isPrefix()) { continue; } diff --git a/common/src/main/java/me/lucko/luckperms/constants/Message.java b/common/src/main/java/me/lucko/luckperms/constants/Message.java index 5dd483e2..31b73b19 100644 --- a/common/src/main/java/me/lucko/luckperms/constants/Message.java +++ b/common/src/main/java/me/lucko/luckperms/constants/Message.java @@ -127,7 +127,10 @@ public enum Message { PREFIX + "&f-> &eStorage Method: &6%s" + "\n" + PREFIX + "&f-> &eServer Name: &6%s" + "\n" + PREFIX + "&f-> &eSync Interval: &6%s minutes" + "\n" + - PREFIX + "&f-> &eInclude Global Perms: &6%s" + "\n" + + PREFIX + "&f-> &eInclude Global: &6%s" + "\n" + + PREFIX + "&f-> &eInclude Global World: &6%s" + "\n" + + PREFIX + "&f-> &eApply Global Groups: &6%s" + "\n" + + PREFIX + "&f-> &eApply Global World Groups: &6%s" + "\n" + PREFIX + "&f-> &eOnline Mode: &6%s" + "\n" + PREFIX + "&f-> &eApply Wildcards: &6%s" + "\n" + PREFIX + "&f-> &eApply Regex: &6%s" + "\n" + diff --git a/common/src/main/java/me/lucko/luckperms/core/LPConfiguration.java b/common/src/main/java/me/lucko/luckperms/core/LPConfiguration.java index 46672908..54034dd2 100644 --- a/common/src/main/java/me/lucko/luckperms/core/LPConfiguration.java +++ b/common/src/main/java/me/lucko/luckperms/core/LPConfiguration.java @@ -91,6 +91,18 @@ public abstract class LPConfiguration { return getBoolean("include-global", defaultIncludeGlobal); } + public boolean getIncludeGlobalWorldPerms() { + return getBoolean("include-global-world", true); + } + + public boolean getApplyGlobalGroups() { + return getBoolean("apply-global-groups", true); + } + + public boolean getApplyGlobalWorldGroups() { + return getBoolean("apply-global-world-groups", true); + } + public boolean getOnlineMode() { return getBoolean("online-mode", true); } diff --git a/common/src/main/java/me/lucko/luckperms/core/PermissionHolder.java b/common/src/main/java/me/lucko/luckperms/core/PermissionHolder.java index 532a175e..6076d2ff 100644 --- a/common/src/main/java/me/lucko/luckperms/core/PermissionHolder.java +++ b/common/src/main/java/me/lucko/luckperms/core/PermissionHolder.java @@ -36,6 +36,7 @@ import me.lucko.luckperms.api.implementation.internal.PermissionHolderLink; import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.groups.Group; +import me.lucko.luckperms.utils.Contexts; import java.util.*; import java.util.concurrent.ConcurrentHashMap; @@ -143,7 +144,7 @@ public abstract class PermissionHolder { * @param excludedGroups a list of groups to exclude * @return a set of nodes */ - public SortedSet getAllNodes(List excludedGroups) { + public SortedSet getAllNodes(List excludedGroups, Contexts context) { SortedSet all = getPermissions(true); if (excludedGroups == null) { @@ -152,13 +153,27 @@ public abstract class PermissionHolder { excludedGroups.add(getObjectName().toLowerCase()); - Set parents = getPermissions(true).stream() + Set parents = getPermissions(true).stream() .filter(Node::isGroupNode) - .map(Node::getGroupName) .collect(Collectors.toSet()); - for (String parent : parents) { - Group group = plugin.getGroupManager().get(parent); + Iterator iterator = parents.iterator(); + while (iterator.hasNext()) { + Node node = iterator.next(); + + if (!node.shouldApplyOnServer(context.getServer(), context.isApplyGlobalGroups(), plugin.getConfiguration().getApplyRegex())) { + iterator.remove(); + continue; + } + + if (!node.shouldApplyOnWorld(context.getWorld(), context.isApplyGlobalWorldGroups(), plugin.getConfiguration().getApplyRegex())) { + iterator.remove(); + continue; + } + } + + for (Node parent : parents) { + Group group = plugin.getGroupManager().get(parent.getGroupName()); if (group == null) { continue; } @@ -168,7 +183,7 @@ public abstract class PermissionHolder { } inherited: - for (Node inherited : group.getAllNodes(excludedGroups)) { + for (Node inherited : group.getAllNodes(excludedGroups, context)) { for (Node existing : all) { if (existing.almostEquals(inherited)) { continue inherited; @@ -184,34 +199,30 @@ public abstract class PermissionHolder { /** * Gets all of the nodes that this holder has (and inherits), given the context - * @param server the server - * @param world the world - * @param extraContext any extra context to filter by - * @param includeGlobal whether to include global nodes - * @param applyGroups if inherited group permissions should be included + * @param context the context for this request * @return a map of permissions */ - public Set getAllNodesFiltered(String server, String world, Map extraContext, boolean includeGlobal, boolean applyGroups) { + public Set getAllNodesFiltered(Contexts context) { Set perms = ConcurrentHashMap.newKeySet(); SortedSet allNodes; - if (applyGroups) { - allNodes = getAllNodes(null); + if (context.isApplyGroups()) { + allNodes = getAllNodes(null, context); } else { allNodes = getPermissions(true); } all: for (Node node : allNodes) { - if (!node.shouldApplyOnServer(server, includeGlobal, plugin.getConfiguration().getApplyRegex())) { + if (!node.shouldApplyOnServer(context.getServer(), context.isIncludeGlobal(), plugin.getConfiguration().getApplyRegex())) { continue; } - if (!node.shouldApplyOnWorld(world, includeGlobal, plugin.getConfiguration().getApplyRegex())) { + if (!node.shouldApplyOnWorld(context.getWorld(), context.isIncludeGlobalWorld(), plugin.getConfiguration().getApplyRegex())) { continue; } - if (!node.shouldApplyWithContext(extraContext)) { + if (!node.shouldApplyWithContext(context.getExtraContext())) { continue; } @@ -229,19 +240,15 @@ public abstract class PermissionHolder { } /** - * Converts the output of {@link #getAllNodesFiltered(String, String, Map, boolean, boolean)}, and expands wildcards/regex/shorthand perms - * @param server the server - * @param world the world - * @param extraContext any extra context to filter by - * @param includeGlobal whether to include global nodes - * @param applyGroups if inherited group permissions should be included + * Converts the output of {@link #getAllNodesFiltered(Contexts)}, and expands wildcards/regex/shorthand perms + * @param context the context for this request * @param possibleNodes a list of possible nodes for wildcards and regex permissions * @return a map of permissions */ - public Map exportNodes(String server, String world, Map extraContext, boolean includeGlobal, boolean applyGroups, List possibleNodes) { + public Map exportNodes(Contexts context, List possibleNodes) { Map perms = new HashMap<>(); - for (Node node : getAllNodesFiltered(server, world, extraContext, includeGlobal, applyGroups)) { + for (Node node : getAllNodesFiltered(context)) { if (node.getPermission().equals("*") || node.getPermission().equals("'*'")) { if (possibleNodes != null && plugin.getConfiguration().getApplyWildcards()) { possibleNodes.forEach(n -> perms.put(n, true)); @@ -356,7 +363,7 @@ public abstract class PermissionHolder { * @return a tristate */ public Tristate inheritsPermission(Node node) { - return hasPermission(getAllNodes(null), node); + return hasPermission(getAllNodes(null, Contexts.allowAll()), node); } public boolean inheritsPermission(String node, boolean b) { @@ -539,18 +546,24 @@ public abstract class PermissionHolder { /* * Don't use these methods, only here for compat reasons */ + @Deprecated public Map getLocalPermissions(String server, String world, List excludedGroups, List possibleNodes) { - return exportNodes(server, world, null, plugin.getConfiguration().getIncludeGlobalPerms(), true, possibleNodes); + return exportNodes(new Contexts(server, world, Collections.emptyMap(), plugin.getConfiguration().getIncludeGlobalPerms(), true, true, true, true), Collections.emptyList()); } + @Deprecated public Map getLocalPermissions(String server, String world, List excludedGroups) { - return exportNodes(server, world, null, plugin.getConfiguration().getIncludeGlobalPerms(), true, null); + return exportNodes(new Contexts(server, world, Collections.emptyMap(), plugin.getConfiguration().getIncludeGlobalPerms(), true, true, true, true), Collections.emptyList()); } + @SuppressWarnings("deprecation") + @Deprecated public Map getLocalPermissions(String server, List excludedGroups, List possibleNodes) { return getLocalPermissions(server, null, excludedGroups, possibleNodes); } + @SuppressWarnings("deprecation") + @Deprecated public Map getLocalPermissions(String server, List excludedGroups) { return getLocalPermissions(server, null, excludedGroups, null); } diff --git a/common/src/main/java/me/lucko/luckperms/utils/Contexts.java b/common/src/main/java/me/lucko/luckperms/utils/Contexts.java new file mode 100644 index 00000000..0a07783d --- /dev/null +++ b/common/src/main/java/me/lucko/luckperms/utils/Contexts.java @@ -0,0 +1,61 @@ +/* + * 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.utils; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import me.lucko.luckperms.core.LPConfiguration; + +import java.util.Collections; +import java.util.Map; + +@Getter +@AllArgsConstructor +public class Contexts { + public static Contexts fromConfig(LPConfiguration configuration) { + return new Contexts( + configuration.getServer(), + null, + Collections.emptyMap(), + configuration.getIncludeGlobalPerms(), + configuration.getIncludeGlobalWorldPerms(), + true, + configuration.getApplyGlobalGroups(), + configuration.getApplyGlobalWorldGroups() + ); + } + + public static Contexts allowAll() { + return new Contexts(null, null, Collections.emptyMap(), true, true, true, true, true); + } + + private final String server; + private final String world; + private final Map extraContext; + private final boolean includeGlobal; + private final boolean includeGlobalWorld; + private final boolean applyGroups; + private final boolean applyGlobalGroups; + private final boolean applyGlobalWorldGroups; + +} diff --git a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsSubject.java b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsSubject.java index 29e8c18c..99aa7089 100644 --- a/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsSubject.java +++ b/sponge/src/main/java/me/lucko/luckperms/api/sponge/LuckPermsSubject.java @@ -35,6 +35,7 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException; import me.lucko.luckperms.exceptions.ObjectLacksException; import me.lucko.luckperms.groups.Group; import me.lucko.luckperms.users.User; +import me.lucko.luckperms.utils.Contexts; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.service.context.Context; import org.spongepowered.api.service.permission.Subject; @@ -203,7 +204,7 @@ public class LuckPermsSubject implements Subject { int priority = Integer.MIN_VALUE; String meta = null; - for (Node n : holder.getAllNodes(null)) { + for (Node n : holder.getAllNodes(null, Contexts.allowAll())) { if (!n.getValue()) { continue; } @@ -343,7 +344,7 @@ public class LuckPermsSubject implements Subject { public Map, List> getAllParents() { Map, List> parents = new HashMap<>(); - for (Node n : holder.getAllNodes(null)) { + for (Node n : holder.getAllNodes(null, Contexts.allowAll())) { if (!n.isGroupNode()) { continue; } @@ -470,7 +471,7 @@ public class LuckPermsSubject implements Subject { public Map, Map> getAllOptions() { Map, Map> options = new HashMap<>(); - for (Node n : holder.getAllNodes(null)) { + for (Node n : holder.getAllNodes(null, Contexts.allowAll())) { if (!n.isMeta()) { continue; } 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 6c5ef6f9..4e38f75d 100644 --- a/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java +++ b/sponge/src/main/java/me/lucko/luckperms/users/SpongeUser.java @@ -27,6 +27,7 @@ import me.lucko.luckperms.api.event.events.UserPermissionRefreshEvent; import me.lucko.luckperms.api.implementation.internal.UserLink; import me.lucko.luckperms.api.sponge.LuckPermsUserSubject; import me.lucko.luckperms.api.sponge.collections.UserCollection; +import me.lucko.luckperms.utils.Contexts; import java.util.Collections; import java.util.Map; @@ -46,7 +47,7 @@ class SpongeUser extends User { } @Override - public void refreshPermissions() { + public synchronized void refreshPermissions() { UserCollection uc = plugin.getService().getUserSubjects(); if (!uc.getUsers().containsKey(getUuid())) { return; @@ -54,11 +55,16 @@ class SpongeUser extends User { // Calculate the permissions that should be applied. This is done async, who cares about how long it takes or how often it's done. Map toApply = exportNodes( - getPlugin().getConfiguration().getServer(), - null, // TODO per world perms - null, - plugin.getConfiguration().getIncludeGlobalPerms(), - true, + new Contexts( + plugin.getConfiguration().getServer(), + null, // TODO per world perms + null, + plugin.getConfiguration().getIncludeGlobalPerms(), + plugin.getConfiguration().getIncludeGlobalWorldPerms(), + true, + plugin.getConfiguration().getApplyGlobalGroups(), + plugin.getConfiguration().getApplyGlobalWorldGroups() + ), Collections.emptyList() ); diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index e2ba1114..f7350935 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -8,9 +8,20 @@ # The name of the server, used for server specific permissions. Set to 'global' to disable. server="global" -# If users on this server should have their global permissions/groups applied. +# If users on this server should have their global permissions applied. +# If set to false, only server specific permissions will apply for users on this server include-global=true +# If users on this server should have their global world permissions applied. +# If set to false, only world specific permissions will apply for users on this server +include-global-world=true + +# If users on this server should have global (non-server specific) groups applied +apply-global-groups=true + +# If users on this server should have global (non-world specific) groups applied +apply-global-world-groups=true + # If this server is in offline or online mode. # This setting allows a player to have the same UUID across a network of offline mode/mixed servers.