From ac4bd418f3a84ed0c988e3024a7a35f7f8832804 Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 17 Mar 2017 20:51:06 +0000 Subject: [PATCH] Rename online-mode config option to use-server-uuids to better reflect/clarify its purpose --- .../lucko/luckperms/bukkit/BukkitConfig.java | 5 ++++ bukkit/src/main/resources/config.yml | 26 ++++++++++--------- .../lucko/luckperms/bungee/BungeeConfig.java | 5 ++++ .../luckperms/bungee/BungeeListener.java | 2 +- bungee/src/main/resources/config.yml | 26 ++++++++++--------- .../delegates/LPConfigurationDelegate.java | 2 +- .../commands/impl/misc/InfoCommand.java | 2 +- .../luckperms/common/config/ConfigKeys.java | 5 +++- .../common/config/LuckPermsConfiguration.java | 2 ++ .../luckperms/common/constants/Message.java | 2 +- .../luckperms/common/core/UuidCache.java | 10 +++---- .../common/utils/AbstractListener.java | 2 +- default-lang.yml | 2 +- .../lucko/luckperms/sponge/SpongeConfig.java | 19 +++++++++----- sponge/src/main/resources/luckperms.conf | 23 +++++++++------- 15 files changed, 81 insertions(+), 52 deletions(-) diff --git a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitConfig.java b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitConfig.java index 0154c0ccc..3822fee51 100644 --- a/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitConfig.java +++ b/bukkit/src/main/java/me/lucko/luckperms/bukkit/BukkitConfig.java @@ -57,6 +57,11 @@ public class BukkitConfig extends AbstractConfiguration { configuration = YamlConfiguration.loadConfiguration(configFile); } + @Override + public boolean contains(String path) { + return configuration.contains(path, true); + } + @Override public String getString(String path, String def) { return configuration.getString(path, def); diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 618820100..7a0f6195a 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -26,22 +26,24 @@ 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. +# If UUIDs should be pulled from the server, or looked up by username based upon previous connections. # -# You should generally reflect the setting in server.properties here. Except when... +# This option should be set to true in most cases. When set to false, in order to get a player's UUID, LuckPerms will: +# 1. Check if a player with the given username has joined before, if they have, use the UUID they used on their previous login. +# 2. Save and return the players "current" uuid. # -# 1. You have Spigot servers connected to a BungeeCord proxy, with online-mode set to false, but 'bungeecord' set to true in the spigot.yml -# AND 'ip-forward' set to true in the BungeeCord config.yml -# In this case, set online-mode in LuckPerms to true, despite the server being in offline mode. +# For offline mode (cracked) servers, a players UUID is generated based upon their username. # -# 2. You are only running one server instance using LuckPerms, (not a network) -# In this case, set online-mode to true no matter what is set in server.properties. (we can just fallback to the servers uuid cache) +# IMPORTANT: +# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" is set in server.properties, but +# "bungeecord: true" is set in the spigot.yml. You also need to set "ip_forward: true" in BungeeCord's config.yml. +# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you may need to set "use-server-uuids" to false. # -# 3. If your proxy is running in offline mode, and you are using PaperSpigot (https://ci.destroystokyo.com/job/PaperSpigot/), -# you should set "bungee-online-mode" to false in the paper.yml, and set "online-mode" to true in all LuckPerms configs. -# This approach is thoroughly recommended for offline mode networks. -online-mode: true +# If your proxy is running in offline mode, you should still be setting up ip-forwarding as described above, but may also find that you need to set +# "bungee-online-mode" to false in paper.yml, if you are using PaperSpigot. (https://ci.destroystokyo.com/job/PaperSpigot/) +# +# This option only really exists for networks who for whatever reason cannot setup proper ip forwarding. +use-server-uuids: true # If the plugin should send log notifications to users whenever permissions are modified. log-notify: true diff --git a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java index 2e6b2fa87..c13440d0f 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeConfig.java @@ -72,6 +72,11 @@ public class BungeeConfig extends AbstractConfiguration { } } + @Override + public boolean contains(String path) { + return configuration.contains(path); + } + @Override public String getString(String path, String def) { return configuration.getString(path, def); 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 bd43ae685..143a025cd 100644 --- a/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java +++ b/bungee/src/main/java/me/lucko/luckperms/bungee/BungeeListener.java @@ -101,7 +101,7 @@ public class BungeeListener extends AbstractListener implements Listener { final UuidCache cache = plugin.getUuidCache(); final PendingConnection c = e.getConnection(); - if (!plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) { + if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) { UUID uuid = plugin.getStorage().getUUID(c.getName()).join(); if (uuid != null) { cache.addToCache(c.getUniqueId(), uuid); diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index 2f75a6824..b918ddd2f 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -26,22 +26,24 @@ 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. +# If UUIDs should be pulled from the server, or looked up by username based upon previous connections. # -# You should generally reflect the setting in server.properties here. Except when... +# This option should be set to true in most cases. When set to false, in order to get a player's UUID, LuckPerms will: +# 1. Check if a player with the given username has joined before, if they have, use the UUID they used on their previous login. +# 2. Save and return the players "current" uuid. # -# 1. You have Spigot servers connected to a BungeeCord proxy, with online-mode set to false, but 'bungeecord' set to true in the spigot.yml -# AND 'ip-forward' set to true in the BungeeCord config.yml -# In this case, set online-mode in LuckPerms to true, despite the server being in offline mode. +# For offline mode (cracked) servers, a players UUID is generated based upon their username. # -# 2. You are only running one server instance using LuckPerms, (not a network) -# In this case, set online-mode to true no matter what is set in server.properties. (we can just fallback to the servers uuid cache) +# IMPORTANT: +# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" is set all backend server.properties, but +# "bungeecord: true" is set in the spigot.yml. You also need to set "ip_forward: true" in BungeeCord's config.yml. +# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you may need to set "use-server-uuids" to false. # -# 3. If your proxy is running in offline mode, and you are using PaperSpigot (https://ci.destroystokyo.com/job/PaperSpigot/), -# you should set "bungee-online-mode" to false in the paper.yml, and set "online-mode" to true in all LuckPerms configs. -# This approach is thoroughly recommended for offline mode networks. -online-mode: true +# If your proxy is running in offline mode, you should still be setting up ip-forwarding as described above, but may also find that you need to set +# "bungee-online-mode" to false in paper.yml, if you are using PaperSpigot. (https://ci.destroystokyo.com/job/PaperSpigot/) +# +# This option should always be set to true on the BungeeCord side. Don't change unless you're sure you know what you're doing. +use-server-uuids: true # If the plugin should send log notifications to users whenever permissions are modified. log-notify: true diff --git a/common/src/main/java/me/lucko/luckperms/common/api/delegates/LPConfigurationDelegate.java b/common/src/main/java/me/lucko/luckperms/common/api/delegates/LPConfigurationDelegate.java index 9cd5c51be..8bff53bc8 100644 --- a/common/src/main/java/me/lucko/luckperms/common/api/delegates/LPConfigurationDelegate.java +++ b/common/src/main/java/me/lucko/luckperms/common/api/delegates/LPConfigurationDelegate.java @@ -70,7 +70,7 @@ public class LPConfigurationDelegate implements LPConfiguration { @Override public boolean getOnlineMode() { - return master.get(ConfigKeys.ONLINE_MODE); + return master.get(ConfigKeys.USE_SERVER_UUIDS); } @Override diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java index fc4ee9bcc..d6a67156f 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/misc/InfoCommand.java @@ -77,7 +77,7 @@ public class InfoCommand extends SingleCommand { plugin.getPreProcessContexts(false).size(), plugin.getContextManager().getCalculatorsSize(), plugin.getPermissionVault().getSize(), - formatBoolean(c.get(ConfigKeys.ONLINE_MODE)), + formatBoolean(c.get(ConfigKeys.USE_SERVER_UUIDS)), formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_PERMS)), formatBoolean(c.get(ConfigKeys.INCLUDING_GLOBAL_WORLD_PERMS)), formatBoolean(c.get(ConfigKeys.APPLYING_GLOBAL_GROUPS)), 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 e8f03563a..4c233ec1c 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 @@ -58,7 +58,10 @@ public class ConfigKeys { public static final ConfigKey INCLUDING_GLOBAL_WORLD_PERMS = BooleanKey.of("include-global-world", true); public static final ConfigKey APPLYING_GLOBAL_GROUPS = BooleanKey.of("apply-global-groups", true); public static final ConfigKey APPLYING_GLOBAL_WORLD_GROUPS = BooleanKey.of("apply-global-world-groups", true); - public static final ConfigKey ONLINE_MODE = BooleanKey.of("online-mode", true); + public static final ConfigKey USE_SERVER_UUIDS = AbstractKey.of(c -> { + // backwards compatible with the old online-mode option + return c.contains("use-server-uuids") ? c.getBoolean("use-server-uuids", true) : c.getBoolean("online-mode", true); + }); public static final ConfigKey TEMPORARY_ADD_BEHAVIOUR = AbstractKey.of(c -> { String option = c.getString("temporary-add-behaviour", "deny").toLowerCase(); if (!option.equals("deny") && !option.equals("replace") && !option.equals("accumulate")) { diff --git a/common/src/main/java/me/lucko/luckperms/common/config/LuckPermsConfiguration.java b/common/src/main/java/me/lucko/luckperms/common/config/LuckPermsConfiguration.java index 76a60377d..fe5811222 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/LuckPermsConfiguration.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/LuckPermsConfiguration.java @@ -40,6 +40,8 @@ public interface LuckPermsConfiguration { void loadAll(); + boolean contains(String path); + String getString(String path, String def); int getInt(String path, int def); diff --git a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java b/common/src/main/java/me/lucko/luckperms/common/constants/Message.java index 83b2baf29..4fa3c47c2 100644 --- a/common/src/main/java/me/lucko/luckperms/common/constants/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/constants/Message.java @@ -170,7 +170,7 @@ public enum Message { "{PREFIX}&f- &3Context Calculators: &a{14}" + "\n" + "{PREFIX}&f- &3Unique permissions: &a{15}" + "\n" + "{PREFIX}&f- &bConfiguration:" + "\n" + - "{PREFIX}&f- &3Online Mode: {16}" + "\n" + + "{PREFIX}&f- &3Use Server UUIDs: {16}" + "\n" + "{PREFIX}&f- &bPermission Calculation:" + "\n" + "{PREFIX}&f- &3Including Global: {17}" + "\n" + "{PREFIX}&f- &3Including Global World: {18}" + "\n" + diff --git a/common/src/main/java/me/lucko/luckperms/common/core/UuidCache.java b/common/src/main/java/me/lucko/luckperms/common/core/UuidCache.java index 90c1c27f5..5d82ef877 100644 --- a/common/src/main/java/me/lucko/luckperms/common/core/UuidCache.java +++ b/common/src/main/java/me/lucko/luckperms/common/core/UuidCache.java @@ -49,25 +49,25 @@ public class UuidCache { private final UuidCacheDelegate delegate = new UuidCacheDelegate(this); public UUID getUUID(UUID external) { - return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? external : cache.getOrDefault(external, external); + return plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS) ? external : cache.getOrDefault(external, external); } public UUID getExternalUUID(UUID internal) { - return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? internal : cache.inverse().getOrDefault(internal, internal); + return plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS) ? internal : cache.inverse().getOrDefault(internal, internal); } public void addToCache(UUID external, UUID internal) { - if (plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) return; + if (plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) return; cache.forcePut(external, internal); } public void clearCache(UUID external) { - if (plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) return; + if (plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) return; cache.remove(external); } public int getSize() { - return plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE) ? 0 : cache.size(); + return plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS) ? 0 : cache.size(); } } diff --git a/common/src/main/java/me/lucko/luckperms/common/utils/AbstractListener.java b/common/src/main/java/me/lucko/luckperms/common/utils/AbstractListener.java index 6969aefc3..36b284df1 100644 --- a/common/src/main/java/me/lucko/luckperms/common/utils/AbstractListener.java +++ b/common/src/main/java/me/lucko/luckperms/common/utils/AbstractListener.java @@ -43,7 +43,7 @@ public class AbstractListener { final long startTime = System.currentTimeMillis(); final UuidCache cache = plugin.getUuidCache(); - if (!plugin.getConfiguration().get(ConfigKeys.ONLINE_MODE)) { + if (!plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUIDS)) { UUID uuid = plugin.getStorage().force().getUUID(username).join(); if (uuid != null) { cache.addToCache(u, uuid); diff --git a/default-lang.yml b/default-lang.yml index 259448dd8..5cbe4c380 100644 --- a/default-lang.yml +++ b/default-lang.yml @@ -124,7 +124,7 @@ info: > {PREFIX}&f- &3Context Calculators: &a{14}\n {PREFIX}&f- &3Unique permissions: &a{15}\n {PREFIX}&f- &bConfiguration:\n - {PREFIX}&f- &3Online Mode: {16}\n + {PREFIX}&f- &3Use Server UUIDs: {16}\n {PREFIX}&f- &bPermission Calculation:\n {PREFIX}&f- &3Including Global: {17}\n {PREFIX}&f- &3Including Global World: {18}\n diff --git a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeConfig.java b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeConfig.java index a88864d61..780e0d6bb 100644 --- a/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeConfig.java +++ b/sponge/src/main/java/me/lucko/luckperms/sponge/SpongeConfig.java @@ -79,7 +79,7 @@ public class SpongeConfig extends AbstractConfiguration { } } - private ConfigurationNode getNode(String path) { + private ConfigurationNode resolvePath(String path) { Iterable paths = Splitter.on('.').split(path); ConfigurationNode node = root; @@ -90,24 +90,29 @@ public class SpongeConfig extends AbstractConfiguration { return node; } + @Override + public boolean contains(String path) { + return !resolvePath(path).isVirtual(); + } + @Override public String getString(String path, String def) { - return getNode(path).getString(def); + return resolvePath(path).getString(def); } @Override public int getInt(String path, int def) { - return getNode(path).getInt(def); + return resolvePath(path).getInt(def); } @Override public boolean getBoolean(String path, boolean def) { - return getNode(path).getBoolean(def); + return resolvePath(path).getBoolean(def); } @Override public List getList(String path, List def) { - ConfigurationNode node = getNode(path); + ConfigurationNode node = resolvePath(path); if (node.isVirtual()) { return def; } @@ -117,7 +122,7 @@ public class SpongeConfig extends AbstractConfiguration { @Override public List getObjectList(String path, List def) { - ConfigurationNode node = getNode(path); + ConfigurationNode node = resolvePath(path); if (node.isVirtual()) { return def; } @@ -128,7 +133,7 @@ public class SpongeConfig extends AbstractConfiguration { @SuppressWarnings("unchecked") @Override public Map getMap(String path, Map def) { - ConfigurationNode node = getNode(path); + ConfigurationNode node = resolvePath(path); if (node.isVirtual()) { return def; } diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 19ef6dfb8..3eb26bc96 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -26,18 +26,23 @@ 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. +# If UUIDs should be pulled from the server, or looked up by username based upon previous connections. # -# You should generally reflect the setting in server.properties here. Except when... +# This option should be set to true in most cases. When set to false, in order to get a player's UUID, LuckPerms will: +# 1. Check if a player with the given username has joined before, if they have, use the UUID they used on their previous login. +# 2. Save and return the players "current" uuid. # -# 1. You have Sponge servers connected to a BungeeCord proxy, with online-mode set to false, but 'bungeecord ip-forwarding' -# set to true in the sponge/global.conf AND 'ip-forward' set to true in the BungeeCord config.yml -# In this case, set online-mode in LuckPerms to true, despite the server being in offline mode. +# For offline mode (cracked) servers, a players UUID is generated based upon their username. # -# 2. You are only running one server instance using LuckPerms, (not a network) In this case, set online-mode to true no -# matter what is set in server.properties. (we can just fallback to the servers uuid cache) -online-mode=true +# IMPORTANT: +# If you are using BungeeCord proxy running in online mode, it is important that "online-mode=false" is set in server.properties, but +# "bungeecord.ip-forwarding=true" is set in Sponge's global.conf. You also need to set "ip_forward: true" in BungeeCord's config.yml. +# If for whatever reason you are not able to do this, and do not have ip-forward enabled, then you may need to set "use-server-uuids" to false. +# +# If your proxy is running in offline mode, you should still be setting up ip-forwarding as described above. +# +# This option only really exists for networks who for whatever reason cannot setup proper ip forwarding. +use-server-uuids=true # If the plugin should send log notifications to users whenever permissions are modified. log-notify=true