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.

Rate limiting: Depending on proxy configuration, excessively fast command submissions may be dropped, forwarded directly to the backend, or cause the player to be kicked before plugin handling. In those cases, this event may not fire.

  • 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 a first slash
    • CommandExecuteEvent

      public CommandExecuteEvent(CommandSource commandSource, String command, CommandExecuteEvent.InvocationInfo invocationInfo)
      Constructs a CommandExecuteEvent.
      Parameters:
      commandSource - the source executing the command
      command - the command being executed without a first slash
      invocationInfo - the invocation info of this command
  • 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
    • getInvocationInfo

      public CommandExecuteEvent.InvocationInfo 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 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