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
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
FieldsModifier and TypeFieldDescriptionprivate StringCustom cancel button text, null uses OkCancelPage default / 自定义取消按钮文本,null 使用 OkCancelPage 默认值private StringCustom confirm button text, null uses OkCancelPage default / 自定义确认按钮文本,null 使用 OkCancelPage 默认值private static final StringThe unique GUI identifier / GUI 唯一标识符private static final intThe number of rows in the GUI (3 rows = 27 slots) / GUI 行数(3 行 = 27 格)private final RunnableCallback executed when player clicks Cancel button / 玩家点击取消按钮时执行的回调private final RunnableCallback executed when player clicks OK button / 玩家点击确定按钮时执行的回调Fields inherited from class mc.obliviate.inventory.Gui
player -
Constructor Summary
ConstructorsConstructorDescriptionInventoryConfirm(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 TypeMethodDescriptionGet the cancel text.Get the confirm text.voidonCancel(org.bukkit.event.inventory.InventoryClickEvent clickEvent) This method is called when the Cancel option is clicked.voidonOk(org.bukkit.event.inventory.InventoryClickEvent clickEvent) This method is called when the OK option is clicked.voidshow()Show the confirm dialog.Methods inherited from class com.ultikits.ultitools.abstracts.guis.OkCancelPage
onOpenMethods 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
-
Field Details
-
confirmText
Custom confirm button text, null uses OkCancelPage default / 自定义确认按钮文本,null 使用 OkCancelPage 默认值 -
cancelText
Custom cancel button text, null uses OkCancelPage default / 自定义取消按钮文本,null 使用 OkCancelPage 默认值 -
onConfirm
Callback executed when player clicks OK button / 玩家点击确定按钮时执行的回调 -
onCancel
Callback executed when player clicks Cancel button / 玩家点击取消按钮时执行的回调 -
GUI_ID
The unique GUI identifier / GUI 唯一标识符- See Also:
-
GUI_ROWS
private static final int GUI_ROWSThe 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
- Overrides:
getOkNamein classOkCancelPage
-
getCancelName
- Overrides:
getCancelNamein classOkCancelPage
-
getConfirmText
Description copied from interface:ConfirmGet the confirm text.
获取确认文本。- Specified by:
getConfirmTextin interfaceConfirm
-
getCancelText
Description copied from interface:ConfirmGet the cancel text.
获取取消文本。- Specified by:
getCancelTextin interfaceConfirm
-
show
public void show()Description copied from interface:ConfirmShow the confirm dialog.
显示确认对话框。 -
onOk
public void onOk(org.bukkit.event.inventory.InventoryClickEvent clickEvent) Description copied from class:OkCancelPageThis method is called when the OK option is clicked. It should be overridden in subclasses to provide specific functionality.当点击OK选项时调用此方法。此方法应该在子类中被重写以提供特定的功能。
- Specified by:
onOkin classOkCancelPage- Parameters:
clickEvent- The InventoryClickEvent that triggers this method.触发此方法的InventoryClickEvent。
-
onCancel
public void onCancel(org.bukkit.event.inventory.InventoryClickEvent clickEvent) Description copied from class:OkCancelPageThis method is called when the Cancel option is clicked. It should be overridden in subclasses to provide specific functionality.当点击Cancel选项时调用此方法。此方法应该在子类中被重写以提供特定的功能。
- Specified by:
onCancelin classOkCancelPage- Parameters:
clickEvent- The InventoryClickEvent that triggers this method.触发此方法的InventoryClickEvent。
-