mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
packets, fancydialogs: Refactor custom action handling to use a map for additional data
This commit is contained in:
@@ -35,12 +35,14 @@ public class ConfirmationDialog {
|
||||
new DialogButton(
|
||||
this.confirmText,
|
||||
this.confirmText,
|
||||
"confirm"
|
||||
"confirm",
|
||||
""
|
||||
),
|
||||
new DialogButton(
|
||||
this.cancelText,
|
||||
this.cancelText,
|
||||
"cancel"
|
||||
"cancel",
|
||||
""
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.fancyinnovations.fancydialogs.api.data;
|
||||
public record DialogButton(
|
||||
String label,
|
||||
String tooltip,
|
||||
String action
|
||||
String action,
|
||||
String actionData
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DialogImpl extends Dialog {
|
||||
|
||||
@@ -46,7 +47,14 @@ public class DialogImpl extends Dialog {
|
||||
button.tooltip(),
|
||||
150 // default button width
|
||||
),
|
||||
new FS_DialogCustomAction("fancydialogs_dialog_action", button.action())
|
||||
new FS_DialogCustomAction(
|
||||
"fancydialogs_dialog_action",
|
||||
Map.of(
|
||||
"dialog_id", id,
|
||||
"action_id", button.action(),
|
||||
"action_data", button.actionData()
|
||||
)
|
||||
)
|
||||
);
|
||||
actions.add(fsDialogActionButton);
|
||||
}
|
||||
|
||||
@@ -31,6 +31,12 @@ public class CustomClickActionPacketListener {
|
||||
if (!packet.getId().namespace().equals("fancysitula") && !packet.getId().namespace().equals("fancydialogs_dialog_action")) {
|
||||
return; // Ignore packets not related to FancyDialogs
|
||||
}
|
||||
|
||||
String dialogId = packet.getPayload().get("dialog_id");
|
||||
String actionId = packet.getPayload().get("action_id");
|
||||
String actionData = packet.getPayload().get("action_data");
|
||||
|
||||
// TODO process the dialog action
|
||||
}
|
||||
|
||||
public FS_PacketListener getPacketListener() {
|
||||
|
||||
@@ -44,12 +44,14 @@ public class DefaultDialogs {
|
||||
new DialogButton(
|
||||
"<color:#ff4f19>Close</color>",
|
||||
"<color:#ff4f19>Enjoy using FancyDialogs</color>",
|
||||
"close_dialog"
|
||||
"close_dialog",
|
||||
""
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#ffd000>Run command</color>",
|
||||
"<color:#ff4f19>Click to give yourself an apple :)</color>",
|
||||
"run_command:/give {player} apple 1"
|
||||
"run_command:",
|
||||
"give {player} apple 1"
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -72,22 +74,26 @@ public class DefaultDialogs {
|
||||
new DialogButton(
|
||||
"<color:red>Read the rules</color>",
|
||||
"<color:red>Click to read our rules!</color>",
|
||||
"message:<click:open_url:'{LINK TO RULES}'>Visit our rules</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO RULES}'>Visit our rules</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#00ff5e>Start playing</color>",
|
||||
"<color:#00ff5e>Click to start playing!</color>",
|
||||
"close_dialog"
|
||||
"close_dialog",
|
||||
""
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#1787ff>Join our Discord</color>",
|
||||
"<color:#1787ff>Click to join our Discord server!</color>",
|
||||
"message:<click:open_url:'{LINK TO DISC SERVER}'>Join our Discord server</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO DISC SERVER}'>Join our Discord server</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#ffee00>Visit our website</color>",
|
||||
"<color:#ffee00>Click to visit our website!</color>",
|
||||
"message:<click:open_url:'{LINK TO WEBSITE}'>Visit our website</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO WEBSITE}'>Visit our website</click>!"
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -107,27 +113,32 @@ public class DefaultDialogs {
|
||||
new DialogButton(
|
||||
"<color:#ffee00>Visit our website</color>",
|
||||
"<color:#ffee00>Click to visit our website!</color>",
|
||||
"message:<click:open_url:'{LINK TO WEBSITE}'>Visit our website</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO WEBSITE}'>Visit our website</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#ffee00>Read the rules</color>",
|
||||
"<color:#ffee00>Click to read our rules!</color>",
|
||||
"message:<click:open_url:'{LINK TO RULES}'>Visit our rules</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO RULES}'>Visit our rules</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#ffee00>Join our Discord</color>",
|
||||
"<color:#ffee00>Click to join our Discord server!</color>",
|
||||
"message:<click:open_url:'{LINK TO DISCORD}'>Join our Discord server</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO DISCORD}'>Join our Discord server</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:#ffee00>Support us</color>",
|
||||
"<color:#ffee00>Click to support us!</color>",
|
||||
"message:<click:open_url:'{LINK TO SUPPORT}'>Support us</click>!"
|
||||
"message",
|
||||
"<click:open_url:'{LINK TO SUPPORT}'>Support us</click>!"
|
||||
),
|
||||
new DialogButton(
|
||||
"<color:red>Close</color>",
|
||||
"<color:red>Click to close this dialog!</color>",
|
||||
"close_dialog"
|
||||
"close_dialog",
|
||||
""
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user