Class ConfirmationBuilder

java.lang.Object
com.palmergames.bukkit.towny.confirmations.ConfirmationBuilder

public class ConfirmationBuilder extends Object
A class responsible for assembling confirmations.
  • Constructor Details

    • ConfirmationBuilder

      public ConfirmationBuilder()
  • Method Details

    • runOnCancel

      public ConfirmationBuilder runOnCancel(Runnable cancelHandler)
      The code to run on cancellation.
      Parameters:
      cancelHandler - The runnable to run on cancellation of the confirmation.
      Returns:
      A builder reference of this object.
    • setTitle

      public ConfirmationBuilder setTitle(String title)
      Sets the title of the confirmation to be sent.
      Parameters:
      title - The title of the confirmation.
      Returns:
      A builder reference of this object.
    • setTitle

      public ConfirmationBuilder setTitle(Translatable title)
    • setDuration

      public ConfirmationBuilder setDuration(int duration)
      Sets the duration the confirmation will run for.
      Parameters:
      duration - The duration in second.
      Returns:
      A builder reference of this object.
    • setCost

      public ConfirmationBuilder setCost(ConfirmationTransaction confirmationTransaction)
      Builds and sends this confirmation to the given CommandSender.
      Parameters:
      confirmationTransaction - The ConfirmationTransaction to apply to the confirmation.
    • setCancellableEvent

      public ConfirmationBuilder setCancellableEvent(CancellableTownyEvent event)
    • setAsync

      public ConfirmationBuilder setAsync(boolean runAsync)
      Sets whether the confirmation will run it's accept handler async or not.
      Parameters:
      runAsync - Whether to run async or not.
      Returns:
      A builder reference of this object.
    • setConfirmText

      public ConfirmationBuilder setConfirmText(String confirm)
      Sets the command which is displayed/run for the confirm command.
      Parameters:
      confirm - String command name.
      Returns:
      ConfirmationBuilder with an overridden confirm text.
    • setCancelText

      public ConfirmationBuilder setCancelText(String cancel)
      Sets the command which is displayed/run for the cancel command.
      Parameters:
      cancel - String command name.
      Returns:
      ConfirmationBuilder with an overriden cancel text.
    • setPluginCommandPrefix

      public ConfirmationBuilder setPluginCommandPrefix(String prefix)
      Sets the base plugin command used when the cancel or confirm commands are run. ie: towny in /"towny":town spawn
      Parameters:
      prefix - String plugin name sending this Confirmation.
      Returns:
      ConfirmationBuilder with an overriden command prefix.
    • build

      public Confirmation build()
      Builds a new instance of Confirmation from this object's state.
      Returns:
      A new Confirmation object.
    • sendTo

      public void sendTo(org.bukkit.command.CommandSender sender)
      Builds and sends this confirmation to the given CommandSender.
      Parameters:
      sender - The sender to send the confirmation to.