#3831: Respect vanilla limits in dialogs
This commit is contained in:
parent
f8de305477
commit
fbbcc454d5
@ -3,6 +3,7 @@ package net.md_5.bungee.api.dialog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.dialog.action.DialogClickAction;
|
||||
@ -19,6 +20,7 @@ import net.md_5.bungee.api.dialog.action.DialogClickAction;
|
||||
public final class ConfirmationDialog implements Dialog
|
||||
{
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
@ -30,7 +32,7 @@ public final class ConfirmationDialog implements Dialog
|
||||
*/
|
||||
private DialogClickAction no;
|
||||
|
||||
public ConfirmationDialog(DialogBase base)
|
||||
public ConfirmationDialog(@NonNull DialogBase base)
|
||||
{
|
||||
this( base, null, null );
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -22,6 +23,7 @@ public final class DialogBase
|
||||
/**
|
||||
* The mandatory dialog title.
|
||||
*/
|
||||
@NonNull
|
||||
private final BaseComponent title;
|
||||
/**
|
||||
* The name which is used for any buttons leading to this dialog (eg from a
|
||||
@ -37,5 +39,5 @@ public final class DialogBase
|
||||
* Whether this dialog can be closed with the escape key (default: true).
|
||||
*/
|
||||
@SerializedName("can_close_with_escape")
|
||||
private boolean canCloseWithEscape = true;
|
||||
private Boolean canCloseWithEscape;
|
||||
}
|
||||
|
@ -1,10 +1,12 @@
|
||||
package net.md_5.bungee.api.dialog;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -19,6 +21,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
public final class DialogListDialog implements Dialog
|
||||
{
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
@ -33,24 +36,38 @@ public final class DialogListDialog implements Dialog
|
||||
/**
|
||||
* The number of columns for the dialog buttons (default: 2).
|
||||
*/
|
||||
private int columns;
|
||||
private Integer columns;
|
||||
/**
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
@SerializedName("button_width")
|
||||
private int buttonWidth;
|
||||
private Integer buttonWidth;
|
||||
|
||||
public DialogListDialog(DialogBase base, Dialog... dialogs)
|
||||
public DialogListDialog(@NonNull DialogBase base, Dialog... dialogs)
|
||||
{
|
||||
this( base, Arrays.asList( dialogs ), null, 2, 150 );
|
||||
this( base, Arrays.asList( dialogs ), null, null, null );
|
||||
}
|
||||
|
||||
public DialogListDialog(DialogBase base, List<Dialog> dialogs, ClickEvent onCancel, int columns, int buttonWidth)
|
||||
public DialogListDialog(@NonNull DialogBase base, List<Dialog> dialogs, ClickEvent onCancel, Integer columns, Integer buttonWidth)
|
||||
{
|
||||
this.base = base;
|
||||
this.dialogs = dialogs;
|
||||
this.onCancel = onCancel;
|
||||
columns( columns );
|
||||
buttonWidth( buttonWidth );
|
||||
}
|
||||
|
||||
public DialogListDialog columns(Integer columns)
|
||||
{
|
||||
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
|
||||
this.columns = columns;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DialogListDialog buttonWidth(Integer buttonWidth)
|
||||
{
|
||||
Preconditions.checkArgument( buttonWidth == null || ( buttonWidth >= 1 && buttonWidth <= 1024 ), "buttonWidth must be between 1 and 1024" );
|
||||
this.buttonWidth = buttonWidth;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -22,34 +23,43 @@ import net.md_5.bungee.api.dialog.action.DialogClickAction;
|
||||
public final class MultiActionDialog implements Dialog
|
||||
{
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
* The action buttons in the dialog. At least one must be provided.
|
||||
*/
|
||||
@NonNull
|
||||
private List<DialogClickAction> actions;
|
||||
/**
|
||||
* The number of columns for the dialog buttons (default: 2).
|
||||
*/
|
||||
private int columns;
|
||||
private Integer columns;
|
||||
/**
|
||||
* The {@link ClickEvent} activated when the dialog is cancelled.
|
||||
*/
|
||||
@SerializedName("on_cancel")
|
||||
private ClickEvent onCancel;
|
||||
|
||||
public MultiActionDialog(DialogBase base, DialogClickAction... actions)
|
||||
public MultiActionDialog(@NonNull DialogBase base, @NonNull DialogClickAction... actions)
|
||||
{
|
||||
this( base, Arrays.asList( actions ), 2, null );
|
||||
}
|
||||
|
||||
public MultiActionDialog(DialogBase base, List<DialogClickAction> actions, int columns, ClickEvent onCancel)
|
||||
public MultiActionDialog(@NonNull DialogBase base, @NonNull List<DialogClickAction> actions, Integer columns, ClickEvent onCancel)
|
||||
{
|
||||
Preconditions.checkArgument( actions != null && !actions.isEmpty(), "At least one action must be provided" );
|
||||
Preconditions.checkArgument( !actions.isEmpty(), "At least one action must be provided" );
|
||||
|
||||
this.base = base;
|
||||
this.actions = actions;
|
||||
this.columns = columns;
|
||||
columns( columns );
|
||||
this.onCancel = onCancel;
|
||||
}
|
||||
|
||||
public MultiActionDialog columns(Integer columns)
|
||||
{
|
||||
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
|
||||
this.columns = columns;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.dialog.action.DialogSubmitAction;
|
||||
@ -22,39 +23,49 @@ public final class MultiActionInputFormDialog implements Dialog
|
||||
{
|
||||
|
||||
@Accessors(fluent = false)
|
||||
@NonNull
|
||||
private DialogBase base;
|
||||
/**
|
||||
* The inputs to the dialog. At least one input must be provided.
|
||||
*/
|
||||
@NonNull
|
||||
private List<DialogInput> inputs;
|
||||
/**
|
||||
* The action/submit buttons for the dialog. At least one action must be
|
||||
* provided.
|
||||
*/
|
||||
@NonNull
|
||||
private List<DialogSubmitAction> actions;
|
||||
/**
|
||||
* The amount of columns (default: 2)
|
||||
*/
|
||||
private int columns;
|
||||
private Integer columns;
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action)
|
||||
public MultiActionInputFormDialog(@NonNull DialogBase base, @NonNull DialogInput input, @NonNull DialogSubmitAction action)
|
||||
{
|
||||
this( base, Arrays.asList( input ), Arrays.asList( action ), 2 );
|
||||
}
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action, int columns)
|
||||
public MultiActionInputFormDialog(@NonNull DialogBase base, @NonNull DialogInput input, @NonNull DialogSubmitAction action, Integer columns)
|
||||
{
|
||||
this( base, Arrays.asList( input ), Arrays.asList( action ), columns );
|
||||
}
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions, int columns)
|
||||
public MultiActionInputFormDialog(@NonNull DialogBase base, @NonNull List<DialogInput> inputs, @NonNull List<DialogSubmitAction> actions, Integer columns)
|
||||
{
|
||||
Preconditions.checkArgument( inputs != null && !inputs.isEmpty(), "At least one input must be provided" );
|
||||
Preconditions.checkArgument( actions != null && !actions.isEmpty(), "At least one action must be provided" );
|
||||
Preconditions.checkArgument( !inputs.isEmpty(), "At least one input must be provided" );
|
||||
Preconditions.checkArgument( !actions.isEmpty(), "At least one action must be provided" );
|
||||
|
||||
this.base = base;
|
||||
this.inputs = inputs;
|
||||
this.actions = actions;
|
||||
columns( columns );
|
||||
}
|
||||
|
||||
public MultiActionInputFormDialog columns(Integer columns)
|
||||
{
|
||||
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
|
||||
this.columns = columns;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee.api.dialog;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.dialog.action.DialogClickAction;
|
||||
@ -19,6 +20,7 @@ import net.md_5.bungee.api.dialog.action.DialogClickAction;
|
||||
public final class NoticeDialog implements Dialog
|
||||
{
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
|
@ -1,9 +1,10 @@
|
||||
package net.md_5.bungee.api.dialog;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -14,11 +15,12 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@Data
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@AllArgsConstructor
|
||||
@Accessors(fluent = true)
|
||||
public final class ServerLinksDialog implements Dialog
|
||||
{
|
||||
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
@ -29,15 +31,37 @@ public final class ServerLinksDialog implements Dialog
|
||||
/**
|
||||
* The number of columns for the dialog buttons (default: 2).
|
||||
*/
|
||||
private int columns;
|
||||
private Integer columns;
|
||||
/**
|
||||
* The width of the dialog buttons (default: 150, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
@SerializedName("button_width")
|
||||
private int buttonWidth;
|
||||
private Integer buttonWidth;
|
||||
|
||||
public ServerLinksDialog(DialogBase base)
|
||||
public ServerLinksDialog(@NonNull DialogBase base)
|
||||
{
|
||||
this( base, null, 2, 150 );
|
||||
this( base, null, null, null );
|
||||
}
|
||||
|
||||
public ServerLinksDialog(@NonNull DialogBase base, ClickEvent onClick, Integer columns, Integer buttonWidth)
|
||||
{
|
||||
this.base = base;
|
||||
this.onClick = onClick;
|
||||
columns( columns );
|
||||
buttonWidth( buttonWidth );
|
||||
}
|
||||
|
||||
public ServerLinksDialog columns(Integer columns)
|
||||
{
|
||||
Preconditions.checkArgument( columns == null || columns > 0, "At least one column is required" );
|
||||
this.columns = columns;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ServerLinksDialog buttonWidth(Integer buttonWidth)
|
||||
{
|
||||
Preconditions.checkArgument( buttonWidth == null || ( buttonWidth >= 1 && buttonWidth <= 1024 ), "buttonWidth must be between 1 and 1024" );
|
||||
this.buttonWidth = buttonWidth;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.dialog.action.DialogSubmitAction;
|
||||
@ -21,30 +22,32 @@ import net.md_5.bungee.api.dialog.input.DialogInput;
|
||||
public final class SimpleInputFormDialog implements Dialog
|
||||
{
|
||||
|
||||
@NonNull
|
||||
@Accessors(fluent = false)
|
||||
private DialogBase base;
|
||||
/**
|
||||
* The inputs to the dialog. At least one input must be provided.
|
||||
*/
|
||||
@NonNull
|
||||
private List<DialogInput> inputs;
|
||||
/**
|
||||
* The action/submit buttons for the dialog.
|
||||
*/
|
||||
private DialogSubmitAction action;
|
||||
|
||||
public SimpleInputFormDialog(DialogBase base, DialogInput... inputs)
|
||||
public SimpleInputFormDialog(@NonNull DialogBase base, @NonNull DialogInput... inputs)
|
||||
{
|
||||
this( base, null, inputs );
|
||||
}
|
||||
|
||||
public SimpleInputFormDialog(DialogBase base, DialogSubmitAction action, DialogInput... inputs)
|
||||
public SimpleInputFormDialog(@NonNull DialogBase base, DialogSubmitAction action, @NonNull DialogInput... inputs)
|
||||
{
|
||||
this( base, action, Arrays.asList( inputs ) );
|
||||
}
|
||||
|
||||
public SimpleInputFormDialog(DialogBase base, DialogSubmitAction action, List<DialogInput> inputs)
|
||||
public SimpleInputFormDialog(@NonNull DialogBase base, DialogSubmitAction action, @NonNull List<DialogInput> inputs)
|
||||
{
|
||||
Preconditions.checkArgument( inputs != null && !inputs.isEmpty(), "At least one input must be provided" );
|
||||
Preconditions.checkArgument( !inputs.isEmpty(), "At least one input must be provided" );
|
||||
|
||||
this.base = base;
|
||||
this.inputs = inputs;
|
||||
|
@ -1,20 +1,21 @@
|
||||
package net.md_5.bungee.api.dialog.action;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
* Represents a dialog action which will usually appear as a button.
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class DialogAction
|
||||
{
|
||||
|
||||
/**
|
||||
* The text label of the button, mandatory.
|
||||
*/
|
||||
@NonNull
|
||||
private BaseComponent label;
|
||||
/**
|
||||
* The hover tooltip of the button.
|
||||
@ -23,10 +24,23 @@ public class DialogAction
|
||||
/**
|
||||
* The width of the button (default: 150, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
private int width;
|
||||
private Integer width;
|
||||
|
||||
public DialogAction(@NonNull BaseComponent label, BaseComponent tooltip, Integer width)
|
||||
{
|
||||
this.label = label;
|
||||
this.tooltip = tooltip;
|
||||
setWidth( width );
|
||||
}
|
||||
|
||||
public DialogAction(BaseComponent label)
|
||||
{
|
||||
this( label, null, 150 );
|
||||
this( label, null, null );
|
||||
}
|
||||
|
||||
public void setWidth(Integer width)
|
||||
{
|
||||
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee.api.dialog.action;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -24,17 +25,17 @@ public class DialogClickAction extends DialogAction
|
||||
@SerializedName("on_click")
|
||||
private ClickEvent onClick;
|
||||
|
||||
public DialogClickAction(BaseComponent label)
|
||||
public DialogClickAction(@NonNull BaseComponent label)
|
||||
{
|
||||
this( null, label );
|
||||
}
|
||||
|
||||
public DialogClickAction(ClickEvent onClick, BaseComponent label)
|
||||
public DialogClickAction(ClickEvent onClick, @NonNull BaseComponent label)
|
||||
{
|
||||
this( onClick, label, null, 150 );
|
||||
this( onClick, label, null, null );
|
||||
}
|
||||
|
||||
public DialogClickAction(ClickEvent onClick, BaseComponent label, BaseComponent tooltip, int width)
|
||||
public DialogClickAction(ClickEvent onClick, @NonNull BaseComponent label, BaseComponent tooltip, Integer width)
|
||||
{
|
||||
super( label, tooltip, width );
|
||||
this.onClick = onClick;
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee.api.dialog.action;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -23,19 +24,21 @@ public class DialogSubmitAction extends DialogAction
|
||||
* The ID of the button, used to distinguish submissions initiated via
|
||||
* different buttons on the dialog.
|
||||
*/
|
||||
@NonNull
|
||||
private String id;
|
||||
/**
|
||||
* The submission action to take.
|
||||
*/
|
||||
@NonNull
|
||||
@SerializedName("on_submit")
|
||||
private DialogSubmission onSubmit;
|
||||
|
||||
public DialogSubmitAction(String id, DialogSubmission onSubmit, BaseComponent label)
|
||||
public DialogSubmitAction(@NonNull String id, @NonNull DialogSubmission onSubmit, @NonNull BaseComponent label)
|
||||
{
|
||||
this( id, onSubmit, label, null, 150 );
|
||||
this( id, onSubmit, label, null, null );
|
||||
}
|
||||
|
||||
public DialogSubmitAction(String id, DialogSubmission onSubmit, BaseComponent label, BaseComponent tooltip, int width)
|
||||
public DialogSubmitAction(@NonNull String id, @NonNull DialogSubmission onSubmit, @NonNull BaseComponent label, BaseComponent tooltip, Integer width)
|
||||
{
|
||||
super( label, tooltip, width );
|
||||
this.id = id;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api.dialog.body;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
@ -13,6 +14,7 @@ public abstract class DialogBody
|
||||
/**
|
||||
* The internal body type.
|
||||
*/
|
||||
@NonNull
|
||||
@ApiStatus.Internal
|
||||
private final String type;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.md_5.bungee.api.dialog.body;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
@ -18,21 +20,28 @@ public class PlainMessageBody extends DialogBody
|
||||
/**
|
||||
* The text body.
|
||||
*/
|
||||
@NonNull
|
||||
private BaseComponent contents;
|
||||
/**
|
||||
* The maximum width (default: 200, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
private int width;
|
||||
private Integer width;
|
||||
|
||||
public PlainMessageBody(BaseComponent contents)
|
||||
public PlainMessageBody(@NonNull BaseComponent contents)
|
||||
{
|
||||
this( contents, 200 );
|
||||
this( contents, null );
|
||||
}
|
||||
|
||||
public PlainMessageBody(BaseComponent contents, int width)
|
||||
public PlainMessageBody(@NonNull BaseComponent contents, Integer width)
|
||||
{
|
||||
super( "minecraft:plain_message" );
|
||||
this.contents = contents;
|
||||
setWidth( width );
|
||||
}
|
||||
|
||||
public void setWidth(int width)
|
||||
{
|
||||
Preconditions.checkArgument( width >= 1 && width <= 1024, "width must be between 1 and 1024" );
|
||||
this.width = width;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package net.md_5.bungee.api.dialog.input;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -20,11 +21,12 @@ public class BooleanInput extends DialogInput
|
||||
/**
|
||||
* The input label.
|
||||
*/
|
||||
@NonNull
|
||||
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").
|
||||
*/
|
||||
@ -36,12 +38,12 @@ public class BooleanInput extends DialogInput
|
||||
@SerializedName("on_false")
|
||||
private String onFalse;
|
||||
|
||||
public BooleanInput(String key, BaseComponent label)
|
||||
public BooleanInput(@NonNull String key, @NonNull BaseComponent label)
|
||||
{
|
||||
this( key, label, false, "true", "false" );
|
||||
this( key, label, null, "true", "false" );
|
||||
}
|
||||
|
||||
public BooleanInput(String key, BaseComponent label, boolean initial, String onTrue, String onFalse)
|
||||
public BooleanInput(@NonNull String key, @NonNull BaseComponent label, Boolean initial, String onTrue, String onFalse)
|
||||
{
|
||||
super( "minecraft:boolean", key );
|
||||
this.label = label;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api.dialog.input;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ -22,5 +23,6 @@ public class DialogInput
|
||||
* The key corresponding to this input and associated with the value
|
||||
* submitted.
|
||||
*/
|
||||
@NonNull
|
||||
private final String key;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.api.dialog.input;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
@ -19,6 +20,7 @@ public class InputOption
|
||||
* The string value associated with this option, to be submitted when
|
||||
* selected.
|
||||
*/
|
||||
@NonNull
|
||||
private String id;
|
||||
/**
|
||||
* The text to display for this option.
|
||||
@ -28,10 +30,10 @@ public class InputOption
|
||||
* 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(@NonNull String id)
|
||||
{
|
||||
this( id, null, false );
|
||||
this( id, null, null );
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
package net.md_5.bungee.api.dialog.input;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -19,10 +21,11 @@ public class NumberRangeInput extends DialogInput
|
||||
/**
|
||||
* The width of the input (default: 200, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
private int width;
|
||||
private Integer width;
|
||||
/**
|
||||
* The label of the slider.
|
||||
*/
|
||||
@NonNull
|
||||
private BaseComponent label;
|
||||
/**
|
||||
* A translate key used to display the label value (default:
|
||||
@ -47,30 +50,54 @@ public class NumberRangeInput extends DialogInput
|
||||
*/
|
||||
private Float initial;
|
||||
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end)
|
||||
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end)
|
||||
{
|
||||
this( key, 200, label, "options.generic_value", start, end, null, null );
|
||||
this( key, null, label, "options.generic_value", start, end, null, null );
|
||||
}
|
||||
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step)
|
||||
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end, Float step)
|
||||
{
|
||||
this( key, 200, label, "options.generic_value", start, end, step, null );
|
||||
this( key, null, label, "options.generic_value", start, end, step, null );
|
||||
}
|
||||
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step, Float initial)
|
||||
public NumberRangeInput(@NonNull String key, @NonNull BaseComponent label, float start, float end, Float step, Float initial)
|
||||
{
|
||||
this( key, 200, label, "options.generic_value", start, end, step, initial );
|
||||
this( key, null, label, "options.generic_value", start, end, step, initial );
|
||||
}
|
||||
|
||||
public NumberRangeInput(String key, int width, BaseComponent label, String labelFormat, float start, float end, Float step, Float initial)
|
||||
public NumberRangeInput(@NonNull String key, Integer width, @NonNull BaseComponent label, String labelFormat, float start, float end, Float step, Float initial)
|
||||
{
|
||||
super( "minecraft:number_range", key );
|
||||
this.width = width;
|
||||
width( width );
|
||||
this.label = label;
|
||||
this.labelFormat = labelFormat;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
step( step );
|
||||
initial( initial );
|
||||
}
|
||||
|
||||
public NumberRangeInput width(Integer width)
|
||||
{
|
||||
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "with must be between 1 and 1024" );
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NumberRangeInput step(Float step)
|
||||
{
|
||||
Preconditions.checkArgument( step == null || step > 0, "step must be null or greater than zero" );
|
||||
this.step = step;
|
||||
return this;
|
||||
}
|
||||
|
||||
public NumberRangeInput initial(Float initial)
|
||||
{
|
||||
// we need to calculate if the initial value is between start and end, regardless of the order
|
||||
float min = Math.min( start, end );
|
||||
float max = Math.max( start, end );
|
||||
Preconditions.checkArgument( step == null || ( initial >= min && initial <= max ), "step must be null or between start and end" );
|
||||
this.initial = initial;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -23,34 +24,43 @@ public class SingleOptionInput extends DialogInput
|
||||
/**
|
||||
* The width of the input (default: 200, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
private int width;
|
||||
private Integer width;
|
||||
/**
|
||||
* The input label.
|
||||
*/
|
||||
@NonNull
|
||||
private BaseComponent label;
|
||||
/**
|
||||
* Whether the label is visible (default: true).
|
||||
*/
|
||||
@SerializedName("label_visible")
|
||||
private boolean labelVisible;
|
||||
private Boolean labelVisible;
|
||||
/**
|
||||
* The non-empty list of options to be selected from.
|
||||
*/
|
||||
@NonNull
|
||||
private List<InputOption> options;
|
||||
|
||||
public SingleOptionInput(String key, BaseComponent label, InputOption... options)
|
||||
public SingleOptionInput(@NonNull String key, @NonNull BaseComponent label, @NonNull InputOption... options)
|
||||
{
|
||||
this( key, 200, label, true, Arrays.asList( options ) );
|
||||
this( key, null, label, null, Arrays.asList( options ) );
|
||||
}
|
||||
|
||||
public SingleOptionInput(String key, int width, BaseComponent label, boolean labelVisible, List<InputOption> options)
|
||||
public SingleOptionInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, @NonNull List<InputOption> options)
|
||||
{
|
||||
super( "minecraft:single_option", key );
|
||||
Preconditions.checkArgument( options != null && !options.isEmpty(), "At least one option must be provided" );
|
||||
Preconditions.checkArgument( !options.isEmpty(), "At least one option must be provided" );
|
||||
|
||||
this.width = width;
|
||||
width( width );
|
||||
this.label = label;
|
||||
this.labelVisible = labelVisible;
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public SingleOptionInput width(Integer width)
|
||||
{
|
||||
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package net.md_5.bungee.api.dialog.input;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
@ -20,16 +23,17 @@ public class TextInput extends DialogInput
|
||||
/**
|
||||
* The width of this text input (default: 200, minimum: 1, maximum: 1024).
|
||||
*/
|
||||
private int width;
|
||||
private Integer width;
|
||||
/**
|
||||
* The label of this text input.
|
||||
*/
|
||||
@NonNull
|
||||
private BaseComponent label;
|
||||
/**
|
||||
* The visibility of this text input's label.
|
||||
*/
|
||||
@SerializedName("label_visible")
|
||||
private boolean labelVisible;
|
||||
private Boolean labelVisible;
|
||||
/**
|
||||
* The initial value of this text input.
|
||||
*/
|
||||
@ -38,26 +42,26 @@ public class TextInput extends DialogInput
|
||||
* The maximum length of the input (default: 32).
|
||||
*/
|
||||
@SerializedName("max_length")
|
||||
private int maxLength;
|
||||
private Integer maxLength;
|
||||
/**
|
||||
* If present, allows users to input multiple lines.
|
||||
*/
|
||||
private Multiline multiline;
|
||||
|
||||
public TextInput(String key, BaseComponent label)
|
||||
public TextInput(@NonNull String key, @NonNull BaseComponent label)
|
||||
{
|
||||
this( key, 200, label, true, null, 32, null );
|
||||
this( key, 200, label, null, null, null, null );
|
||||
}
|
||||
|
||||
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial, Integer maxLength)
|
||||
public TextInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, String initial, Integer maxLength)
|
||||
{
|
||||
this( key, width, label, labelVisible, initial, maxLength, null );
|
||||
}
|
||||
|
||||
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial, Integer maxLength, Multiline multiline)
|
||||
public TextInput(@NonNull String key, Integer width, @NonNull BaseComponent label, Boolean labelVisible, String initial, Integer maxLength, Multiline multiline)
|
||||
{
|
||||
super( "minecraft:text", key );
|
||||
this.width = width;
|
||||
width( width );
|
||||
this.label = label;
|
||||
this.labelVisible = labelVisible;
|
||||
this.initial = initial;
|
||||
@ -69,6 +73,7 @@ public class TextInput extends DialogInput
|
||||
* Configuration data for a multiline input.
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Accessors(fluent = true)
|
||||
public static class Multiline
|
||||
{
|
||||
@ -81,6 +86,25 @@ public class TextInput extends DialogInput
|
||||
/**
|
||||
* The height of this input (default: 32, minimum: 1, maximum: 512).
|
||||
*/
|
||||
private Integer height = 32;
|
||||
private Integer height;
|
||||
|
||||
public Multiline(Integer maxLines, Integer height)
|
||||
{
|
||||
height( height ).maxLines( maxLines );
|
||||
}
|
||||
|
||||
public Multiline height(Integer height)
|
||||
{
|
||||
Preconditions.checkArgument( height == null || height >= 1 && height <= 512, "height must null or be between 1 and 512" );
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
public TextInput width(Integer width)
|
||||
{
|
||||
Preconditions.checkArgument( width == null || ( width >= 1 && width <= 1024 ), "width must be between 1 and 1024" );
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.api.dialog.submit;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ -24,9 +25,10 @@ public class CommandTemplateSubmission extends DialogSubmission
|
||||
* The <code>action</code> key is special and will be replaced with the
|
||||
* {@link net.md_5.bungee.api.dialog.action.DialogSubmitAction#id}.
|
||||
*/
|
||||
@NonNull
|
||||
private String template;
|
||||
|
||||
public CommandTemplateSubmission(String template)
|
||||
public CommandTemplateSubmission(@NonNull String template)
|
||||
{
|
||||
super( "minecraft:command_template" );
|
||||
this.template = template;
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.api.dialog.submit;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ -18,9 +19,10 @@ public class CustomFormSubmission extends DialogSubmission
|
||||
/**
|
||||
* The namespaced key of the submission.
|
||||
*/
|
||||
@NonNull
|
||||
private String id;
|
||||
|
||||
public CustomFormSubmission(String id)
|
||||
public CustomFormSubmission(@NonNull String id)
|
||||
{
|
||||
super( "minecraft:custom_form" );
|
||||
this.id = id;
|
||||
|
@ -2,6 +2,7 @@ package net.md_5.bungee.api.dialog.submit;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ -19,6 +20,7 @@ public class CustomTemplateSubmission extends DialogSubmission
|
||||
/**
|
||||
* The namespaced key of the submission.
|
||||
*/
|
||||
@NonNull
|
||||
private String id;
|
||||
/**
|
||||
* The template to be applied, where variables of the form
|
||||
@ -28,9 +30,10 @@ public class CustomTemplateSubmission extends DialogSubmission
|
||||
* The <code>action</code> key is special and will be replaced with the
|
||||
* {@link net.md_5.bungee.api.dialog.action.DialogSubmitAction#id}.
|
||||
*/
|
||||
@NonNull
|
||||
private String template;
|
||||
|
||||
public CustomTemplateSubmission(String id, String template)
|
||||
public CustomTemplateSubmission(@NonNull String id, @NonNull String template)
|
||||
{
|
||||
super( "minecraft:custom_template" );
|
||||
this.id = id;
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.md_5.bungee.api.dialog.submit;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@ -15,6 +16,7 @@ public class DialogSubmission
|
||||
/**
|
||||
* The internal submissions type.
|
||||
*/
|
||||
@NonNull
|
||||
@ApiStatus.Internal
|
||||
private final String type;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user