Class InventoryConfirm

All Implemented Interfaces:
Confirm, org.bukkit.inventory.InventoryHolder

public class InventoryConfirm extends BaseConfirmationPage implements Confirm
A GUI inventory-based confirmation dialog implementation.

This widget displays a 3-row inventory GUI with OK and Cancel buttons. Extends BaseConfirmationPage to inherit the standard OK/Cancel button layout.

Example Usage:


 Confirm.gui(player, "Confirm Purchase", "Buy Diamond Sword for 100 coins?",
     () -> completePurchase(),
     () -> cancelPurchase()
 ).show();
 
Since:
6.0.0
Author:
wisdomme
See Also:
  • Field Details

    • confirmText

      private String confirmText
      Custom confirm button text, null uses BaseConfirmationPage default
    • cancelText

      private String cancelText
      Custom cancel button text, null uses BaseConfirmationPage default
    • onConfirmCallback

      private final Runnable onConfirmCallback
      Callback executed when player clicks OK button
    • onCancelCallback

      private final Runnable onCancelCallback
      Callback executed when player clicks Cancel button
    • GUI_ID

      private static final String GUI_ID
      The unique GUI identifier
      See Also:
    • GUI_ROWS

      private static final int GUI_ROWS
      The number of rows in the GUI (3 rows = 27 slots)
      See Also:
  • Constructor Details

    • InventoryConfirm

      public InventoryConfirm(org.bukkit.entity.Player player, String title, String description, Runnable onConfirm, Runnable onCancel)
      Creates an inventory confirmation dialog with default button text.
      Parameters:
      player - the target player
      title - the dialog title
      description - the dialog description (appended to title)
      onConfirm - callback for confirm action
      onCancel - callback for cancel action
    • InventoryConfirm

      public InventoryConfirm(org.bukkit.entity.Player player, String title, String description, String confirmText, String cancelText, Runnable onConfirm, Runnable onCancel)
      Creates an inventory confirmation dialog with custom button text.
      Parameters:
      player - the target player
      title - the dialog title
      description - the dialog description (appended to title)
      confirmText - custom confirm button text
      cancelText - custom cancel button text
      onConfirm - callback for confirm action
      onCancel - callback for cancel action
  • Method Details

    • getOkButtonName

      protected String getOkButtonName()
      Description copied from class: BaseConfirmationPage
      Gets the OK button display name. Override to customize.
      Overrides:
      getOkButtonName in class BaseConfirmationPage
      Returns:
      the OK button name
    • getCancelButtonName

      protected String getCancelButtonName()
      Description copied from class: BaseConfirmationPage
      Gets the Cancel button display name. Override to customize.
      Overrides:
      getCancelButtonName in class BaseConfirmationPage
      Returns:
      the Cancel button name
    • getConfirmText

      public String getConfirmText()
      Description copied from interface: Confirm
      Get the confirm text.
      Specified by:
      getConfirmText in interface Confirm
    • getCancelText

      public String getCancelText()
      Description copied from interface: Confirm
      Get the cancel text.
      Specified by:
      getCancelText in interface Confirm
    • show

      public void show()
      Description copied from interface: Confirm
      Show the confirm dialog.
      Specified by:
      show in interface Confirm
    • onConfirm

      protected void onConfirm(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
      Description copied from class: BaseConfirmationPage
      Called when the OK button is clicked.
      Specified by:
      onConfirm in class BaseConfirmationPage
      Parameters:
      clickEvent - the click event
    • onCancel

      protected void onCancel(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
      Description copied from class: BaseConfirmationPage
      Called when the Cancel button is clicked. Default implementation does nothing.
      Overrides:
      onCancel in class BaseConfirmationPage
      Parameters:
      clickEvent - the click event