mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-27 23:10:16 +01:00
Added onPlayerChat and onPlayerCommand
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
de10dba640
commit
e61f164e8b
5 changed files with 81 additions and 3 deletions
55
paper-api/src/org/bukkit/event/player/PlayerChatEvent.java
Normal file
55
paper-api/src/org/bukkit/event/player/PlayerChatEvent.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue