mirror of
https://github.com/FancyInnovations/FancyPlugins.git
synced 2025-12-06 07:43:36 +00:00
packets: Add support for notice dialogs
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
package de.oliver.fancysitula.api.dialogs;
|
||||
|
||||
import de.oliver.fancysitula.api.dialogs.body.FS_DialogBody;
|
||||
import de.oliver.fancysitula.api.dialogs.inputs.FS_DialogInput;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_CommonDialogData {
|
||||
|
||||
private String title;
|
||||
private @Nullable String externalTitle;
|
||||
private boolean canCloseWithEscape;
|
||||
private boolean pause;
|
||||
private FS_DialogAction afterAction;
|
||||
private List<FS_DialogBody> body;
|
||||
private List<FS_DialogInput> inputs;
|
||||
|
||||
public FS_CommonDialogData(String title, @Nullable String externalTitle, boolean canCloseWithEscape, boolean pause, FS_DialogAction afterAction, List<FS_DialogBody> body, List<FS_DialogInput> inputs) {
|
||||
this.title = title;
|
||||
this.externalTitle = externalTitle;
|
||||
this.canCloseWithEscape = canCloseWithEscape;
|
||||
this.pause = pause;
|
||||
this.afterAction = afterAction;
|
||||
this.body = body;
|
||||
this.inputs = inputs;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public @Nullable String getExternalTitle() {
|
||||
return externalTitle;
|
||||
}
|
||||
|
||||
public void setExternalTitle(@Nullable String externalTitle) {
|
||||
this.externalTitle = externalTitle;
|
||||
}
|
||||
|
||||
public boolean isCanCloseWithEscape() {
|
||||
return canCloseWithEscape;
|
||||
}
|
||||
|
||||
public void setCanCloseWithEscape(boolean canCloseWithEscape) {
|
||||
this.canCloseWithEscape = canCloseWithEscape;
|
||||
}
|
||||
|
||||
public boolean isPause() {
|
||||
return pause;
|
||||
}
|
||||
|
||||
public void setPause(boolean pause) {
|
||||
this.pause = pause;
|
||||
}
|
||||
|
||||
public FS_DialogAction getAfterAction() {
|
||||
return afterAction;
|
||||
}
|
||||
|
||||
public void setAfterAction(FS_DialogAction afterAction) {
|
||||
this.afterAction = afterAction;
|
||||
}
|
||||
|
||||
public List<FS_DialogBody> getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(List<FS_DialogBody> body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public List<FS_DialogInput> getInputs() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
public void setInputs(List<FS_DialogInput> inputs) {
|
||||
this.inputs = inputs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package de.oliver.fancysitula.api.dialogs;
|
||||
|
||||
public enum FS_DialogAction {
|
||||
CLOSE(0, "close"),
|
||||
NONE(1, "none"),
|
||||
WAIT_FOR_RESPONSE(2, "wait_for_response");
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
FS_DialogAction(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package de.oliver.fancysitula.api.dialogs.actions;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FS_CommonButtonData {
|
||||
|
||||
private String label;
|
||||
private @Nullable String tooltip;
|
||||
private int width;
|
||||
|
||||
public FS_CommonButtonData(String label, @Nullable String tooltip, int width) {
|
||||
this.label = label;
|
||||
this.tooltip = tooltip;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public @Nullable String getTooltip() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
public void setTooltip(@Nullable String tooltip) {
|
||||
this.tooltip = tooltip;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.oliver.fancysitula.api.dialogs.actions;
|
||||
|
||||
public class FS_DialogActionButton {
|
||||
|
||||
private FS_CommonButtonData buttonData;
|
||||
private FS_DialogActionButtonAction action;
|
||||
|
||||
public FS_DialogActionButton(FS_CommonButtonData buttonData, FS_DialogActionButtonAction action) {
|
||||
this.buttonData = buttonData;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public FS_CommonButtonData getButtonData() {
|
||||
return buttonData;
|
||||
}
|
||||
|
||||
public void setButtonData(FS_CommonButtonData buttonData) {
|
||||
this.buttonData = buttonData;
|
||||
}
|
||||
|
||||
public FS_DialogActionButtonAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(FS_DialogActionButtonAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.oliver.fancysitula.api.dialogs.actions;
|
||||
|
||||
public interface FS_DialogActionButtonAction {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package de.oliver.fancysitula.api.dialogs.actions;
|
||||
|
||||
public class FS_DialogRunCommandAction implements FS_DialogActionButtonAction {
|
||||
|
||||
private String command;
|
||||
|
||||
public FS_DialogRunCommandAction(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.oliver.fancysitula.api.dialogs.body;
|
||||
|
||||
public interface FS_DialogBody {
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package de.oliver.fancysitula.api.dialogs.body;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FS_DialogItemBody implements FS_DialogBody {
|
||||
|
||||
private ItemStack item;
|
||||
private @Nullable FS_DialogTextBody description;
|
||||
private boolean showDecorations;
|
||||
private boolean showTooltip;
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public FS_DialogItemBody(ItemStack item, @Nullable FS_DialogTextBody description, boolean showDecorations, boolean showTooltip, int width, int height) {
|
||||
this.item = item;
|
||||
this.description = description;
|
||||
this.showDecorations = showDecorations;
|
||||
this.showTooltip = showTooltip;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
public @Nullable FS_DialogTextBody getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(@Nullable FS_DialogTextBody description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isShowDecorations() {
|
||||
return showDecorations;
|
||||
}
|
||||
|
||||
public void setShowDecorations(boolean showDecorations) {
|
||||
this.showDecorations = showDecorations;
|
||||
}
|
||||
|
||||
public boolean isShowTooltip() {
|
||||
return showTooltip;
|
||||
}
|
||||
|
||||
public void setShowTooltip(boolean showTooltip) {
|
||||
this.showTooltip = showTooltip;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.oliver.fancysitula.api.dialogs.body;
|
||||
|
||||
public class FS_DialogTextBody implements FS_DialogBody {
|
||||
|
||||
private String text;
|
||||
private int width;
|
||||
|
||||
public FS_DialogTextBody(String text, int width) {
|
||||
this.text = text;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
public class FS_DialogBooleanInput implements FS_DialogInputControl {
|
||||
|
||||
private String label;
|
||||
private boolean initial;
|
||||
private String onTrue;
|
||||
private String onFalse;
|
||||
|
||||
public FS_DialogBooleanInput(String label, boolean initial, String onTrue, String onFalse) {
|
||||
this.label = label;
|
||||
this.initial = initial;
|
||||
this.onTrue = onTrue;
|
||||
this.onFalse = onFalse;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
public void setInitial(boolean initial) {
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
public String getOnTrue() {
|
||||
return onTrue;
|
||||
}
|
||||
|
||||
public void setOnTrue(String onTrue) {
|
||||
this.onTrue = onTrue;
|
||||
}
|
||||
|
||||
public String getOnFalse() {
|
||||
return onFalse;
|
||||
}
|
||||
|
||||
public void setOnFalse(String onFalse) {
|
||||
this.onFalse = onFalse;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
public class FS_DialogInput {
|
||||
|
||||
private String key;
|
||||
private FS_DialogInputControl control;
|
||||
|
||||
public FS_DialogInput(String key, FS_DialogInputControl control) {
|
||||
this.key = key;
|
||||
this.control = control;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public FS_DialogInputControl getControl() {
|
||||
return control;
|
||||
}
|
||||
|
||||
public void setControl(FS_DialogInputControl control) {
|
||||
this.control = control;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
public interface FS_DialogInputControl {
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FS_DialogNumberRangeInput implements FS_DialogInputControl {
|
||||
|
||||
private int width;
|
||||
private String label;
|
||||
private String labelFormat;
|
||||
private float start;
|
||||
private float end;
|
||||
private @Nullable Float initial;
|
||||
private @Nullable Float step;
|
||||
|
||||
public FS_DialogNumberRangeInput(int width, String label, String labelFormat, float start, float end, @Nullable Float initial, @Nullable Float step) {
|
||||
this.width = width;
|
||||
this.label = label;
|
||||
this.labelFormat = labelFormat;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.initial = initial;
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public String getLabelFormat() {
|
||||
return labelFormat;
|
||||
}
|
||||
|
||||
public void setLabelFormat(String labelFormat) {
|
||||
this.labelFormat = labelFormat;
|
||||
}
|
||||
|
||||
public float getStart() {
|
||||
return start;
|
||||
}
|
||||
|
||||
public void setStart(float start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
public float getEnd() {
|
||||
return end;
|
||||
}
|
||||
|
||||
public void setEnd(float end) {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public @Nullable Float getInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
public void setInitial(@Nullable Float initial) {
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
public @Nullable Float getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public void setStep(@Nullable Float step) {
|
||||
this.step = step;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FS_DialogSingleOptionInput implements FS_DialogInputControl {
|
||||
|
||||
private int width;
|
||||
private List<Entry> entries;
|
||||
private String label;
|
||||
private boolean isLabelVisible;
|
||||
|
||||
public FS_DialogSingleOptionInput(int width, List<Entry> entries, String label, boolean isLabelVisible) {
|
||||
this.width = width;
|
||||
this.entries = entries;
|
||||
this.label = label;
|
||||
this.isLabelVisible = isLabelVisible;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public List<Entry> getEntries() {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public void setEntries(List<Entry> entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public boolean isLabelVisible() {
|
||||
return isLabelVisible;
|
||||
}
|
||||
|
||||
public void setLabelVisible(boolean labelVisible) {
|
||||
isLabelVisible = labelVisible;
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
|
||||
private String id;
|
||||
private @Nullable String display;
|
||||
private boolean initial;
|
||||
|
||||
public Entry(String id, @Nullable String display, boolean initial) {
|
||||
this.id = id;
|
||||
this.display = display;
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public @Nullable String getDisplay() {
|
||||
return display;
|
||||
}
|
||||
|
||||
public void setDisplay(@Nullable String display) {
|
||||
this.display = display;
|
||||
}
|
||||
|
||||
public boolean isInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
public void setInitial(boolean initial) {
|
||||
this.initial = initial;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package de.oliver.fancysitula.api.dialogs.inputs;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class FS_DialogTextInput implements FS_DialogInputControl {
|
||||
|
||||
private int width;
|
||||
private String label;
|
||||
private boolean isLabelVisible;
|
||||
private String initial;
|
||||
private int maxLength;
|
||||
private @Nullable MultilineOptions multilineOptions;
|
||||
|
||||
public FS_DialogTextInput(int width, String label, boolean isLabelVisible, String initial, int maxLength, @Nullable MultilineOptions multilineOptions) {
|
||||
this.width = width;
|
||||
this.label = label;
|
||||
this.isLabelVisible = isLabelVisible;
|
||||
this.initial = initial;
|
||||
this.maxLength = maxLength;
|
||||
this.multilineOptions = multilineOptions;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return width;
|
||||
}
|
||||
|
||||
public void setWidth(int width) {
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public boolean isLabelVisible() {
|
||||
return isLabelVisible;
|
||||
}
|
||||
|
||||
public void setLabelVisible(boolean labelVisible) {
|
||||
isLabelVisible = labelVisible;
|
||||
}
|
||||
|
||||
public String getInitial() {
|
||||
return initial;
|
||||
}
|
||||
|
||||
public void setInitial(String initial) {
|
||||
this.initial = initial;
|
||||
}
|
||||
|
||||
public int getMaxLength() {
|
||||
return maxLength;
|
||||
}
|
||||
|
||||
public void setMaxLength(int maxLength) {
|
||||
this.maxLength = maxLength;
|
||||
}
|
||||
|
||||
public @Nullable MultilineOptions getMultilineOptions() {
|
||||
return multilineOptions;
|
||||
}
|
||||
|
||||
public void setMultilineOptions(@Nullable MultilineOptions multilineOptions) {
|
||||
this.multilineOptions = multilineOptions;
|
||||
}
|
||||
|
||||
public static class MultilineOptions {
|
||||
|
||||
private @Nullable Integer maxLines;
|
||||
private @Nullable Integer height;
|
||||
|
||||
public MultilineOptions(@Nullable Integer maxLines, @Nullable Integer height) {
|
||||
this.maxLines = maxLines;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public @Nullable Integer getMaxLines() {
|
||||
return maxLines;
|
||||
}
|
||||
|
||||
public void setMaxLines(@Nullable Integer maxLines) {
|
||||
this.maxLines = maxLines;
|
||||
}
|
||||
|
||||
public @Nullable Integer getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public void setHeight(@Nullable Integer height) {
|
||||
this.height = height;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package de.oliver.fancysitula.api.dialogs.types;
|
||||
|
||||
import de.oliver.fancysitula.api.dialogs.FS_CommonDialogData;
|
||||
import de.oliver.fancysitula.api.dialogs.FS_Dialog;
|
||||
import de.oliver.fancysitula.api.dialogs.actions.FS_DialogActionButton;
|
||||
|
||||
public class FS_NoticeDialog implements FS_Dialog {
|
||||
|
||||
private FS_CommonDialogData dialogData;
|
||||
private FS_DialogActionButton actionButton;
|
||||
|
||||
public FS_NoticeDialog(FS_CommonDialogData dialogData, FS_DialogActionButton actionButton) {
|
||||
this.dialogData = dialogData;
|
||||
this.actionButton = actionButton;
|
||||
}
|
||||
|
||||
public FS_CommonDialogData getDialogData() {
|
||||
return dialogData;
|
||||
}
|
||||
|
||||
public void setDialogData(FS_CommonDialogData dialogData) {
|
||||
this.dialogData = dialogData;
|
||||
}
|
||||
|
||||
public FS_DialogActionButton getActionButton() {
|
||||
return actionButton;
|
||||
}
|
||||
|
||||
public void setActionButton(FS_DialogActionButton actionButton) {
|
||||
this.actionButton = actionButton;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user