|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.bukkit.event.Event org.bukkit.event.player.PlayerEvent org.bukkit.event.player.PlayerCommandPreprocessEvent
public class PlayerCommandPreprocessEvent
This event is called whenever a player runs a command (by placing a slash
at the start of their message). It is called early in the command handling
process, and modifications in this event (via setMessage(String)
)
will be shown in the behavior.
Many plugins will have no use for this event, and you should attempt to avoid using it if it is not necessary.
Some examples of valid uses for this event are:
${nearbyPlayer}
with the name of the nearest other
player, or simulating the @a
and @p
decorators used by Command Blocks in plugins that do not handle it.
/home
command in a
combat arena.
/calias cr gamemode creative
, the next time they
run /cr
, it gets replaced into
/gamemode creative
. (Global command aliases should be
done by registering the alias.)
Examples of incorrect uses are:
If the event is cancelled, processing of the command will halt.
The state of whether or not there is a slash (/
) at the
beginning of the message should be preserved. If a slash is added or
removed, unexpected behavior may result.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.bukkit.event.Event |
---|
Event.Result |
Field Summary |
---|
Fields inherited from class org.bukkit.event.player.PlayerEvent |
---|
player |
Constructor Summary | |
---|---|
PlayerCommandPreprocessEvent(Player player,
String message)
|
|
PlayerCommandPreprocessEvent(Player player,
String message,
Set<Player> recipients)
|
Method Summary | |
---|---|
String |
getFormat()
Deprecated. This method is provided for backward compatibility with no guarantee to the use of the format. |
static HandlerList |
getHandlerList()
|
HandlerList |
getHandlers()
|
String |
getMessage()
Gets the command that the player is attempting to send. |
Set<Player> |
getRecipients()
Deprecated. This method is provided for backward compatibility with no guarantee to the effect of viewing or modifying the set. |
boolean |
isCancelled()
Gets the cancellation state of this event. |
void |
setCancelled(boolean cancel)
Sets the cancellation state of this event. |
void |
setFormat(String format)
Deprecated. This method is provided for backward compatibility with no guarantee to the effect of modifying the format. |
void |
setMessage(String command)
Sets the command that the player will send. |
void |
setPlayer(Player player)
Sets the player that this command will be executed as. |
Methods inherited from class org.bukkit.event.player.PlayerEvent |
---|
getPlayer |
Methods inherited from class org.bukkit.event.Event |
---|
getEventName, isAsynchronous |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PlayerCommandPreprocessEvent(Player player, String message)
public PlayerCommandPreprocessEvent(Player player, String message, Set<Player> recipients)
Method Detail |
---|
public boolean isCancelled()
Cancellable
isCancelled
in interface Cancellable
public void setCancelled(boolean cancel)
Cancellable
setCancelled
in interface Cancellable
cancel
- true if you wish to cancel this eventpublic String getMessage()
All commands begin with a special character; implementations do not consider the first character when executing the content.
public void setMessage(String command) throws IllegalArgumentException
All commands begin with a special character; implementations do not consider the first character when executing the content.
command
- New message that the player will send
IllegalArgumentException
- if command is null or emptypublic void setPlayer(Player player) throws IllegalArgumentException
player
- New player which this event will execute as
IllegalArgumentException
- if the player provided is null@Deprecated public String getFormat()
@Deprecated public void setFormat(String format)
format
- String.Format compatible format string@Deprecated public Set<Player> getRecipients()
The set returned is not guaranteed to be mutable and may auto-populate
on access. Any listener accessing the returned set should be aware that
it may reduce performance for a lazy set implementation. Listeners
should be aware that modifying the list may throw UnsupportedOperationException
if the event caller provides an
unmodifiable set.
public HandlerList getHandlers()
getHandlers
in class Event
public static HandlerList getHandlerList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |