Interface CommandExecutor<C>
-
Method Summary
Modifier and TypeMethodDescriptiondefault @NonNull CompletableFuture<CommandResult<C>> executeCommand(@NonNull C commandSender, @NonNull String input) Executes a command and get a future that completes with the result.executeCommand(@NonNull C commandSender, @NonNull String input, @NonNull Consumer<CommandContext<C>> contextConsumer) Executes a command and get a future that completes with the result.Returns the command execution coordinator.
-
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 theExecutionCoordinatorused in the command manager.The command may also be filtered out by preprocessors (see
CommandPreprocessor) before they are parsed, or by theCommandComponentcommand components during parsing. The execution may also be filtered out after parsing by aCommandPostprocessor. In the case that a command was filtered out at any of the execution stages, the future will complete withnull.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 commandinput- 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
nullif 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 theExecutionCoordinatorused in the command manager.The command may also be filtered out by preprocessors (see
CommandPreprocessor) before they are parsed, or by theCommandComponentcommand components during parsing. The execution may also be filtered out after parsing by aCommandPostprocessor. In the case that a command was filtered out at any of the execution stages, the future will complete withnull.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 commandinput- 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
nullif the execution was cancelled at any of the processing stages.
-
executionCoordinator
@NonNull ExecutionCoordinator<C> executionCoordinator()Returns the command execution coordinator.- Returns:
- command execution coordinator
-