Package cloud.commandframework.execution
Interface CommandExecutionHandler<C>
- Type Parameters:
C
- Command sender type
- All Known Subinterfaces:
CommandExecutionHandler.FutureCommandExecutionHandler<C>
- All Known Implementing Classes:
CommandExecutionHandler.MulticastDelegateFutureCommandExecutionHandler
,CommandExecutionHandler.NullCommandExecutionHandler
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Handler that is invoked whenever a
Command
is executed
by a command sender-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interface
Handler that is invoked whenever aCommand
is executed by a command senderstatic final class
Delegates to other handlers.static class
Command execution handler that does nothing -
Method Summary
Modifier and TypeMethodDescriptionstatic <C> @NonNull CommandExecutionHandler<C>
delegatingExecutionHandler
(List<CommandExecutionHandler<C>> handlers) Returns aCommandExecutionHandler
that delegates the givenhandlers
in sequence.void
execute
(@NonNull CommandContext<C> commandContext) Handle command executiondefault CompletableFuture<@Nullable Void>
executeFuture
(@NonNull CommandContext<C> commandContext) Handle command executionstatic <C> @NonNull CommandExecutionHandler<C>
Returns aCommandExecutionHandler
that does nothing (no-op).
-
Method Details
-
noOpCommandExecutionHandler
@API(status=STABLE, since="1.7.0") static <C> @NonNull CommandExecutionHandler<C> noOpCommandExecutionHandler()Returns aCommandExecutionHandler
that does nothing (no-op).- Type Parameters:
C
- Command sender type- Returns:
- command execution handler that does nothing
- Since:
- 1.7.0
-
delegatingExecutionHandler
@API(status=STABLE, since="1.7.0") static <C> @NonNull CommandExecutionHandler<C> delegatingExecutionHandler(List<CommandExecutionHandler<C>> handlers) Returns aCommandExecutionHandler
that delegates the givenhandlers
in sequence.If any handler in the chain throws an exception, then no subsequent handlers will be invoked.
- Type Parameters:
C
- Command sender type- Parameters:
handlers
- The handlers to delegate to- Returns:
- multicast-delegate command execution handler
- Since:
- 1.7.0
-
execute
Handle command execution- Parameters:
commandContext
- Command context
-
executeFuture
@API(status=STABLE, since="1.6.0") default CompletableFuture<@Nullable Void> executeFuture(@NonNull CommandContext<C> commandContext) Handle command execution- Parameters:
commandContext
- Command context- Returns:
- future that completes when the command has finished execution
- Since:
- 1.6.0
-