From 8cc126f71160ba2d475ac5abad43a8fc9daabc99 Mon Sep 17 00:00:00 2001 From: Luck Date: Thu, 9 Dec 2021 21:31:17 +0000 Subject: [PATCH] Add config option to disable bulkupdate functionality --- bukkit/src/main/resources/config.yml | 6 ++++++ bungee/src/main/resources/config.yml | 6 ++++++ .../luckperms/common/commands/misc/BulkUpdateCommand.java | 5 +++++ .../java/me/lucko/luckperms/common/config/ConfigKeys.java | 5 +++++ .../java/me/lucko/luckperms/common/locale/Message.java | 7 +++++++ common/src/main/resources/luckperms_en.properties | 1 + fabric/src/main/resources/luckperms.conf | 6 ++++++ nukkit/src/main/resources/config.yml | 6 ++++++ sponge/src/main/resources/luckperms.conf | 6 ++++++ velocity/src/main/resources/config.yml | 6 ++++++ 10 files changed, 54 insertions(+) diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index a31dc3060..cb1167ece 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -687,6 +687,12 @@ allow-invalid-usernames: false # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation: false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate: false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default. diff --git a/bungee/src/main/resources/config.yml b/bungee/src/main/resources/config.yml index 53a2bd837..d90c33588 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -589,6 +589,12 @@ allow-invalid-usernames: false # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation: false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate: false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default. diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java index 85feafb78..7c6b63d15 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/BulkUpdateCommand.java @@ -64,6 +64,11 @@ public class BulkUpdateCommand extends SingleCommand { @Override public void execute(LuckPermsPlugin plugin, Sender sender, ArgumentList args, String label) throws CommandException { + if (plugin.getConfiguration().get(ConfigKeys.DISABLE_BULKUPDATE)) { + Message.BULK_UPDATE_DISABLED.send(sender); + return; + } + if (!sender.isConsole()) { Message.BULK_UPDATE_MUST_USE_CONSOLE.send(sender); return; 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 11eee3e89..970ca9760 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 @@ -164,6 +164,11 @@ public final class ConfigKeys { */ public static final ConfigKey SKIP_BULKUPDATE_CONFIRMATION = booleanKey("skip-bulkupdate-confirmation", false); + /** + * If LuckPerms should prevent bulkupdate operations. + */ + public static final ConfigKey DISABLE_BULKUPDATE = booleanKey("disable-bulkupdate", false); + /** * If LuckPerms should produce extra logging output when it handles logins. */ diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java index 20da8fa5e..6976bd500 100644 --- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java +++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java @@ -2662,6 +2662,13 @@ public interface Message { .append(FULL_STOP) ); + Args0 BULK_UPDATE_DISABLED = () -> prefixed(translatable() + // "&cBulk update functionality is disabled in the configuration file." + .key("luckperms.command.bulkupdate.disabled") + .color(RED) + .append(FULL_STOP) + ); + Args0 BULK_UPDATE_MUST_USE_CONSOLE = () -> prefixed(translatable() // "&cThe bulk update command can only be used from the console." .key("luckperms.command.bulkupdate.must-use-console") diff --git a/common/src/main/resources/luckperms_en.properties b/common/src/main/resources/luckperms_en.properties index e85b99eef..c587e836d 100644 --- a/common/src/main/resources/luckperms_en.properties +++ b/common/src/main/resources/luckperms_en.properties @@ -324,6 +324,7 @@ luckperms.command.import.progress.operations={0}/{1} operations complete luckperms.command.import.starting=Starting import process luckperms.command.import.completed=COMPLETED luckperms.command.import.duration=took {0} seconds +luckperms.command.bulkupdate.disabled=Bulk update functionality is disabled in the configuration file luckperms.command.bulkupdate.must-use-console=The bulk update command can only be used from the console luckperms.command.bulkupdate.invalid-data-type=Invalid type, was expecting {0} luckperms.command.bulkupdate.invalid-constraint=Invalid constraint {0} diff --git a/fabric/src/main/resources/luckperms.conf b/fabric/src/main/resources/luckperms.conf index f875e3e5a..73c0825c0 100644 --- a/fabric/src/main/resources/luckperms.conf +++ b/fabric/src/main/resources/luckperms.conf @@ -620,6 +620,12 @@ allow-invalid-usernames = false # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation = false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate = false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default. diff --git a/nukkit/src/main/resources/config.yml b/nukkit/src/main/resources/config.yml index 6d9e2d068..a20e4fe03 100644 --- a/nukkit/src/main/resources/config.yml +++ b/nukkit/src/main/resources/config.yml @@ -631,6 +631,12 @@ allow-invalid-usernames: true # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation: false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate: false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default. diff --git a/sponge/src/main/resources/luckperms.conf b/sponge/src/main/resources/luckperms.conf index 0f58a2775..ac04c48ba 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -607,6 +607,12 @@ allow-invalid-usernames = false # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation = false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate = false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default. diff --git a/velocity/src/main/resources/config.yml b/velocity/src/main/resources/config.yml index 7321eabf5..e6eb8c7d8 100644 --- a/velocity/src/main/resources/config.yml +++ b/velocity/src/main/resources/config.yml @@ -575,6 +575,12 @@ allow-invalid-usernames: false # - If automation is needed, users should prefer using the LuckPerms API. skip-bulkupdate-confirmation: false +# If LuckPerms should prevent bulkupdate operations. +# +# - When set to true, bulkupdate operations (the /lp bulkupdate command) will not work. +# - When set to false, bulkupdate operations will be allowed via the console. +disable-bulkupdate: false + # If LuckPerms should allow a users primary group to be removed with the 'parent remove' command. # # - When this happens, the plugin will set their primary group back to default.