Package com.ultikits.ultitools.manager
Class ChatCallbackManager
java.lang.Object
com.ultikits.ultitools.manager.ChatCallbackManager
Manager for chat-based callback commands.
Enables clickable chat messages that execute callbacks when clicked. Registers a hidden command /ultitools_callback that executes registered callbacks by their UUID.
聊天回调命令管理器。 支持可点击的聊天消息,点击时执行回调。 注册一个隐藏命令 /ultitools_callback,通过 UUID 执行已注册的回调。
Usage Example / 使用示例:
VoidFunc0 callback = () -> player.sendMessage("Clicked!");
UUID callbackId = ChatCallbackManager.registerCallback(callback);
// Create clickable text that runs: /ultitools_callback <callbackId>
Component text = Component.text("[Click Me]")
.clickEvent(ClickEvent.runCommand("/ultitools_callback " + callbackId));
- Since:
- 6.0.0
- Author:
- wisdomme
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThread-safe storage for pending callbacks / 待处理回调的线程安全存储private static booleanInitialization flag to prevent multiple command registrations / 防止多次命令注册的初始化标志 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static org.bukkit.command.CommandMapGet the CommandMap from Bukkit's PluginManager.private static voidstatic UUIDregisterCallback(Runnable callback) Registers a callback and returns its unique identifier.
-
Field Details
-
callbacks
Thread-safe storage for pending callbacks / 待处理回调的线程安全存储 -
initialized
private static boolean initializedInitialization flag to prevent multiple command registrations / 防止多次命令注册的初始化标志
-
-
Constructor Details
-
ChatCallbackManager
public ChatCallbackManager()
-
-
Method Details
-
registerCallback
Registers a callback and returns its unique identifier.The callback will be executed once when a player runs the command /ultitools_callback <uuid>. After execution, the callback is removed.
注册一个回调并返回其唯一标识符。 当玩家运行命令 /ultitools_callback <uuid> 时,回调将被执行一次,执行后移除。
- Parameters:
callback- the callback to register / 要注册的回调- Returns:
- the UUID identifier for this callback / 此回调的 UUID 标识符
-
getCommandMap
private static org.bukkit.command.CommandMap getCommandMap()Get the CommandMap from Bukkit's PluginManager. Returns null if the PluginManager is not a SimplePluginManager (e.g., in test environments). -
initialize
private static void initialize()
-