diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/CraftServer.java | 11 | ||||
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java | 9 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index acf14fd5..a7c7dca6 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -126,6 +126,7 @@ import io.netty.buffer.ByteBufOutputStream; import io.netty.buffer.Unpooled; import io.netty.handler.codec.base64.Base64; import jline.console.ConsoleReader; +import org.bukkit.event.server.TabCompleteEvent; public final class CraftServer implements Server { private static final Player[] EMPTY_PLAYER_ARRAY = new Player[0]; @@ -1536,12 +1537,18 @@ public final class CraftServer implements Server { return ImmutableList.of(); } + List<String> offers; Player player = ((EntityPlayer) sender).getBukkitEntity(); if (message.startsWith("/")) { - return tabCompleteCommand(player, message); + offers = tabCompleteCommand(player, message); } else { - return tabCompleteChat(player, message); + offers = tabCompleteChat(player, message); } + + TabCompleteEvent tabEvent = new TabCompleteEvent(player, message, offers); + getPluginManager().callEvent(tabEvent); + + return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); } public List<String> tabCompleteCommand(Player player, String message) { diff --git a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java index 7ef57727..c576f4f7 100644 --- a/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java +++ b/src/main/java/org/bukkit/craftbukkit/command/ConsoleCommandCompleter.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.command; +import java.util.Collections; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.logging.Level; @@ -8,6 +9,7 @@ import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.util.Waitable; import jline.console.completer.Completer; +import org.bukkit.event.server.TabCompleteEvent; public class ConsoleCommandCompleter implements Completer { private final CraftServer server; @@ -20,7 +22,12 @@ public class ConsoleCommandCompleter implements Completer { Waitable<List<String>> waitable = new Waitable<List<String>>() { @Override protected List<String> evaluate() { - return server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); + List<String> offers = server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); + + TabCompleteEvent tabEvent = new TabCompleteEvent(server.getConsoleSender(), buffer, offers); + server.getPluginManager().callEvent(tabEvent); + + return tabEvent.isCancelled() ? Collections.EMPTY_LIST : tabEvent.getCompletions(); } }; this.server.getServer().processQueue.add(waitable); |