Class CommandExecuteEvent
java.lang.Object
com.velocitypowered.api.event.command.CommandExecuteEvent
- All Implemented Interfaces:
ResultedEvent<CommandExecuteEvent.CommandResult>
@AwaitingEvent
public final class CommandExecuteEvent
extends Object
implements ResultedEvent<CommandExecuteEvent.CommandResult>
This event is fired when someone executes a command. Velocity will wait for this event to finish
firing before trying to handle the command and/or forwarding it to the server.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
Represents the result of theCommandExecuteEvent
.static final record
Represents information about a command invocation, including its signed state and source.static enum
Represents the signed state of a command invocation.static enum
Represents the source of a command invocation.Nested classes/interfaces inherited from interface com.velocitypowered.api.event.ResultedEvent
ResultedEvent.ComponentResult, ResultedEvent.GenericResult, ResultedEvent.Result
-
Constructor Summary
ConstructorDescriptionCommandExecuteEvent
(CommandSource commandSource, String command) Constructs a CommandExecuteEvent.CommandExecuteEvent
(CommandSource commandSource, String command, CommandExecuteEvent.InvocationInfo invocationInfo) Constructs a CommandExecuteEvent. -
Method Summary
Modifier and TypeMethodDescriptionGets the original command being executed without the first slash.Gets the source responsible for the execution of this command.Returns the info of the command invocation.Returns the result associated with this event.void
setResult
(@NonNull CommandExecuteEvent.CommandResult result) Sets the result of this event.toString()
-
Constructor Details
-
CommandExecuteEvent
Constructs a CommandExecuteEvent.- Parameters:
commandSource
- the source executing the commandcommand
- the command being executed without first slash
-
CommandExecuteEvent
public CommandExecuteEvent(CommandSource commandSource, String command, CommandExecuteEvent.InvocationInfo invocationInfo) Constructs a CommandExecuteEvent.- Parameters:
commandSource
- the source executing the commandcommand
- the command being executed without first slashinvocationInfo
- the invocation info of this command
-
-
Method Details
-
getCommandSource
Gets the source responsible for the execution of this command.- Returns:
- the source executing the command
-
getCommand
Gets the original command being executed without the first slash.- Returns:
- the original command being executed
- API Note:
- Note that the player can provide a command that begins with spaces,
but still be validly executed. For example, the command
/ velocity info
, although not valid in the chat bar, will be executed as correctly as if the player had executed/velocity info
-
getInvocationInfo
Returns the info of the command invocation.- Returns:
- invocation info
- Since:
- 3.4.0
-
getResult
Description copied from interface:ResultedEvent
Returns the result associated with this event.- Specified by:
getResult
in interfaceResultedEvent<CommandExecuteEvent.CommandResult>
- Returns:
- the result of this event
-
setResult
Description copied from interface:ResultedEvent
Sets the result of this event. The result must be non-null.- Specified by:
setResult
in interfaceResultedEvent<CommandExecuteEvent.CommandResult>
- Parameters:
result
- the new result
-
toString
-