From dcd041e84775a9c219199fd7c34640eae484c3a7 Mon Sep 17 00:00:00 2001 From: IronApollo Date: Thu, 1 Nov 2018 07:22:50 -0400 Subject: [PATCH] Potential fix for CommandSuggestionEvent errors --- .../boydti/fawe/bukkit/listener/ATabCompleteListener.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java index 9b772fc14..04a66c2c2 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/listener/ATabCompleteListener.java @@ -6,6 +6,7 @@ import com.sk89q.worldedit.event.platform.CommandSuggestionEvent; import com.sk89q.worldedit.extension.platform.CommandManager; import com.sk89q.worldedit.util.command.CommandMapping; import com.sk89q.worldedit.util.command.Dispatcher; + import org.bukkit.command.CommandSender; import org.bukkit.event.Listener; @@ -23,11 +24,12 @@ public class ATabCompleteListener implements Listener { MutableCharSequence mBuffer = MutableCharSequence.getTemporal(); mBuffer.setString(buffer); mBuffer.setSubstring(0, firstSpace); - String label = buffer.substring(mBuffer.indexOf(':') + 1, firstSpace); + int index; + String label = buffer.substring(index = (mBuffer.indexOf(':') == -1 ? 1 : mBuffer.indexOf(':') + 1), firstSpace); Dispatcher dispatcher = CommandManager.getInstance().getDispatcher(); CommandMapping weCommand = dispatcher.get(label); if (weCommand != null) { - CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer); + CommandSuggestionEvent event = new CommandSuggestionEvent(worldEdit.wrapCommandSender(sender), buffer.substring(index, buffer.length())); worldEdit.getWorldEdit().getEventBus().post(event); List suggestions = event.getSuggestions(); if (suggestions != null) {