From 98d75dc7ecfd8b2c1b2b61ce806c6a33b22cf7f9 Mon Sep 17 00:00:00 2001 From: apple-juice Date: Fri, 10 Nov 2023 16:08:25 +0300 Subject: [PATCH] fix bug with parsing commands that contain a colon --- .../main/java/revxrsal/commands/bukkit/brigadier/Node.java | 6 ++++-- .../revxrsal/commands/bukkit/brigadier/PaperCommodore.java | 5 ++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/Node.java b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/Node.java index 8dbbbb1c..d338a040 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/Node.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/Node.java @@ -73,10 +73,12 @@ public void action(Command command) { public Node canBeExecuted(BukkitBrigadier brigadier) { action(a -> { - String input = stripNamespace(a.getInput()); + String input = a.getInput(); ArgumentStack args = ArgumentStack.parse( - input.startsWith("/") ? input.substring(1) : input + input.indexOf('/') == 0 ? input.substring(1) : input ); + args.set(0, stripNamespace(args.getFirst())); + CommandActor actor = brigadier.wrapSource(a.getSource()); try { brigadier.getCommandHandler().dispatch(actor, args); diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/PaperCommodore.java b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/PaperCommodore.java index 410e00a1..9a711d71 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/PaperCommodore.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/brigadier/PaperCommodore.java @@ -71,9 +71,8 @@ public final class UnknownCommandListener implements Listener { @EventHandler public void onUnknownCommand(UnknownCommandEvent event) { - ArgumentStack args = ArgumentStack.parse( - stripNamespace(fallbackPrefix, event.getCommandLine()) - ); + ArgumentStack args = ArgumentStack.parse(event.getCommandLine()); + args.set(0, stripNamespace(fallbackPrefix, args.getFirst())); if (commands.containsKey(args.getFirst())) { event.message(null); BukkitCommandActor actor = BukkitCommandActor.wrap(event.getSender(), handler);