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.
  • Constructor Details

    • CommandExecuteEvent

      public CommandExecuteEvent(CommandSource commandSource, String command)
      Constructs a CommandExecuteEvent.
      Parameters:
      commandSource - the source executing the command
      command - the command being executed without first slash
  • Method Details

    • getCommandSource

      public CommandSource getCommandSource()
      Gets the source responsible for the execution of this command.
      Returns:
      the source executing the command
    • getCommand

      public String 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
    • getResult

      Description copied from interface: ResultedEvent
      Returns the result associated with this event.
      Specified by:
      getResult in interface ResultedEvent<CommandExecuteEvent.CommandResult>
      Returns:
      the result of this event
    • setResult

      public void setResult(@NonNull CommandExecuteEvent.CommandResult result)
      Description copied from interface: ResultedEvent
      Sets the result of this event. The result must be non-null.
      Specified by:
      setResult in interface ResultedEvent<CommandExecuteEvent.CommandResult>
      Parameters:
      result - the new result
    • toString

      public String toString()
      Overrides:
      toString in class Object