mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-05 18:39:40 +01:00
Add 'skip-bulkupdate-confirmation' config option (#2980)
This commit is contained in:
parent
e219237e44
commit
07f672ae1f
@ -660,6 +660,14 @@ debug-logins: false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames: false
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
@ -563,6 +563,14 @@ debug-logins: false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames: false
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
@ -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.spec.CommandSpec;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentException;
|
import me.lucko.luckperms.common.command.utils.ArgumentException;
|
||||||
import me.lucko.luckperms.common.command.utils.ArgumentList;
|
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.locale.Message;
|
||||||
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
|
||||||
import me.lucko.luckperms.common.sender.Sender;
|
import me.lucko.luckperms.common.sender.Sender;
|
||||||
@ -77,20 +78,7 @@ public class BulkUpdateCommand extends SingleCommand {
|
|||||||
return CommandResult.INVALID_ARGS;
|
return CommandResult.INVALID_ARGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message.BULK_UPDATE_STARTING.send(sender);
|
runOperation(operation, plugin, 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());
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,15 +143,35 @@ public class BulkUpdateCommand extends SingleCommand {
|
|||||||
bulkUpdateBuilder.query(Query.of(field, Constraint.of(comparison, expr)));
|
bulkUpdateBuilder.query(Query.of(field, Constraint.of(comparison, expr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = String.format("%04d", ThreadLocalRandom.current().nextInt(10000));
|
|
||||||
|
|
||||||
BulkUpdate bulkUpdate = bulkUpdateBuilder.build();
|
BulkUpdate bulkUpdate = bulkUpdateBuilder.build();
|
||||||
|
|
||||||
|
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);
|
this.pendingOperations.put(id, bulkUpdate);
|
||||||
|
|
||||||
Message.BULK_UPDATE_QUEUED.send(sender, bulkUpdate.buildAsSql().toReadableString().replace("{table}", bulkUpdate.getDataType().getName()));
|
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_CONFIRM.send(sender, label, id);
|
||||||
|
}
|
||||||
|
|
||||||
return CommandResult.SUCCESS;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -156,6 +156,11 @@ public final class ConfigKeys {
|
|||||||
*/
|
*/
|
||||||
public static final ConfigKey<Boolean> ALLOW_INVALID_USERNAMES = booleanKey("allow-invalid-usernames", false);
|
public static final ConfigKey<Boolean> ALLOW_INVALID_USERNAMES = booleanKey("allow-invalid-usernames", false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If LuckPerms should not require users to confirm bulkupdate operations.
|
||||||
|
*/
|
||||||
|
public static final ConfigKey<Boolean> SKIP_BULKUPDATE_CONFIRMATION = booleanKey("skip-bulkupdate-confirmation", false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If LuckPerms should produce extra logging output when it handles logins.
|
* If LuckPerms should produce extra logging output when it handles logins.
|
||||||
*/
|
*/
|
||||||
|
@ -570,6 +570,14 @@ debug-logins = false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames = false
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
@ -604,6 +604,14 @@ debug-logins: false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames: true
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
@ -581,6 +581,14 @@ debug-logins = false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames = false
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
@ -549,6 +549,14 @@ debug-logins: false
|
|||||||
# or less.
|
# or less.
|
||||||
allow-invalid-usernames: false
|
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.
|
# 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.
|
# - When this happens, the plugin will set their primary group back to default.
|
||||||
|
Loading…
Reference in New Issue
Block a user