From 21e4c28d425431006a94d500bc01183163440d6b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 31 Jul 2018 10:45:22 +1000 Subject: [PATCH] SPIGOT-4029: Add event for commands being sent to client By: md_5 --- .../event/player/PlayerCommandSendEvent.java | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java new file mode 100644 index 0000000000..fbdecdcc1d --- /dev/null +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerCommandSendEvent.java @@ -0,0 +1,51 @@ +package org.bukkit.event.player; + +import java.util.Collection; +import org.bukkit.Warning; +import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; + +/** + * This event is called when the list of available server commands is sent to + * the player. + *
+ * Commands may be removed from display using this event, but implementations + * are not required to securely remove all traces of the command. If secure + * removal of commands is required, then the command should be assigned a + * permission which is not granted to the player. + * + * @deprecated draft API + */ +@Deprecated +@Warning(false) +public class PlayerCommandSendEvent extends PlayerEvent { + + private static final HandlerList handlers = new HandlerList(); + private final Collection commands; + + public PlayerCommandSendEvent(final Player player, final Collection commands) { + super(player); + this.commands = commands; + } + + /** + * Returns a mutable collection of all top level commands to be sent. + *
+ * It is not legal to add entries to this collection, only remove them. + * Behaviour of adding entries is undefined. + * + * @return collection of all commands + */ + public Collection getCommands() { + return commands; + } + + @Override + public HandlerList getHandlers() { + return handlers; + } + + public static HandlerList getHandlerList() { + return handlers; + } +}