Class CommandConfirmationManager<C>

java.lang.Object
cloud.commandframework.extra.confirmation.CommandConfirmationManager<C>
Type Parameters:
C - Command sender type

@API(status=STABLE) public class CommandConfirmationManager<C> extends 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 attach createConfirmationExecutionHandler().

To require a command to be confirmed, use decorate(SimpleCommandMeta.Builder) on the command meta builder.

  • Field Details

    • CONFIRMATION_REQUIRED_META

      @Deprecated public static final String CONFIRMATION_REQUIRED_META
      Deprecated.
      for removal since 1.3.0. Use META_CONFIRMATION_REQUIRED instead.
      Meta data stored for commands that require confirmation
      See Also:
    • META_CONFIRMATION_REQUIRED

      @API(status=STABLE, since="1.3.0") public static final CommandMeta.Key<Boolean> META_CONFIRMATION_REQUIRED
      Metadata 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 value
      timeoutTimeUnit - Timeout time unit
      notifier - Notifier that gets called when a command gets added to the queue
      errorNotifier - Notifier that gets called when someone tries to confirm a command with nothing in the queue
  • Method Details

    • getPending

      public @NonNull 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