fancydialogs: Add support for multiple actions

This commit is contained in:
Oliver
2025-06-19 14:36:23 +02:00
parent bd4a8f2f23
commit b8f57fda38
7 changed files with 96 additions and 46 deletions

View File

@@ -35,14 +35,12 @@ public class ConfirmationDialog {
new DialogButton(
this.confirmText,
this.confirmText,
"confirm",
""
List.of()
),
new DialogButton(
this.cancelText,
this.cancelText,
"cancel",
""
List.of()
)
)
);

View File

@@ -1,4 +0,0 @@
package com.fancyinnovations.fancydialogs.api.data;
public abstract class DialogAction {
}

View File

@@ -1,9 +1,43 @@
package com.fancyinnovations.fancydialogs.api.data;
public record DialogButton(
String label,
String tooltip,
String action,
String actionData
) {
import java.util.List;
import java.util.UUID;
public class DialogButton {
private final transient String id;
private final String label;
private final String tooltip;
private final List<DialogAction> actions;
public DialogButton(String label, String tooltip, List<DialogAction> actions) {
this.id = UUID.randomUUID().toString();
this.label = label;
this.tooltip = tooltip;
this.actions = actions;
}
public String id() {
return id;
}
public String label() {
return label;
}
public String tooltip() {
return tooltip;
}
public List<DialogAction> actions() {
return actions;
}
public record DialogAction(
String name,
String data
) {
}
}

View File

@@ -12,4 +12,14 @@ public record DialogData(
@NotNull List<DialogButton> buttons
) {
public DialogButton getButtonById(@NotNull String buttonId) {
for (DialogButton button : buttons) {
if (button.id().equals(buttonId)) {
return button;
}
}
return null;
}
}