From 754c7d8e3b2ff78d7f609652c5faccc3d7b81426 Mon Sep 17 00:00:00 2001 From: Luck Date: Mon, 4 Sep 2017 17:03:17 +0100 Subject: [PATCH] Add config option to prevent primary group removal (#405) --- bukkit/src/main/resources/config.yml | 4 ++++ bungee/src/main/resources/config.yml | 4 ++++ .../common/commands/impl/generic/parent/ParentRemove.java | 3 ++- .../java/me/lucko/luckperms/common/config/ConfigKeys.java | 6 ++++++ sponge/src/main/resources/luckperms.conf | 4 ++++ 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 76cd1df8d..568c2e8f5 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -105,6 +105,10 @@ temporary-add-behaviour: deny # directly and indirectly primary-group-calculation: stored +# If set to false, the plugin will allow a Users primary group to be removed with the +# 'parent remove' command, and will set their primary group back to default. +prevent-primary-group-removal: false + # If the plugin should check for "extra" permissions with users run LP commands. # # These extra permissions allow finer control over what users can do with each command, and diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index f6cb03711..708cdf4e3 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -108,6 +108,10 @@ temporary-add-behaviour: deny # directly and indirectly primary-group-calculation: stored +# If set to false, the plugin will allow a Users primary group to be removed with the +# 'parent remove' command, and will set their primary group back to default. +prevent-primary-group-removal: false + # If the plugin should check for "extra" permissions with users run LP commands. # # These extra permissions allow finer control over what users can do with each command, and diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java index 6cd111fba..2111168ad 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/impl/generic/parent/ParentRemove.java @@ -79,7 +79,8 @@ public class ParentRemove extends SharedSubCommand { if (holder instanceof User) { User user = (User) holder; - boolean shouldPrevent = (context.isEmpty() || context.has("server", "global")) && + boolean shouldPrevent = plugin.getConfiguration().get(ConfigKeys.PREVENT_PRIMARY_GROUP_REMOVAL) && + context.isEmpty() && plugin.getConfiguration().get(ConfigKeys.PRIMARY_GROUP_CALCULATION_METHOD).equals("stored") && user.getPrimaryGroup().getStoredValue().equalsIgnoreCase(groupName); 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 0845c9f4c..e5985c66e 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 @@ -166,6 +166,12 @@ public class ConfigKeys { } })); + /** + * If set to false, the plugin will allow a Users primary group to be removed with the + * 'parent remove' command, and will set their primary group back to default. + */ + public static final ConfigKey PREVENT_PRIMARY_GROUP_REMOVAL = BooleanKey.of("prevent-primary-group-removal", true); + /** * If the plugin should check for "extra" permissions with users run LP commands */ diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 866ee5297..ec8cd8c51 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -106,6 +106,10 @@ temporary-add-behaviour="deny" # directly and indirectly primary-group-calculation="parents-by-weight" +# If set to false, the plugin will allow a Users primary group to be removed with the +# 'parent remove' command, and will set their primary group back to default. +prevent-primary-group-removal=false + # If the plugin should check for "extra" permissions with users run LP commands. # # These extra permissions allow finer control over what users can do with each command, and