From da1b7d4c482d482d201547899411fcbc330c7abe Mon Sep 17 00:00:00 2001 From: Keuin Date: Tue, 20 Sep 2022 23:28:55 +0800 Subject: Fix: OP cannot make backups or restore with default perm level without luckperms. --- .../keuin/kbackupfabric/KBCommandsRegister.java | 27 ++++++++++++---------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java b/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java index 5ec0239..b502ad5 100644 --- a/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java +++ b/src/main/java/com/keuin/kbackupfabric/KBCommandsRegister.java @@ -9,6 +9,9 @@ import net.minecraft.server.command.CommandManager; import net.minecraft.server.command.ServerCommandSource; public final class KBCommandsRegister { + + public static final int DEFAULT_REQUIRED_LEVEL = 2; + // First make method to register public static void registerCommands(CommandDispatcher dispatcher) { @@ -24,24 +27,24 @@ public final class KBCommandsRegister { // register /kb list for showing the backup list. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("list") - .requires(Permissions.require("kb.list", 4)) + .requires(Permissions.require("kb.list", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::list))); // register /kb backup [name] for performing backup. OP is required. dispatcher.register(CommandManager.literal("kb").then(CommandManager.literal("backup").then( CommandManager.argument("backupName", StringArgumentType.greedyString()) - .requires(Permissions.require("kb.backup", 4)) + .requires(Permissions.require("kb.backup", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::primitiveBackup) - ).requires(Permissions.require("kb.backup", 4)) + ).requires(Permissions.require("kb.backup", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::primitiveBackupWithDefaultName))); // register /kb incbak [name] for performing incremental backup. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("incbak") .then(CommandManager.argument("backupName", StringArgumentType.greedyString()) - .requires(Permissions.require("kb.incbak", 4)) + .requires(Permissions.require("kb.incbak", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::incrementalBackup)) - .requires(Permissions.require("kb.incbak", 4)) + .requires(Permissions.require("kb.incbak", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::incrementalBackupWithDefaultName) )); @@ -50,9 +53,9 @@ public final class KBCommandsRegister { .then(CommandManager.literal("restore") .then(CommandManager.argument("backupName", StringArgumentType.greedyString()) .suggests(BackupNameSuggestionProvider.getProvider()) - .requires(Permissions.require("kb.restore", 4)) + .requires(Permissions.require("kb.restore", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::restore)) - .requires(Permissions.require("kb.list", 4)) + .requires(Permissions.require("kb.list", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::list))); // register /kb delete [name] for deleting an existing backup. OP is required. @@ -60,26 +63,26 @@ public final class KBCommandsRegister { .then(CommandManager.literal("delete") .then(CommandManager.argument("backupName", StringArgumentType.greedyString()) .suggests(BackupNameSuggestionProvider.getProvider()) -// .requires(Permissions.require("kb.delete", 4)) + .requires(Permissions.require("kb.delete", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::delete)) - .requires(Permissions.require("kb.delete", 4)))); + .requires(Permissions.require("kb.delete", DEFAULT_REQUIRED_LEVEL)))); // register /kb confirm for confirming the execution. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("confirm") - .requires(Permissions.require("kb.confirm", 4)) + .requires(Permissions.require("kb.confirm", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::confirm))); // register /kb cancel for cancelling the execution to be confirmed. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("cancel") - .requires(Permissions.require("kb.cancel", 4)) + .requires(Permissions.require("kb.cancel", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::cancel))); // register /kb prev for showing the latest backup. OP is required. dispatcher.register(CommandManager.literal("kb") .then(CommandManager.literal("prev") - .requires(Permissions.require("kb.prev", 4)) + .requires(Permissions.require("kb.prev", DEFAULT_REQUIRED_LEVEL)) .executes(KBCommands::prev))); // // register /kb setMethod for selecting backup method (zip, incremental) -- cgit v1.2.3