Class ChatConfirm

java.lang.Object
com.ultikits.ultitools.widgets.impl.ChatConfirm
All Implemented Interfaces:
Confirm

public class ChatConfirm extends Object implements 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

    Fields
    Modifier and Type
    Field
    Description
    private String
    Custom cancel button text, null uses default i18n "取消" / 自定义取消按钮文本,null 使用默认 i18n "取消"
    private String
    Custom confirm button text, null uses default i18n "OK" / 自定义确认按钮文本,null 使用默认 i18n "OK"
    private final String
    The description text displayed below title / 显示在标题下方的描述文本
    private final Runnable
    Callback executed when player clicks cancel / 玩家点击取消时执行的回调
    private final Runnable
    Callback executed when player clicks confirm / 玩家点击确认时执行的回调
    private final org.bukkit.entity.Player
    The target player to show the dialog / 显示对话框的目标玩家
    private final String
    The title text displayed in bold gold / 以粗体金色显示的标题文本
  • Constructor Summary

    Constructors
    Constructor
    Description
    ChatConfirm(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 Type
    Method
    Description
    Get the cancel text.
    Get the confirm text.
    void
    Show the confirm dialog.

    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 default i18n "OK" / 自定义确认按钮文本,null 使用默认 i18n "OK"
    • cancelText

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

      private final org.bukkit.entity.Player player
      The target player to show the dialog / 显示对话框的目标玩家
    • title

      private final String title
      The title text displayed in bold gold / 以粗体金色显示的标题文本
    • description

      private final String description
      The description text displayed below title / 显示在标题下方的描述文本
    • onConfirm

      private final Runnable onConfirm
      Callback executed when player clicks confirm / 玩家点击确认时执行的回调
    • onCancel

      private final Runnable 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

      在玩家聊天中显示确认对话框,包含:

      • 粗体金色标题文本
      • 描述文本
      • 可点击的绿色确认按钮
      • 可点击的红色取消按钮
      Specified by:
      show in interface Confirm
    • 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