From 87a13cf7297911da647e7652b40578d58c2843a9 Mon Sep 17 00:00:00 2001 From: Christopher Bohn Date: Mon, 12 Feb 2024 23:34:11 -0800 Subject: [PATCH] Add border command to Forge --- .../java/org/popcraft/chunky/ChunkyForge.java | 22 +++++++++++++++++++ .../org/popcraft/chunky/ChunkyNeoForge.java | 22 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/forge/src/main/java/org/popcraft/chunky/ChunkyForge.java b/forge/src/main/java/org/popcraft/chunky/ChunkyForge.java index 23af6c3c..4a97f43c 100644 --- a/forge/src/main/java/org/popcraft/chunky/ChunkyForge.java +++ b/forge/src/main/java/org/popcraft/chunky/ChunkyForge.java @@ -40,6 +40,7 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.DimensionArgument.dimension; +import static net.minecraft.commands.arguments.EntityArgument.player; @Mod(ChunkyForge.MOD_ID) public class ChunkyForge { @@ -139,6 +140,27 @@ public void onRegisterCommands(final RegisterCommandsEvent event) { registerArguments(command, literal(CommandLiteral.WORLDBORDER)); registerArguments(command, literal(CommandLiteral.WORLD), argument(CommandLiteral.WORLD, dimension())); + final LiteralArgumentBuilder borderCommand = literal(CommandLiteral.BORDER) + .requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER)) + .executes(command.getCommand()); + registerArguments(borderCommand, literal(CommandLiteral.ADD), + argument(CommandLiteral.WORLD, dimension()), + argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES), + argument(CommandLiteral.CENTER_X, word()), + argument(CommandLiteral.CENTER_Z, word()), + argument(CommandLiteral.RADIUS_X, word()), + argument(CommandLiteral.RADIUS_Z, word())); + registerArguments(borderCommand, literal(CommandLiteral.BYPASS), + argument(CommandLiteral.PLAYER, player())); + registerArguments(borderCommand, literal(CommandLiteral.HELP)); + registerArguments(borderCommand, literal(CommandLiteral.LIST)); + registerArguments(borderCommand, literal(CommandLiteral.LOAD), + argument(CommandLiteral.WORLD, dimension())); + registerArguments(borderCommand, literal(CommandLiteral.REMOVE), + argument(CommandLiteral.WORLD, dimension())); + registerArguments(borderCommand, literal(CommandLiteral.WRAP), + argument(CommandLiteral.WRAP, word())); + registerArguments(command, borderCommand); event.getDispatcher().register(command); } diff --git a/neoforge/src/main/java/org/popcraft/chunky/ChunkyNeoForge.java b/neoforge/src/main/java/org/popcraft/chunky/ChunkyNeoForge.java index 1fc3b758..e4f251e0 100644 --- a/neoforge/src/main/java/org/popcraft/chunky/ChunkyNeoForge.java +++ b/neoforge/src/main/java/org/popcraft/chunky/ChunkyNeoForge.java @@ -40,6 +40,7 @@ import static net.minecraft.commands.Commands.argument; import static net.minecraft.commands.Commands.literal; import static net.minecraft.commands.arguments.DimensionArgument.dimension; +import static net.minecraft.commands.arguments.EntityArgument.player; @Mod(ChunkyNeoForge.MOD_ID) public class ChunkyNeoForge { @@ -139,6 +140,27 @@ public void onRegisterCommands(final RegisterCommandsEvent event) { registerArguments(command, literal(CommandLiteral.WORLDBORDER)); registerArguments(command, literal(CommandLiteral.WORLD), argument(CommandLiteral.WORLD, dimension())); + final LiteralArgumentBuilder borderCommand = literal(CommandLiteral.BORDER) + .requires(serverCommandSource -> chunky != null && chunky.getCommands().containsKey(CommandLiteral.BORDER)) + .executes(command.getCommand()); + registerArguments(borderCommand, literal(CommandLiteral.ADD), + argument(CommandLiteral.WORLD, dimension()), + argument(CommandLiteral.SHAPE, string()).suggests(SuggestionProviders.SHAPES), + argument(CommandLiteral.CENTER_X, word()), + argument(CommandLiteral.CENTER_Z, word()), + argument(CommandLiteral.RADIUS_X, word()), + argument(CommandLiteral.RADIUS_Z, word())); + registerArguments(borderCommand, literal(CommandLiteral.BYPASS), + argument(CommandLiteral.PLAYER, player())); + registerArguments(borderCommand, literal(CommandLiteral.HELP)); + registerArguments(borderCommand, literal(CommandLiteral.LIST)); + registerArguments(borderCommand, literal(CommandLiteral.LOAD), + argument(CommandLiteral.WORLD, dimension())); + registerArguments(borderCommand, literal(CommandLiteral.REMOVE), + argument(CommandLiteral.WORLD, dimension())); + registerArguments(borderCommand, literal(CommandLiteral.WRAP), + argument(CommandLiteral.WRAP, word())); + registerArguments(command, borderCommand); event.getDispatcher().register(command); }