From dd5b8b1a376d880606cb94505fdb776f06eebfe1 Mon Sep 17 00:00:00 2001 From: wizjany Date: Sat, 9 Nov 2019 10:22:54 -0500 Subject: [PATCH] Fix /worldedit:xyz commands on Bukkit. (execution and completions) --- .../sk89q/worldedit/bukkit/WorldEditPlugin.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java index 614414368..3e1eb1247 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java @@ -337,7 +337,7 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = "/" + commandLabel; + split[0] = "/" + cmd.getName(); CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split)); getWorldEdit().getEventBus().post(event); @@ -351,7 +351,7 @@ public List onTabComplete(CommandSender sender, Command cmd, String comm // code of WorldEdit expects it String[] split = new String[args.length + 1]; System.arraycopy(args, 0, split, 1, args.length); - split[0] = "/" + commandLabel; + split[0] = "/" + cmd.getName(); String arguments = Joiner.on(" ").join(split); CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments); @@ -496,19 +496,24 @@ public void onAsyncTabComplete(com.destroystokyo.paper.event.server.AsyncTabComp String buffer = event.getBuffer(); int firstSpace = buffer.indexOf(' '); if (firstSpace < 0) return; - final String label = buffer.substring(0, firstSpace); + String label = buffer.substring(0, firstSpace); Plugin owner = server.getDynamicCommands().getCommandOwner(label); if (owner != WorldEditPlugin.this) { return; } + int plSep = label.indexOf(":"); + if (plSep >= 0 && plSep < label.length() + 1) { + label = "/" + label.substring(plSep + 1); + buffer = "/" + buffer.substring(plSep + 1); + } final Optional command = WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getCommandManager().getCommand(label); if (!command.isPresent()) return; - CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), event.getBuffer()); + CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), buffer); getWorldEdit().getEventBus().post(suggestEvent); - event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions())); + event.setCompletions(CommandUtil.fixSuggestions(buffer, suggestEvent.getSuggestions())); event.setHandled(true); } }