Interface CommandExecutor<C>


@API(status=STABLE) public interface CommandExecutor<C>
  • Method Details

    • executeCommand

      default @NonNull CompletableFuture<CommandResult<C>> executeCommand(@NonNull C commandSender, @NonNull String input)
      Executes a command and get a future that completes with the result. The command may be executed immediately or at some point in the future, depending on the ExecutionCoordinator used in the command manager.

      The command may also be filtered out by preprocessors (see CommandPreprocessor) before they are parsed, or by the CommandComponent command components during parsing. The execution may also be filtered out after parsing by a CommandPostprocessor. In the case that a command was filtered out at any of the execution stages, the future will complete with null.

      The future may also complete exceptionally. These exceptions will be handled using exception handlers registered in the ExceptionController. The exceptions will be forwarded to the future, if the exception was transformed during the exception handling, then the new exception will be present in the completed future.

      Parameters:
      commandSender - Sender of the command
      input - Input provided by the sender. Prefixes should be removed before the method is being called, and the input here will be passed directly to the command parsing pipeline, after having been tokenized.
      Returns:
      future that completes with the command result, or null if the execution was cancelled at any of the processing stages.
    • executeCommand

      @NonNull CompletableFuture<CommandResult<C>> executeCommand(@NonNull C commandSender, @NonNull String input, @NonNull Consumer<CommandContext<C>> contextConsumer)
      Executes a command and get a future that completes with the result. The command may be executed immediately or at some point in the future, depending on the ExecutionCoordinator used in the command manager.

      The command may also be filtered out by preprocessors (see CommandPreprocessor) before they are parsed, or by the CommandComponent command components during parsing. The execution may also be filtered out after parsing by a CommandPostprocessor. In the case that a command was filtered out at any of the execution stages, the future will complete with null.

      The future may also complete exceptionally. These exceptions will be handled using exception handlers registered in the ExceptionController. The exceptions will be forwarded to the future, if the exception was transformed during the exception handling, then the new exception will be present in the completed future.

      Parameters:
      commandSender - the sender of the command
      input - the input provided by the sender. Prefixes should be removed before the method is being called, and the input here will be passed directly to the command parsing pipeline, after having been tokenized.
      contextConsumer - consumer that accepts the context before the command is executed
      Returns:
      future that completes with the command result, or null if the execution was cancelled at any of the processing stages.
    • executionCoordinator

      @NonNull ExecutionCoordinator<C> executionCoordinator()
      Returns the command execution coordinator.
      Returns:
      command execution coordinator