mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
fancydialogs: Add support for multiple actions
This commit is contained in:
@@ -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()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
package com.fancyinnovations.fancydialogs.api.data;
|
||||
|
||||
public abstract class DialogAction {
|
||||
}
|
||||
@@ -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
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user