public class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable
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.
Event.Result
player
Constructor and Description |
---|
PlayerCommandPreprocessEvent(Player player,
String message) |
PlayerCommandPreprocessEvent(Player player,
String message,
Set<Player> recipients) |
Modifier and Type | Method and Description |
---|---|
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 |
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.
|
getPlayer
getEventName, isAsynchronous
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 sendIllegalArgumentException
- if command is null or emptypublic void setPlayer(Player player) throws IllegalArgumentException
player
- New player which this event will execute asIllegalArgumentException
- if the player provided is null@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()
Copyright © 2016. All rights reserved.