diff --git a/bukkit/src/main/resources/config.yml b/bukkit/src/main/resources/config.yml index 0743e764b..7fc20df99 100644 --- a/bukkit/src/main/resources/config.yml +++ b/bukkit/src/main/resources/config.yml @@ -660,6 +660,14 @@ debug-logins: false # or less. allow-invalid-usernames: false +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation: 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 6ec95ca34..27d5655f5 100644 --- a/bungee/src/main/resources/config.yml +++ b/bungee/src/main/resources/config.yml @@ -563,6 +563,14 @@ debug-logins: false # or less. allow-invalid-usernames: false +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation: 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 33607c20f..88cbe348e 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 @@ -45,6 +45,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission; import me.lucko.luckperms.common.command.spec.CommandSpec; import me.lucko.luckperms.common.command.utils.ArgumentException; import me.lucko.luckperms.common.command.utils.ArgumentList; +import me.lucko.luckperms.common.config.ConfigKeys; import me.lucko.luckperms.common.locale.Message; import me.lucko.luckperms.common.plugin.LuckPermsPlugin; import me.lucko.luckperms.common.sender.Sender; @@ -77,20 +78,7 @@ public class BulkUpdateCommand extends SingleCommand { return CommandResult.INVALID_ARGS; } - Message.BULK_UPDATE_STARTING.send(sender); - plugin.getStorage().applyBulkUpdate(operation).whenCompleteAsync((v, ex) -> { - if (ex == null) { - plugin.getSyncTaskBuffer().requestDirectly(); - Message.BULK_UPDATE_SUCCESS.send(sender); - if (operation.isTrackingStatistics()) { - BulkUpdateStatistics stats = operation.getStatistics(); - Message.BULK_UPDATE_STATISTICS.send(sender, stats.getAffectedNodes(), stats.getAffectedUsers(), stats.getAffectedGroups()); - } - } else { - ex.printStackTrace(); - Message.BULK_UPDATE_FAILURE.send(sender); - } - }, plugin.getBootstrap().getScheduler().async()); + runOperation(operation, plugin, sender); return CommandResult.SUCCESS; } @@ -155,15 +143,35 @@ public class BulkUpdateCommand extends SingleCommand { bulkUpdateBuilder.query(Query.of(field, Constraint.of(comparison, expr))); } - String id = String.format("%04d", ThreadLocalRandom.current().nextInt(10000)); - BulkUpdate bulkUpdate = bulkUpdateBuilder.build(); - this.pendingOperations.put(id, bulkUpdate); + if (plugin.getConfiguration().get(ConfigKeys.SKIP_BULKUPDATE_CONFIRMATION)) { + runOperation(bulkUpdate, plugin, sender); + } else { + String id = String.format("%04d", ThreadLocalRandom.current().nextInt(10000)); + this.pendingOperations.put(id, bulkUpdate); - Message.BULK_UPDATE_QUEUED.send(sender, bulkUpdate.buildAsSql().toReadableString().replace("{table}", bulkUpdate.getDataType().getName())); - Message.BULK_UPDATE_CONFIRM.send(sender, label, id); + Message.BULK_UPDATE_QUEUED.send(sender, bulkUpdate.buildAsSql().toReadableString().replace("{table}", bulkUpdate.getDataType().getName())); + Message.BULK_UPDATE_CONFIRM.send(sender, label, id); + } return CommandResult.SUCCESS; } + + private static void runOperation(BulkUpdate operation, LuckPermsPlugin plugin, Sender sender) { + Message.BULK_UPDATE_STARTING.send(sender); + plugin.getStorage().applyBulkUpdate(operation).whenCompleteAsync((v, ex) -> { + if (ex == null) { + plugin.getSyncTaskBuffer().requestDirectly(); + Message.BULK_UPDATE_SUCCESS.send(sender); + if (operation.isTrackingStatistics()) { + BulkUpdateStatistics stats = operation.getStatistics(); + Message.BULK_UPDATE_STATISTICS.send(sender, stats.getAffectedNodes(), stats.getAffectedUsers(), stats.getAffectedGroups()); + } + } else { + ex.printStackTrace(); + Message.BULK_UPDATE_FAILURE.send(sender); + } + }, plugin.getBootstrap().getScheduler().async()); + } } 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 d7f0ea797..1c4a27204 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 @@ -156,6 +156,11 @@ public final class ConfigKeys { */ public static final ConfigKey ALLOW_INVALID_USERNAMES = booleanKey("allow-invalid-usernames", false); + /** + * If LuckPerms should not require users to confirm bulkupdate operations. + */ + public static final ConfigKey SKIP_BULKUPDATE_CONFIRMATION = booleanKey("skip-bulkupdate-confirmation", false); + /** * If LuckPerms should produce extra logging output when it handles logins. */ diff --git a/fabric/src/main/resources/luckperms.conf b/fabric/src/main/resources/luckperms.conf index 1c51e2d97..fe8b50d12 100644 --- a/fabric/src/main/resources/luckperms.conf +++ b/fabric/src/main/resources/luckperms.conf @@ -570,6 +570,14 @@ debug-logins = false # or less. allow-invalid-usernames = false +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation = 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 7278086c8..efd7686ff 100644 --- a/nukkit/src/main/resources/config.yml +++ b/nukkit/src/main/resources/config.yml @@ -604,6 +604,14 @@ debug-logins: false # or less. allow-invalid-usernames: true +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation: 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 0b7a41d60..26c596ba6 100644 --- a/sponge/src/main/resources/luckperms.conf +++ b/sponge/src/main/resources/luckperms.conf @@ -581,6 +581,14 @@ debug-logins = false # or less. allow-invalid-usernames = false +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation = 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 c67ff5dec..382476b8d 100644 --- a/velocity/src/main/resources/config.yml +++ b/velocity/src/main/resources/config.yml @@ -549,6 +549,14 @@ debug-logins: false # or less. allow-invalid-usernames: false +# If LuckPerms should not require users to confirm bulkupdate operations. +# +# - When set to true, operations will be executed immediately. +# - This is not recommended, as bulkupdate has the potential to irreversibly delete large amounts of +# data, and is not designed to be executed automatically. +# - If automation is needed, users should prefer using the LuckPerms API. +skip-bulkupdate-confirmation: 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.