Class CommandConfirmationManager<C>
java.lang.Object
cloud.commandframework.extra.confirmation.CommandConfirmationManager<C>
- Type Parameters:
C
- Command sender type
Manager for the command confirmation system that enables the ability to add "confirmation" requirements to commands,
such that they need to be confirmed in order to be executed.
To use the confirmation system, the confirmation post processor needs to be added. To to this, use
registerConfirmationProcessor(CommandManager)
. After this is done, a confirmation command has
been added. To do this, create a command builder and attach createConfirmationExecutionHandler()
.
To require a command to be confirmed, use decorate(SimpleCommandMeta.Builder)
on the command meta builder.
-
Field Summary
Modifier and TypeFieldDescriptionstatic String
Deprecated.for removal since 1.3.0.static CommandMeta.Key<Boolean>
Meta data stored for commands that require confirmation -
Constructor Summary
ConstructorDescriptionCommandConfirmationManager(long timeout, @NonNull TimeUnit timeoutTimeUnit, @NonNull Consumer<@NonNull CommandPostprocessingContext<C>> notifier, @NonNull Consumer<@NonNull C> errorNotifier)
Create a new confirmation manager instance -
Method Summary
Modifier and TypeMethodDescription@NonNull CommandExecutionHandler<C>
Create an execution handler for a confirmation command@NonNull SimpleCommandMeta.Builder
decorate(@NonNull SimpleCommandMeta.Builder builder)
Decorate a simple command meta builder, to require confirmation for a command@NonNull Optional<CommandPostprocessingContext<C>>
getPending(@NonNull C sender)
Get a pending context if one is stored for the sendervoid
registerConfirmationProcessor(@NonNull CommandManager<C> manager)
Register the confirmation processor in the command manager
-
Field Details
-
CONFIRMATION_REQUIRED_META
Deprecated.for removal since 1.3.0. UseMETA_CONFIRMATION_REQUIRED
instead.Meta data stored for commands that require confirmation- See Also:
- Constant Field Values
-
META_CONFIRMATION_REQUIRED
Meta data stored for commands that require confirmation- Since:
- 1.3.0
-
-
Constructor Details
-
CommandConfirmationManager
public CommandConfirmationManager(long timeout, @NonNull TimeUnit timeoutTimeUnit, @NonNull Consumer<@NonNull CommandPostprocessingContext<C>> notifier, @NonNull Consumer<@NonNull C> errorNotifier)Create a new confirmation manager instance- Parameters:
timeout
- Timeout valuetimeoutTimeUnit
- Timeout time unitnotifier
- Notifier that gets called when a command gets added to the queueerrorNotifier
- Notifier that gets called when someone tries to confirm a command with nothing in the queue
-
-
Method Details
-
getPending
Get a pending context if one is stored for the sender- Parameters:
sender
- Sender- Returns:
- Optional containing the post processing context if one has been stored, else
Optional.empty()
-
decorate
Decorate a simple command meta builder, to require confirmation for a command- Parameters:
builder
- Command meta builder- Returns:
- Builder instance
-
registerConfirmationProcessor
Register the confirmation processor in the command manager- Parameters:
manager
- Command manager
-
createConfirmationExecutionHandler
Create an execution handler for a confirmation command- Returns:
- Handler for a confirmation command
-