#3830: Dialog & 25w21a changes
This commit is contained in:
parent
4d37c2488e
commit
8bff00f15b
@ -1,5 +1,6 @@
|
||||
package net.md_5.bungee.api.dialog;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@ -26,6 +27,7 @@ public final class DialogBase
|
||||
* The name which is used for any buttons leading to this dialog (eg from a
|
||||
* {@link DialogListDialog}). Otherwise defaults to {@link #title}.
|
||||
*/
|
||||
@SerializedName("external_title")
|
||||
private BaseComponent externalTitle;
|
||||
/**
|
||||
* The body elements which make up this dialog.
|
||||
@ -34,5 +36,6 @@ public final class DialogBase
|
||||
/**
|
||||
* Whether this dialog can be closed with the escape key (default: true).
|
||||
*/
|
||||
private boolean canCloseWithEscape;
|
||||
@SerializedName("can_close_with_escape")
|
||||
private boolean canCloseWithEscape = true;
|
||||
}
|
||||
|
@ -32,13 +32,22 @@ public final class MultiActionInputFormDialog implements Dialog
|
||||
* provided.
|
||||
*/
|
||||
private List<DialogSubmitAction> actions;
|
||||
/**
|
||||
* The amount of columns (default: 2)
|
||||
*/
|
||||
private int columns;
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action)
|
||||
{
|
||||
this( base, Arrays.asList( input ), Arrays.asList( action ) );
|
||||
this( base, Arrays.asList( input ), Arrays.asList( action ), 2 );
|
||||
}
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions)
|
||||
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action, int columns)
|
||||
{
|
||||
this( base, Arrays.asList( input ), Arrays.asList( action ), columns );
|
||||
}
|
||||
|
||||
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions, int 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" );
|
||||
@ -46,5 +55,6 @@ public final class MultiActionInputFormDialog implements Dialog
|
||||
this.base = base;
|
||||
this.inputs = inputs;
|
||||
this.actions = actions;
|
||||
this.columns = columns;
|
||||
}
|
||||
}
|
||||
|
@ -13,20 +13,48 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
public class NumberRangeInput extends DialogInput
|
||||
{
|
||||
|
||||
/**
|
||||
* The width of the input (default 200)
|
||||
*/
|
||||
private int width;
|
||||
/**
|
||||
* The label of the slider
|
||||
*/
|
||||
private BaseComponent label;
|
||||
private String labelFormat;
|
||||
private int start;
|
||||
private int end;
|
||||
private int steps;
|
||||
private int initial;
|
||||
/**
|
||||
* The start position of the slider (leftmost position)
|
||||
*/
|
||||
private float start;
|
||||
/**
|
||||
* The end position of the slider (rightmost position)
|
||||
*/
|
||||
private float end;
|
||||
/**
|
||||
* The steps in which the input will be increased or decreased, or null if no specific steps
|
||||
*/
|
||||
private Float step;
|
||||
/**
|
||||
* The initial value of number input, or null to fall back to the middle
|
||||
*/
|
||||
private Float initial;
|
||||
|
||||
public NumberRangeInput(String key, BaseComponent label, int start, int end, int steps)
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end)
|
||||
{
|
||||
this( key, 200, label, "options.generic_value", start, end, steps, start );
|
||||
this( key, 200, label, "options.generic_value", start, end, null, null );
|
||||
}
|
||||
|
||||
public NumberRangeInput(String key, int width, BaseComponent label, String labelFormat, int start, int end, int steps, int initial)
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step)
|
||||
{
|
||||
this( key, 200, label, "options.generic_value", start, end, step, null );
|
||||
}
|
||||
|
||||
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step, Float initial)
|
||||
{
|
||||
this( key, 200, 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)
|
||||
{
|
||||
super( "minecraft:number_range", key );
|
||||
this.width = width;
|
||||
@ -34,7 +62,7 @@ public class NumberRangeInput extends DialogInput
|
||||
this.labelFormat = labelFormat;
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.steps = steps;
|
||||
this.step = step;
|
||||
this.initial = initial;
|
||||
}
|
||||
}
|
||||
|
@ -14,23 +14,65 @@ import net.md_5.bungee.api.chat.BaseComponent;
|
||||
public class TextInput extends DialogInput
|
||||
{
|
||||
|
||||
/**
|
||||
* The width of this text input
|
||||
*/
|
||||
private int width;
|
||||
/**
|
||||
* The label of this text input
|
||||
*/
|
||||
private BaseComponent label;
|
||||
/**
|
||||
* The visibility of this text inputs label
|
||||
*/
|
||||
@SerializedName("label_visible")
|
||||
private boolean labelVisible;
|
||||
/**
|
||||
* The initial value of this text input
|
||||
*/
|
||||
private String initial;
|
||||
@SerializedName("max_length")
|
||||
private int maxLength;
|
||||
/**
|
||||
* if set, allows users to input multiple lines
|
||||
*/
|
||||
private Multiline multiline;
|
||||
|
||||
public TextInput(String key, BaseComponent label)
|
||||
{
|
||||
this( key, 200, label, true, "" );
|
||||
this( key, 200, label, true, null, 32, null );
|
||||
}
|
||||
|
||||
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial)
|
||||
public TextInput(String key, int width, 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)
|
||||
{
|
||||
super( "minecraft:text", key );
|
||||
this.width = width;
|
||||
this.label = label;
|
||||
this.labelVisible = labelVisible;
|
||||
this.initial = initial;
|
||||
this.maxLength = maxLength;
|
||||
this.multiline = multiline;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
@ToString(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public static class Multiline
|
||||
{
|
||||
/**
|
||||
* The maximum length of input, or null to disable any limits
|
||||
*/
|
||||
@SerializedName("max_lines")
|
||||
private Integer maxLines;
|
||||
/**
|
||||
* The height of this input, default value is 32
|
||||
*/
|
||||
private Integer height = 32;
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ public class ProtocolConstants
|
||||
public static final int MINECRAFT_1_21_2 = 768;
|
||||
public static final int MINECRAFT_1_21_4 = 769;
|
||||
public static final int MINECRAFT_1_21_5 = 770;
|
||||
public static final int MINECRAFT_1_21_6 = 1073742074;
|
||||
public static final int MINECRAFT_1_21_6 = 1073742075;
|
||||
public static final List<String> SUPPORTED_VERSIONS;
|
||||
public static final List<Integer> SUPPORTED_VERSION_IDS;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user