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.
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 callbacksprivate 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.
- Parameters:
callback- the callback to register- Returns:
- the UUID identifier for this callback
-
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()
-