From e3b86cda50a54110d78cb720492a4d9b73a9329b Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 19 Feb 2011 01:41:33 -0800 Subject: [PATCH] Lowered the priority of the old command handler event because a number of plugins were using this event incorrectly. A new event, the command preprocesser event, has replaced the previous function of the original command event. By: sk89q --- paper-api/src/main/java/org/bukkit/event/Event.java | 7 +++++++ .../org/bukkit/event/player/PlayerListener.java | 13 ++++++++++--- .../org/bukkit/plugin/java/JavaPluginLoader.java | 5 +++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/event/Event.java b/paper-api/src/main/java/org/bukkit/event/Event.java index 0beea9c6a4..6fee5240b4 100644 --- a/paper-api/src/main/java/org/bukkit/event/Event.java +++ b/paper-api/src/main/java/org/bukkit/event/Event.java @@ -178,6 +178,13 @@ public abstract class Event { */ PLAYER_COMMAND (Category.PLAYER), + /** + * Called when a player early in the command handling process + * + * @see org.bukkit.event.player.PlayerChatEvent + */ + PLAYER_COMMAND_PREPROCESS (Category.PLAYER), + /** * Called when a player leaves a server * diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java index e2760acc3b..4b1d00352d 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerListener.java @@ -43,9 +43,7 @@ public class PlayerListener implements Listener { } /** - * Called when a player attempts to use a command. Avoid using this - * when possible -- it won't be removed, but this is not how you - * handle commands. + * Called when a player attempts to use a command. * * @param event Relevant event details */ @@ -53,6 +51,15 @@ public class PlayerListener implements Listener { public void onPlayerCommand(PlayerChatEvent event) { } + /** + * Called early in the command handling process. This event is only + * for very exceptional cases and you should not normally use it. + * + * @param event Relevant event details + */ + public void onPlayerCommandPreprocess(PlayerChatEvent event) { + } + /** * Called when a player attempts to move location in a world * diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index bb9ddf185f..6241bda642 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -150,6 +150,11 @@ public final class JavaPluginLoader implements PluginLoader { ((PlayerListener)listener).onPlayerCommand( (PlayerChatEvent)event ); } }; + case PLAYER_COMMAND_PREPROCESS: + return new EventExecutor() { public void execute( Listener listener, Event event ) { + ((PlayerListener)listener).onPlayerCommandPreprocess( (PlayerChatEvent)event ); + } + }; case PLAYER_CHAT: return new EventExecutor() { public void execute( Listener listener, Event event ) { ((PlayerListener)listener).onPlayerChat( (PlayerChatEvent)event );