Class ChatConfirm
java.lang.Object
com.ultikits.ultitools.widgets.impl.ChatConfirm
- All Implemented Interfaces:
Confirm
A chat-based confirmation dialog implementation.
This widget displays a confirmation prompt in the player's chat with clickable confirm and cancel buttons. Uses Adventure API for rich text formatting.
基于聊天的确认对话框实现。 该组件在玩家聊天中显示带有可点击确认和取消按钮的确认提示。 使用 Adventure API 进行富文本格式化。
Example Usage / 使用示例:
Confirm.chat(player, "Delete Item", "Are you sure?",
() -> deleteItem(),
() -> player.sendMessage("Cancelled")
).show();
- Since:
- 6.0.0
- Author:
- wisdomme
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringCustom cancel button text, null uses default i18n "取消" / 自定义取消按钮文本,null 使用默认 i18n "取消"private StringCustom confirm button text, null uses default i18n "OK" / 自定义确认按钮文本,null 使用默认 i18n "OK"private final StringThe description text displayed below title / 显示在标题下方的描述文本private final RunnableCallback executed when player clicks cancel / 玩家点击取消时执行的回调private final RunnableCallback executed when player clicks confirm / 玩家点击确认时执行的回调private final org.bukkit.entity.PlayerThe target player to show the dialog / 显示对话框的目标玩家private final StringThe title text displayed in bold gold / 以粗体金色显示的标题文本 -
Constructor Summary
ConstructorsConstructorDescriptionChatConfirm(org.bukkit.entity.Player player, String title, String description, Runnable onConfirm, Runnable onCancel) Creates a chat confirmation dialog with default button text.ChatConfirm(org.bukkit.entity.Player player, String title, String description, String confirmText, String cancelText, Runnable onConfirm, Runnable onCancel) Creates a chat confirmation dialog with custom button text. -
Method Summary
Modifier and TypeMethodDescriptionGet the cancel text.Get the confirm text.voidshow()Show the confirm dialog.
-
Field Details
-
confirmText
Custom confirm button text, null uses default i18n "OK" / 自定义确认按钮文本,null 使用默认 i18n "OK" -
cancelText
Custom cancel button text, null uses default i18n "取消" / 自定义取消按钮文本,null 使用默认 i18n "取消" -
player
private final org.bukkit.entity.Player playerThe target player to show the dialog / 显示对话框的目标玩家 -
title
The title text displayed in bold gold / 以粗体金色显示的标题文本 -
description
The description text displayed below title / 显示在标题下方的描述文本 -
onConfirm
Callback executed when player clicks confirm / 玩家点击确认时执行的回调 -
onCancel
Callback executed when player clicks cancel / 玩家点击取消时执行的回调
-
-
Constructor Details
-
ChatConfirm
public ChatConfirm(org.bukkit.entity.Player player, String title, String description, Runnable onConfirm, Runnable onCancel) Creates a chat confirmation dialog with default button text.
使用默认按钮文本创建聊天确认对话框。- Parameters:
player- the target player / 目标玩家title- the dialog title / 对话框标题description- the dialog description / 对话框描述onConfirm- callback for confirm action / 确认操作的回调onCancel- callback for cancel action / 取消操作的回调
-
ChatConfirm
public ChatConfirm(org.bukkit.entity.Player player, String title, String description, String confirmText, String cancelText, Runnable onConfirm, Runnable onCancel) Creates a chat confirmation dialog with custom button text.
使用自定义按钮文本创建聊天确认对话框。- Parameters:
player- the target player / 目标玩家title- the dialog title / 对话框标题description- the dialog description / 对话框描述confirmText- custom confirm button text / 自定义确认按钮文本cancelText- custom cancel button text / 自定义取消按钮文本onConfirm- callback for confirm action / 确认操作的回调onCancel- callback for cancel action / 取消操作的回调
-
-
Method Details
-
show
public void show()Show the confirm dialog.
显示确认对话框。 Displays the confirmation dialog in player's chat with:- Bold gold title text
- Description text
- Clickable green confirm button
- Clickable red cancel button
在玩家聊天中显示确认对话框,包含:
- 粗体金色标题文本
- 描述文本
- 可点击的绿色确认按钮
- 可点击的红色取消按钮
-
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
-