Class InventoryConfirm

java.lang.Object
mc.obliviate.inventory.Gui
com.ultikits.ultitools.abstracts.guis.OkCancelPage
com.ultikits.ultitools.widgets.impl.InventoryConfirm
All Implemented Interfaces:
Confirm, org.bukkit.inventory.InventoryHolder

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

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

基于 GUI 物品栏的确认对话框实现。 该组件显示一个带有确定和取消按钮的 3 行物品栏界面。 继承 OkCancelPage 以获得标准的确定/取消按钮布局。

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 Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Custom cancel button text, null uses OkCancelPage default / 自定义取消按钮文本,null 使用 OkCancelPage 默认值
    private String
    Custom confirm button text, null uses OkCancelPage default / 自定义确认按钮文本,null 使用 OkCancelPage 默认值
    private static final String
    The unique GUI identifier / GUI 唯一标识符
    private static final int
    The number of rows in the GUI (3 rows = 27 slots) / GUI 行数(3 行 = 27 格)
    private final Runnable
    Callback executed when player clicks Cancel button / 玩家点击取消按钮时执行的回调
    private final Runnable
    Callback executed when player clicks OK button / 玩家点击确定按钮时执行的回调

    Fields inherited from class mc.obliviate.inventory.Gui

    player
  • Constructor Summary

    Constructors
    Constructor
    Description
    InventoryConfirm(org.bukkit.entity.Player player, String title, String description, Runnable onConfirm, Runnable onCancel)
    Creates an inventory confirmation dialog with default button text.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
     
    Get the cancel text.
    Get the confirm text.
     
    void
    onCancel(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
    This method is called when the Cancel option is clicked.
    void
    onOk(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
    This method is called when the OK option is clicked.
    void
    Show the confirm dialog.

    Methods inherited from class com.ultikits.ultitools.abstracts.guis.OkCancelPage

    onOpen

    Methods inherited from class mc.obliviate.inventory.Gui

    addItem, addItem, addItem, addItem, addItem, addItem, addItem, addItem, createInventory, createInventory, fillColumn, fillGui, fillGui, fillGui, fillGui, fillRow, getId, getInventory, getItems, getLastSlot, getPlugin, getSize, getTaskList, getTitle, isClosed, onClick, onClose, onDrag, open, runTaskLater, sendSizeUpdate, sendTitleUpdate, setClosed, setInventory, setSize, setTitle, stopAllTasks, stopTask, updateTask

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • confirmText

      private String confirmText
      Custom confirm button text, null uses OkCancelPage default / 自定义确认按钮文本,null 使用 OkCancelPage 默认值
    • cancelText

      private String cancelText
      Custom cancel button text, null uses OkCancelPage default / 自定义取消按钮文本,null 使用 OkCancelPage 默认值
    • onConfirm

      private final Runnable onConfirm
      Callback executed when player clicks OK button / 玩家点击确定按钮时执行的回调
    • onCancel

      private final Runnable onCancel
      Callback executed when player clicks Cancel button / 玩家点击取消按钮时执行的回调
    • GUI_ID

      private static final String GUI_ID
      The unique GUI identifier / GUI 唯一标识符
      See Also:
    • GUI_ROWS

      private static final int GUI_ROWS
      The number of rows in the GUI (3 rows = 27 slots) / GUI 行数(3 行 = 27 格)
      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

    • getOkName

      public String getOkName()
      Overrides:
      getOkName in class OkCancelPage
    • getCancelName

      public String getCancelName()
      Overrides:
      getCancelName in class OkCancelPage
    • 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
    • onOk

      public void onOk(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
      Description copied from class: OkCancelPage
      This method is called when the OK option is clicked. It should be overridden in subclasses to provide specific functionality.

      当点击OK选项时调用此方法。此方法应该在子类中被重写以提供特定的功能。

      Specified by:
      onOk in class OkCancelPage
      Parameters:
      clickEvent - The InventoryClickEvent that triggers this method.

      触发此方法的InventoryClickEvent。

    • onCancel

      public void onCancel(org.bukkit.event.inventory.InventoryClickEvent clickEvent)
      Description copied from class: OkCancelPage
      This method is called when the Cancel option is clicked. It should be overridden in subclasses to provide specific functionality.

      当点击Cancel选项时调用此方法。此方法应该在子类中被重写以提供特定的功能。

      Specified by:
      onCancel in class OkCancelPage
      Parameters:
      clickEvent - The InventoryClickEvent that triggers this method.

      触发此方法的InventoryClickEvent。