diff --git a/paper-api/src/org/bukkit/event/player/PlayerChatEvent.java b/paper-api/src/org/bukkit/event/player/PlayerChatEvent.java new file mode 100644 index 0000000000..0f358f550f --- /dev/null +++ b/paper-api/src/org/bukkit/event/player/PlayerChatEvent.java @@ -0,0 +1,55 @@ + +package org.bukkit.event.player; + +import org.bukkit.Player; + +/** + * Holds information for player chat and commands + */ +public class PlayerChatEvent extends PlayerEvent { + private boolean cancel = false; + private String message; + + public PlayerChatEvent(final Type type, final Player player, final String message) { + super(type, player); + this.message = message; + } + + /** + * Gets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * @return true if this event is cancelled + */ + public boolean isCancelled() { + return cancel; + } + + /** + * Sets the cancellation state of this event. A cancelled event will not + * be executed in the server, but will still pass to other plugins + * + * @param cancel true if you wish to cancel this event + */ + public void setCancelled(boolean cancel) { + this.cancel = cancel; + } + + /** + * Gets the message that the player is attempting to send + * + * @return Message the player is attempting to send + */ + public String getMessage() { + return message; + } + + /** + * Sets the message that the player will send + * + * @param message New message that the player will send + */ + public void setMessage(String message) { + this.message = message; + } +} diff --git a/paper-api/src/org/bukkit/event/player/PlayerListener.java b/paper-api/src/org/bukkit/event/player/PlayerListener.java index fb90ab85d2..dc3d01ecb6 100644 --- a/paper-api/src/org/bukkit/event/player/PlayerListener.java +++ b/paper-api/src/org/bukkit/event/player/PlayerListener.java @@ -12,6 +12,7 @@ public class PlayerListener implements Listener { /** * Called when a player joins a server + * * @param event Relevant event details */ public void onPlayerJoin(PlayerEvent event) { @@ -19,8 +20,25 @@ public class PlayerListener implements Listener { /** * Called when a player leaves a server + * * @param event Relevant event details */ public void onPlayerQuit(PlayerEvent event) { } + + /** + * Called when a player sends a chat message + * + * @param event Relevant event details + */ + public void onPlayerChat(PlayerChatEvent event) { + } + + /** + * Called when a player attempts to use a command + * + * @param event Relevant event details + */ + public void onPlayerCommand(PlayerChatEvent event) { + } } diff --git a/paper-api/src/org/bukkit/plugin/PluginManager.java b/paper-api/src/org/bukkit/plugin/PluginManager.java index b36ecc0dae..a2f88cb177 100644 --- a/paper-api/src/org/bukkit/plugin/PluginManager.java +++ b/paper-api/src/org/bukkit/plugin/PluginManager.java @@ -76,7 +76,7 @@ public interface PluginManager { public void callEvent(Event event); /** - * Registers the given player event to the specified listener + * Registers the given event to the specified listener * * @param type EventType to register * @param listener Listener to register diff --git a/paper-api/src/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/org/bukkit/plugin/SimplePluginManager.java index bc15be8c9b..5cbe08b3e4 100644 --- a/paper-api/src/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/org/bukkit/plugin/SimplePluginManager.java @@ -183,7 +183,7 @@ public final class SimplePluginManager implements PluginManager { } /** - * Registers the given player event to the specified listener + * Registers the given event to the specified listener * * @param type EventType to register * @param listener PlayerListener to register diff --git a/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java index a33e61ff77..d687096c97 100644 --- a/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/org/bukkit/plugin/java/JavaPluginLoader.java @@ -8,7 +8,6 @@ import java.io.InputStream; import java.lang.reflect.Constructor; import java.net.URL; import java.net.URLClassLoader; -import java.util.Map; import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.regex.Pattern; @@ -88,6 +87,12 @@ public final class JavaPluginLoader implements PluginLoader { case PLAYER_QUIT: trueListener.onPlayerQuit((PlayerEvent)event); break; + case PLAYER_COMMAND: + trueListener.onPlayerCommand((PlayerChatEvent)event); + break; + case PLAYER_CHAT: + trueListener.onPlayerChat((PlayerChatEvent)event); + break; } } }