diff --git a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommand.java b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommand.java index 6901ad02..9462409e 100644 --- a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommand.java +++ b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommand.java @@ -17,4 +17,4 @@ String permissionNode() default ""; String description() default ""; -} \ No newline at end of file +} diff --git a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java index f0c27e54..a4e3ba65 100644 --- a/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java +++ b/plugin/src/main/java/org/battleplugins/arena/command/ArenaCommandExecutor.java @@ -30,9 +30,7 @@ import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import org.jetbrains.annotations.Nullable; -import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; diff --git a/plugin/src/main/java/org/battleplugins/arena/command/BaseCommandExecutor.java b/plugin/src/main/java/org/battleplugins/arena/command/BaseCommandExecutor.java index c9a0ec5b..c5c83d7a 100644 --- a/plugin/src/main/java/org/battleplugins/arena/command/BaseCommandExecutor.java +++ b/plugin/src/main/java/org/battleplugins/arena/command/BaseCommandExecutor.java @@ -1,5 +1,6 @@ package org.battleplugins.arena.command; +import io.papermc.paper.math.Position; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.event.ClickEvent; @@ -455,6 +456,30 @@ private Object verifyArgument(CommandSender sender, String arg, Class paramet return null; } } + case "position" -> { + String[] coords = arg.split(","); + if (coords.length != 3) { + return null; + } + + double x = Double.parseDouble(coords[0]); + double y = Double.parseDouble(coords[1]); + double z = Double.parseDouble(coords[2]); + + return Position.fine(x, y, z); + } + case "blockposition" -> { + String[] coords = arg.split(","); + if (coords.length != 3) { + return null; + } + + int x = Integer.parseInt(coords[0]); + int y = Integer.parseInt(coords[1]); + int z = Integer.parseInt(coords[2]); + + return Position.block(x, y, z); + } case "material" -> { try { return ItemStackParser.deserializeSingular(arg); @@ -519,6 +544,10 @@ protected boolean invalidArgument(CommandSender sender, Class parameter, Stri Messages.ARENA_DOES_NOT_EXIST.send(sender, input); return true; } + case "position", "blockposition" -> { + Messages.INVALID_POSITION.send(sender, input); + return true; + } } return false; @@ -623,6 +652,7 @@ private String getUsageString(Class parameter, @Nullable Argument argument) { case "player", "offlineplayer" -> " "; case "world" -> " "; case "arena" -> " "; + case "position", "blockposition" -> " "; default -> { for (SubCommandExecutor subCommandExecutor : this.subCommandExecutors) { String usage = subCommandExecutor.getUsageString(parameter); diff --git a/plugin/src/main/java/org/battleplugins/arena/messages/Messages.java b/plugin/src/main/java/org/battleplugins/arena/messages/Messages.java index 5fbaa29e..1e53ee73 100644 --- a/plugin/src/main/java/org/battleplugins/arena/messages/Messages.java +++ b/plugin/src/main/java/org/battleplugins/arena/messages/Messages.java @@ -47,6 +47,7 @@ public final class Messages { public static final Message AN_ERROR_OCCURRED = error("command-an-error-occurred", "An error occurred while executing this command: {}!"); public static final Message PLAYER_NOT_ONLINE = error("command-player-not-found", "The player {} could not be found!"); public static final Message INVALID_TYPE = error("command-invalid-type", "The specified type {} was not a valid {}!"); + public static final Message INVALID_POSITION = error("command-invalid-position", "The specified position ({}) is not valid! Expected format: ,,."); public static final Message CLICK_TO_PREPARE = info("command-click-to-prepare", "Click to prepare: {}"); // Arena messages