From 0ddb5563bea3f705a9b165d5ff2b292910922ebb Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Tue, 29 Aug 2023 10:54:22 +0800 Subject: [PATCH] Fix command conditions not registering and lowercased --- .../MultiverseCore/commands/CloneCommand.java | 4 ++-- .../MultiverseCore/commands/CreateCommand.java | 2 +- .../MultiverseCore/commands/DeleteCommand.java | 2 +- .../MultiverseCore/commands/ImportCommand.java | 2 +- .../MultiverseCore/commands/LoadCommand.java | 2 +- .../MultiverseCore/commands/RegenCommand.java | 2 +- .../commandtools/MVCommandConditions.java | 11 +++++------ 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java index b8f7fe02..64cb954b 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CloneCommand.java @@ -36,13 +36,13 @@ public class CloneCommand extends MultiverseCommand { @Description("{@@mv-core.clone.description}") public void onCloneCommand(CommandIssuer issuer, - @Conditions("validWorldName:scope=both") + @Conditions("worldname:scope=both") @Syntax("") @Description("{@@mv-core.clone.world.description}") String worldName, @Single - @Conditions("validWorldName:scope=new") + @Conditions("worldname:scope=new") @Syntax("") @Description("{@@mv-core.clone.newWorld.description}") String newWorldName diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java index d4d8ea2b..f339aff1 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/CreateCommand.java @@ -100,7 +100,7 @@ public class CreateCommand extends MultiverseCommand { @Description("{@@mv-core.create.description}") public void onCreateCommand(BukkitCommandIssuer issuer, - @Conditions("validWorldName:scope=new") + @Conditions("worldname:scope=new") @Syntax("") @Description("{@@mv-core.create.name.description}") String worldName, diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java index cf21e1c4..4a1f1c51 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DeleteCommand.java @@ -39,7 +39,7 @@ public class DeleteCommand extends MultiverseCommand { public void onDeleteCommand(BukkitCommandIssuer issuer, @Single - @Conditions("validWorldName:scope=both") + @Conditions("worldname:scope=both") @Syntax("") @Description("The world you want to delete.") String worldName diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java index d938d018..6e5d6efb 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ImportCommand.java @@ -69,7 +69,7 @@ public class ImportCommand extends MultiverseCommand { @Description("{@@mv-core.import.description") public void onImportCommand(BukkitCommandIssuer issuer, - @Conditions("validWorldName:scope=new") + @Conditions("worldname:scope=new") @Syntax("") @Description("{@@mv-core.import.name.description}") String worldName, diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java index 9097d485..17849902 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/LoadCommand.java @@ -37,7 +37,7 @@ public class LoadCommand extends MultiverseCommand { public void onLoadCommand(BukkitCommandIssuer issuer, @Single - @Conditions("validWorldName:scope=unloaded") + @Conditions("worldname:scope=unloaded") @Syntax("") @Description("{@@mv-core.load.world.description}") String worldName diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java index 43013835..1ff18614 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/RegenCommand.java @@ -56,7 +56,7 @@ public class RegenCommand extends MultiverseCommand { @Description("{@@mv-core.regen.description}") public void onRegenCommand(BukkitCommandIssuer issuer, - @Conditions("validWorldName:scope=both") + @Conditions("worldname:scope=both") @Syntax("") @Description("{@@mv-core.regen.world.description}") String worldName, diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java index c639f362..273d793d 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandConditions.java @@ -8,7 +8,6 @@ import co.aikar.commands.ConditionContext; import co.aikar.commands.ConditionFailedException; import com.onarandombox.MultiverseCore.api.MVWorldManager; import com.onarandombox.MultiverseCore.world.WorldNameChecker; -import jakarta.annotation.PostConstruct; import org.jetbrains.annotations.NotNull; public class MVCommandConditions { @@ -22,19 +21,19 @@ public class MVCommandConditions { private MVCommandConditions(@NotNull MVCommandManager commandManager, @NotNull MVWorldManager worldManager) { this.worldManager = worldManager; this.commandManager = commandManager; + registerConditions(); } - @PostConstruct private void registerConditions() { CommandConditions conditions = commandManager.getCommandConditions(); - conditions.addCondition(String.class, "validWorldName", this::checkValidWorldName); + conditions.addCondition(String.class, "worldname", this::checkWorldname); } - private void checkValidWorldName(ConditionContext context, - BukkitCommandExecutionContext executionContext, - String worldName + private void checkWorldname(ConditionContext context, + BukkitCommandExecutionContext executionContext, + String worldName ) { String scope = context.getConfigValue("scope", "loaded");