Cancellable
RemoteServerCommandEvent
public class ServerCommandEvent extends ServerEvent implements Cancellable
setCommand(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:
${ip:Steve}
with the connection IP of the player named Steve, or simulating the
@a
and @p
decorators used by Command Blocks
for plugins that do not handle it.
/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
Constructor | Description |
---|---|
ServerCommandEvent(@NotNull CommandSender sender,
@NotNull String command) |
Modifier and Type | Method | Description |
---|---|---|
@NotNull String |
getCommand() |
Gets the command that the user is attempting to execute from the
console
|
static @NotNull HandlerList |
getHandlerList() |
|
@NotNull HandlerList |
getHandlers() |
|
@NotNull CommandSender |
getSender() |
Get the command sender.
|
boolean |
isCancelled() |
Gets the cancellation state of this event.
|
void |
setCancelled(boolean cancel) |
Sets the cancellation state of this event.
|
void |
setCommand(@NotNull String message) |
Sets the command that the server will execute
|
getEventName, isAsynchronous
public ServerCommandEvent(@NotNull @NotNull CommandSender sender, @NotNull @NotNull String command)
@NotNull public @NotNull String getCommand()
public void setCommand(@NotNull @NotNull String message)
message
- New message that the server will execute@NotNull public @NotNull CommandSender getSender()
@NotNull public @NotNull HandlerList getHandlers()
getHandlers
in class Event
@NotNull public static @NotNull HandlerList getHandlerList()
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 eventCopyright © 2020. All rights reserved.