Klasse ConfirmationService

java.lang.Object
de.delinkedde.areashopreborn.application.ConfirmationService

public final class ConfirmationService extends Object
Holds short-lived confirmations for destructive or ownership-changing player actions.

Confirmations intentionally live in memory: a restart cancels them instead of unexpectedly executing an old action. Each player may have at most one pending confirmation.

  • Konstruktordetails

    • ConfirmationService

      public ConfirmationService(Duration timeout)
      Creates a confirmation store.
      Parameter:
      timeout - maximum confirmation lifetime
    • ConfirmationService

      public ConfirmationService(Duration timeout, int maximumPending)
      Creates a bounded confirmation store.
      Parameter:
      timeout - maximum confirmation lifetime
      maximumPending - maximum distinct players retained at once
  • Methodendetails

    • request

      public String request(UUID playerId, String description, Supplier<CompletableFuture<ConfirmationResult>> action)
      Replaces a player's pending action and returns its new confirmation token.
      Parameter:
      playerId - player requesting the action
      description - human-readable action description
      action - deferred operation executed only after confirmation
      Gibt zurück:
      generated case-insensitive token
    • confirm

      public CompletableFuture<ConfirmationResult> confirm(UUID playerId, String suppliedToken)
      Consumes and executes a pending action.
      Parameter:
      playerId - confirming player
      suppliedToken - optional token; required to match when provided
      Gibt zurück:
      future containing the action's success message
    • cancel

      public boolean cancel(UUID playerId)
      Cancels a player's pending action.
      Parameter:
      playerId - player identifier
      Gibt zurück:
      true when an action was removed