Class CommandConfirmationManager<C>
- java.lang.Object
-
- cloud.commandframework.extra.confirmation.CommandConfirmationManager<C>
-
- Type Parameters:
C
- Command sender type
public class CommandConfirmationManager<C> extends java.lang.Object
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 attachcreateConfirmationExecutionHandler()
.To require a command to be confirmed, use
decorate(SimpleCommandMeta.Builder)
on the command meta builder.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONFIRMATION_REQUIRED_META
Meta data stored for commands that require confirmation
-
Constructor Summary
Constructors Constructor Description CommandConfirmationManager(long timeout, @NonNull java.util.concurrent.TimeUnit timeoutTimeUnit, @NonNull java.util.function.Consumer<@NonNull CommandPostprocessingContext<C>> notifier, @NonNull java.util.function.Consumer<@NonNull C> errorNotifier)
Create a new confirmation manager instance
-
Method Summary
Modifier and Type Method Description @NonNull CommandExecutionHandler<C>
createConfirmationExecutionHandler()
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 java.util.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 Detail
-
CONFIRMATION_REQUIRED_META
public static final java.lang.String CONFIRMATION_REQUIRED_META
Meta data stored for commands that require confirmation- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CommandConfirmationManager
public CommandConfirmationManager(long timeout, @NonNull java.util.concurrent.TimeUnit timeoutTimeUnit, @NonNull java.util.function.Consumer<@NonNull CommandPostprocessingContext<C>> notifier, @NonNull java.util.function.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 Detail
-
getPending
public @NonNull java.util.Optional<CommandPostprocessingContext<C>> getPending(@NonNull C sender)
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
public @NonNull SimpleCommandMeta.Builder decorate(@NonNull SimpleCommandMeta.Builder builder)
Decorate a simple command meta builder, to require confirmation for a command- Parameters:
builder
- Command meta builder- Returns:
- Builder instance
-
registerConfirmationProcessor
public void registerConfirmationProcessor(@NonNull CommandManager<C> manager)
Register the confirmation processor in the command manager- Parameters:
manager
- Command manager
-
createConfirmationExecutionHandler
public @NonNull CommandExecutionHandler<C> createConfirmationExecutionHandler()
Create an execution handler for a confirmation command- Returns:
- Handler for a confirmation command
-
-