diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index acf14fd525..a7c7dca65f 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 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 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 7ef5772719..c576f4f78a 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> waitable = new Waitable>() { @Override protected List evaluate() { - return server.getCommandMap().tabComplete(server.getConsoleSender(), buffer); + List 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);