-
-
Notifications
You must be signed in to change notification settings - Fork 1
Register custom action
Huynh Tien edited this page Jul 3, 2025
·
1 revision
The DialogManager#registerCustomAction can be used to register custom actions so that the manager can listen to incoming events and trigger the actions.
The parameters of the actions include an UUID of the player who triggers the action and a Map<String, String> containing the keys and values of all inputs in the dialog.
String actionId = "test_action_id";
dialogManager.registerCustomAction(actionId, (uuid, map) -> {
System.out.println("Your name is " + map.get("name"));
});You can now use the id in your dynamicAction
Here is the example for the sample Confirmation Dialog:
dialogManager.createConfirmationDialog()
.title("Sample Dialog")
.canCloseWithEscape(true)
.afterAction(Dialog.AfterAction.CLOSE)
.body(builder -> builder.text().text("This is a sample dialog. Do you want to proceed?"))
.input("name", builder -> builder.textInput().label("Enter your name:"))
.yesAction(builder -> builder.label("Confirm").dynamicCustom(actionId))
.noAction(builder -> builder.label("Cancel"));