Add further documentation to dialog API
This commit is contained in:
parent
e05560976b
commit
f1f5be18f9
@ -35,7 +35,7 @@ public final class DialogListDialog implements Dialog
|
|||||||
*/
|
*/
|
||||||
private int columns;
|
private int columns;
|
||||||
/**
|
/**
|
||||||
* The width of the dialog buttons (default: 150).
|
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
@SerializedName("button_width")
|
@SerializedName("button_width")
|
||||||
private int buttonWidth;
|
private int buttonWidth;
|
||||||
|
@ -31,7 +31,7 @@ public final class ServerLinksDialog implements Dialog
|
|||||||
*/
|
*/
|
||||||
private int columns;
|
private int columns;
|
||||||
/**
|
/**
|
||||||
* The width of the dialog buttons (default: 150).
|
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
@SerializedName("button_width")
|
@SerializedName("button_width")
|
||||||
private int buttonWidth;
|
private int buttonWidth;
|
||||||
|
@ -21,7 +21,7 @@ public class DialogAction
|
|||||||
*/
|
*/
|
||||||
private BaseComponent tooltip;
|
private BaseComponent tooltip;
|
||||||
/**
|
/**
|
||||||
* The width of the button (default: 150).
|
* The width of the button (default: 150, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
private int width;
|
private int width;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public class PlainMessageBody extends DialogBody
|
|||||||
*/
|
*/
|
||||||
private BaseComponent contents;
|
private BaseComponent contents;
|
||||||
/**
|
/**
|
||||||
* The maximum width (default: 200).
|
* The maximum width (default: 200, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
private int width;
|
private int width;
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Contains dialog extensions to the chat API.
|
||||||
|
*/
|
||||||
|
package net.md_5.bungee.api.dialog.chat;
|
@ -7,6 +7,9 @@ import lombok.ToString;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a checkbox input control.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -14,10 +17,22 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
public class BooleanInput extends DialogInput
|
public class BooleanInput extends DialogInput
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The input label.
|
||||||
|
*/
|
||||||
private BaseComponent label;
|
private BaseComponent label;
|
||||||
|
/**
|
||||||
|
* The initial value (default: false/unchecked).
|
||||||
|
*/
|
||||||
private boolean initial;
|
private boolean initial;
|
||||||
|
/**
|
||||||
|
* The string value to be submitted when true/checked (default: "true").
|
||||||
|
*/
|
||||||
@SerializedName("on_true")
|
@SerializedName("on_true")
|
||||||
private String onTrue;
|
private String onTrue;
|
||||||
|
/**
|
||||||
|
* The string value to be submitted when false/unchecked (default: "false").
|
||||||
|
*/
|
||||||
@SerializedName("on_false")
|
@SerializedName("on_false")
|
||||||
private String onFalse;
|
private String onFalse;
|
||||||
|
|
||||||
|
@ -2,12 +2,25 @@ package net.md_5.bungee.api.dialog.input;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a type of input which may be displayed/submitted with a form
|
||||||
|
* dialog.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
public class DialogInput
|
public class DialogInput
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The internal input type.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
private final String type;
|
private final String type;
|
||||||
|
/**
|
||||||
|
* The key corresponding to this input and associated with the value
|
||||||
|
* submitted.
|
||||||
|
*/
|
||||||
private final String key;
|
private final String key;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,29 @@ import lombok.Data;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an option choice which may form part of a
|
||||||
|
* {@link SingleOptionInput}.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
public class InputOption
|
public class InputOption
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The string value associated with this option, to be submitted when
|
||||||
|
* selected.
|
||||||
|
*/
|
||||||
private String id;
|
private String id;
|
||||||
|
/**
|
||||||
|
* The text to display for this option.
|
||||||
|
*/
|
||||||
private BaseComponent display;
|
private BaseComponent display;
|
||||||
|
/**
|
||||||
|
* Whether this option is the one initially selected. Only one option may
|
||||||
|
* have this value as true (default: first option).
|
||||||
|
*/
|
||||||
private boolean initial;
|
private boolean initial;
|
||||||
|
|
||||||
public InputOption(String id)
|
public InputOption(String id)
|
||||||
|
@ -6,6 +6,9 @@ import lombok.ToString;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a number slider input.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -14,28 +17,33 @@ public class NumberRangeInput extends DialogInput
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of the input (default 200)
|
* The width of the input (default: 200, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
private int width;
|
private int width;
|
||||||
/**
|
/**
|
||||||
* The label of the slider
|
* The label of the slider.
|
||||||
*/
|
*/
|
||||||
private BaseComponent label;
|
private BaseComponent label;
|
||||||
|
/**
|
||||||
|
* A translate key used to display the label value (default:
|
||||||
|
* options.generic_value).
|
||||||
|
*/
|
||||||
private String labelFormat;
|
private String labelFormat;
|
||||||
/**
|
/**
|
||||||
* The start position of the slider (leftmost position)
|
* The start position of the slider (leftmost position).
|
||||||
*/
|
*/
|
||||||
private float start;
|
private float start;
|
||||||
/**
|
/**
|
||||||
* The end position of the slider (rightmost position)
|
* The end position of the slider (rightmost position).
|
||||||
*/
|
*/
|
||||||
private float end;
|
private float end;
|
||||||
/**
|
/**
|
||||||
* The steps in which the input will be increased or decreased, or null if no specific steps
|
* The steps in which the input will be increased or decreased, or null if
|
||||||
|
* no specific steps.
|
||||||
*/
|
*/
|
||||||
private Float step;
|
private Float step;
|
||||||
/**
|
/**
|
||||||
* The initial value of number input, or null to fall back to the middle
|
* The initial value of number input, or null to fall back to the middle.
|
||||||
*/
|
*/
|
||||||
private Float initial;
|
private Float initial;
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.md_5.bungee.api.dialog.input;
|
package net.md_5.bungee.api.dialog.input;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -9,6 +10,9 @@ import lombok.ToString;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a single option (dropdown) input.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -16,10 +20,22 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
|||||||
public class SingleOptionInput extends DialogInput
|
public class SingleOptionInput extends DialogInput
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The width of the input (default: 200, minimum: 1, maximum: 1024).
|
||||||
|
*/
|
||||||
private int width;
|
private int width;
|
||||||
|
/**
|
||||||
|
* The input label.
|
||||||
|
*/
|
||||||
private BaseComponent label;
|
private BaseComponent label;
|
||||||
|
/**
|
||||||
|
* Whether the label is visible (default: true).
|
||||||
|
*/
|
||||||
@SerializedName("label_visible")
|
@SerializedName("label_visible")
|
||||||
private boolean labelVisible;
|
private boolean labelVisible;
|
||||||
|
/**
|
||||||
|
* The non-empty list of options to be selected from.
|
||||||
|
*/
|
||||||
private List<InputOption> options;
|
private List<InputOption> options;
|
||||||
|
|
||||||
public SingleOptionInput(String key, BaseComponent label, InputOption... options)
|
public SingleOptionInput(String key, BaseComponent label, InputOption... options)
|
||||||
@ -30,6 +46,8 @@ public class SingleOptionInput extends DialogInput
|
|||||||
public SingleOptionInput(String key, int width, BaseComponent label, boolean labelVisible, List<InputOption> options)
|
public SingleOptionInput(String key, int width, BaseComponent label, boolean labelVisible, List<InputOption> options)
|
||||||
{
|
{
|
||||||
super( "minecraft:single_option", key );
|
super( "minecraft:single_option", key );
|
||||||
|
Preconditions.checkArgument( options != null && !options.isEmpty(), "At least one option must be provided" );
|
||||||
|
|
||||||
this.width = width;
|
this.width = width;
|
||||||
this.label = label;
|
this.label = label;
|
||||||
this.labelVisible = labelVisible;
|
this.labelVisible = labelVisible;
|
||||||
|
@ -7,6 +7,9 @@ import lombok.ToString;
|
|||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a textbox input.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -15,26 +18,29 @@ public class TextInput extends DialogInput
|
|||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The width of this text input
|
* The width of this text input (default: 200, minimum: 1, maximum: 1024).
|
||||||
*/
|
*/
|
||||||
private int width;
|
private int width;
|
||||||
/**
|
/**
|
||||||
* The label of this text input
|
* The label of this text input.
|
||||||
*/
|
*/
|
||||||
private BaseComponent label;
|
private BaseComponent label;
|
||||||
/**
|
/**
|
||||||
* The visibility of this text inputs label
|
* The visibility of this text input's label.
|
||||||
*/
|
*/
|
||||||
@SerializedName("label_visible")
|
@SerializedName("label_visible")
|
||||||
private boolean labelVisible;
|
private boolean labelVisible;
|
||||||
/**
|
/**
|
||||||
* The initial value of this text input
|
* The initial value of this text input.
|
||||||
*/
|
*/
|
||||||
private String initial;
|
private String initial;
|
||||||
|
/**
|
||||||
|
* The maximum length of the input (default: 32).
|
||||||
|
*/
|
||||||
@SerializedName("max_length")
|
@SerializedName("max_length")
|
||||||
private int maxLength;
|
private int maxLength;
|
||||||
/**
|
/**
|
||||||
* if set, allows users to input multiple lines
|
* If present, allows users to input multiple lines.
|
||||||
*/
|
*/
|
||||||
private Multiline multiline;
|
private Multiline multiline;
|
||||||
|
|
||||||
@ -59,19 +65,21 @@ public class TextInput extends DialogInput
|
|||||||
this.multiline = multiline;
|
this.multiline = multiline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configuration data for a multiline input.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
|
||||||
@EqualsAndHashCode(callSuper = false)
|
|
||||||
public static class Multiline
|
public static class Multiline
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum length of input, or null to disable any limits
|
* The maximum length of input, or null to disable any limits.
|
||||||
*/
|
*/
|
||||||
@SerializedName("max_lines")
|
@SerializedName("max_lines")
|
||||||
private Integer maxLines;
|
private Integer maxLines;
|
||||||
/**
|
/**
|
||||||
* The height of this input, default value is 32
|
* The height of this input (default: 32, minimum: 1, maximum: 512).
|
||||||
*/
|
*/
|
||||||
private Integer height = 32;
|
private Integer height = 32;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Represents the various input controls which may be present on form dialogs.
|
||||||
|
*/
|
||||||
|
package net.md_5.bungee.api.dialog.input;
|
@ -5,6 +5,10 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a command on form submission. If the command requires a permission
|
||||||
|
* higher than 0, a confirmation dialog will be shown by the client.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -12,6 +16,14 @@ import lombok.experimental.Accessors;
|
|||||||
public class CommandTemplateSubmission extends DialogSubmission
|
public class CommandTemplateSubmission extends DialogSubmission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The template to be applied, where variables of the form
|
||||||
|
* <code>$(key)</code> will be replaced by their
|
||||||
|
* {@link net.md_5.bungee.api.dialog.input.DialogInput#key} value.
|
||||||
|
* <br>
|
||||||
|
* The <code>action</code> key is special and will be replaced with the
|
||||||
|
* {@link net.md_5.bungee.api.dialog.action.DialogSubmitAction#id}.
|
||||||
|
*/
|
||||||
private String template;
|
private String template;
|
||||||
|
|
||||||
public CommandTemplateSubmission(String template)
|
public CommandTemplateSubmission(String template)
|
||||||
|
@ -5,6 +5,9 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits the form with the given ID and all values as a payload.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -12,6 +15,9 @@ import lombok.experimental.Accessors;
|
|||||||
public class CustomFormSubmission extends DialogSubmission
|
public class CustomFormSubmission extends DialogSubmission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespaced key of the submission.
|
||||||
|
*/
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public CustomFormSubmission(String id)
|
public CustomFormSubmission(String id)
|
||||||
|
@ -5,6 +5,10 @@ import lombok.EqualsAndHashCode;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Submits the form with the given ID and a single payload specified by the
|
||||||
|
* template.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
@ -12,7 +16,18 @@ import lombok.experimental.Accessors;
|
|||||||
public class CustomTemplateSubmission extends DialogSubmission
|
public class CustomTemplateSubmission extends DialogSubmission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The namespaced key of the submission.
|
||||||
|
*/
|
||||||
private String id;
|
private String id;
|
||||||
|
/**
|
||||||
|
* The template to be applied, where variables of the form
|
||||||
|
* <code>$(key)</code> will be replaced by their
|
||||||
|
* {@link net.md_5.bungee.api.dialog.input.DialogInput#key} value.
|
||||||
|
* <br>
|
||||||
|
* The <code>action</code> key is special and will be replaced with the
|
||||||
|
* {@link net.md_5.bungee.api.dialog.action.DialogSubmitAction#id}.
|
||||||
|
*/
|
||||||
private String template;
|
private String template;
|
||||||
|
|
||||||
public CustomTemplateSubmission(String id, String template)
|
public CustomTemplateSubmission(String id, String template)
|
||||||
|
@ -2,11 +2,19 @@ package net.md_5.bungee.api.dialog.submit;
|
|||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents an action which may be taken on form dialog submission.
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
public class DialogSubmission
|
public class DialogSubmission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The internal submissions type.
|
||||||
|
*/
|
||||||
|
@ApiStatus.Internal
|
||||||
private final String type;
|
private final String type;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* Represents the various submissions actions of form dialogs.
|
||||||
|
*/
|
||||||
|
package net.md_5.bungee.api.dialog.submit;
|
Loading…
Reference in New Issue
Block a user