Merge pull request #2983 from Multiverse/conditions-id

Fix command conditions not registering and lowercased
This commit is contained in:
Ben Woo 2023-08-29 12:16:17 +08:00 committed by GitHub
commit 3800513dc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 12 additions and 13 deletions

View File

@ -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("<world>")
@Description("{@@mv-core.clone.world.description}")
String worldName,
@Single
@Conditions("validWorldName:scope=new")
@Conditions("worldname:scope=new")
@Syntax("<new world name>")
@Description("{@@mv-core.clone.newWorld.description}")
String newWorldName

View File

@ -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("<name>")
@Description("{@@mv-core.create.name.description}")
String worldName,

View File

@ -39,7 +39,7 @@ public class DeleteCommand extends MultiverseCommand {
public void onDeleteCommand(BukkitCommandIssuer issuer,
@Single
@Conditions("validWorldName:scope=both")
@Conditions("worldname:scope=both")
@Syntax("<world>")
@Description("The world you want to delete.")
String worldName

View File

@ -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("<name>")
@Description("{@@mv-core.import.name.description}")
String worldName,

View File

@ -37,7 +37,7 @@ public class LoadCommand extends MultiverseCommand {
public void onLoadCommand(BukkitCommandIssuer issuer,
@Single
@Conditions("validWorldName:scope=unloaded")
@Conditions("worldname:scope=unloaded")
@Syntax("<world>")
@Description("{@@mv-core.load.world.description}")
String worldName

View File

@ -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("<world>")
@Description("{@@mv-core.regen.world.description}")
String worldName,

View File

@ -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<BukkitCommandIssuer, BukkitCommandExecutionContext, BukkitConditionContext> conditions
= commandManager.getCommandConditions();
conditions.addCondition(String.class, "validWorldName", this::checkValidWorldName);
conditions.addCondition(String.class, "worldname", this::checkWorldname);
}
private void checkValidWorldName(ConditionContext<BukkitCommandIssuer> context,
BukkitCommandExecutionContext executionContext,
String worldName
private void checkWorldname(ConditionContext<BukkitCommandIssuer> context,
BukkitCommandExecutionContext executionContext,
String worldName
) {
String scope = context.getConfigValue("scope", "loaded");