Skip to content

Commit 8bff00f

Browse files
Outfluencermd-5
authored andcommitted
SpigotMC#3830: Dialog & 25w21a changes
1 parent 4d37c24 commit 8bff00f

File tree

5 files changed

+97
-14
lines changed

5 files changed

+97
-14
lines changed

dialog/src/main/java/net/md_5/bungee/api/dialog/DialogBase.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.md_5.bungee.api.dialog;
22

3+
import com.google.gson.annotations.SerializedName;
34
import java.util.List;
45
import lombok.AllArgsConstructor;
56
import lombok.Data;
@@ -26,6 +27,7 @@ public final class DialogBase
2627
* The name which is used for any buttons leading to this dialog (eg from a
2728
* {@link DialogListDialog}). Otherwise defaults to {@link #title}.
2829
*/
30+
@SerializedName("external_title")
2931
private BaseComponent externalTitle;
3032
/**
3133
* The body elements which make up this dialog.
@@ -34,5 +36,6 @@ public final class DialogBase
3436
/**
3537
* Whether this dialog can be closed with the escape key (default: true).
3638
*/
37-
private boolean canCloseWithEscape;
39+
@SerializedName("can_close_with_escape")
40+
private boolean canCloseWithEscape = true;
3841
}

dialog/src/main/java/net/md_5/bungee/api/dialog/MultiActionInputFormDialog.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,29 @@ public final class MultiActionInputFormDialog implements Dialog
3232
* provided.
3333
*/
3434
private List<DialogSubmitAction> actions;
35+
/**
36+
* The amount of columns (default: 2)
37+
*/
38+
private int columns;
3539

3640
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action)
3741
{
38-
this( base, Arrays.asList( input ), Arrays.asList( action ) );
42+
this( base, Arrays.asList( input ), Arrays.asList( action ), 2 );
43+
}
44+
45+
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action, int columns)
46+
{
47+
this( base, Arrays.asList( input ), Arrays.asList( action ), columns );
3948
}
4049

41-
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions)
50+
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions, int columns)
4251
{
4352
Preconditions.checkArgument( inputs != null && !inputs.isEmpty(), "At least one input must be provided" );
4453
Preconditions.checkArgument( actions != null && !actions.isEmpty(), "At least one action must be provided" );
4554

4655
this.base = base;
4756
this.inputs = inputs;
4857
this.actions = actions;
58+
this.columns = columns;
4959
}
5060
}

dialog/src/main/java/net/md_5/bungee/api/dialog/input/NumberRangeInput.java

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,56 @@
1313
public class NumberRangeInput extends DialogInput
1414
{
1515

16+
/**
17+
* The width of the input (default 200)
18+
*/
1619
private int width;
20+
/**
21+
* The label of the slider
22+
*/
1723
private BaseComponent label;
1824
private String labelFormat;
19-
private int start;
20-
private int end;
21-
private int steps;
22-
private int initial;
25+
/**
26+
* The start position of the slider (leftmost position)
27+
*/
28+
private float start;
29+
/**
30+
* The end position of the slider (rightmost position)
31+
*/
32+
private float end;
33+
/**
34+
* The steps in which the input will be increased or decreased, or null if no specific steps
35+
*/
36+
private Float step;
37+
/**
38+
* The initial value of number input, or null to fall back to the middle
39+
*/
40+
private Float initial;
2341

24-
public NumberRangeInput(String key, BaseComponent label, int start, int end, int steps)
42+
public NumberRangeInput(String key, BaseComponent label, float start, float end)
2543
{
26-
this( key, 200, label, "options.generic_value", start, end, steps, start );
44+
this( key, 200, label, "options.generic_value", start, end, null, null );
2745
}
2846

29-
public NumberRangeInput(String key, int width, BaseComponent label, String labelFormat, int start, int end, int steps, int initial)
47+
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step)
48+
{
49+
this( key, 200, label, "options.generic_value", start, end, step, null );
50+
}
51+
52+
public NumberRangeInput(String key, BaseComponent label, float start, float end, Float step, Float initial)
53+
{
54+
this( key, 200, label, "options.generic_value", start, end, step, initial );
55+
}
56+
57+
public NumberRangeInput(String key, int width, BaseComponent label, String labelFormat, float start, float end, Float step, Float initial)
3058
{
3159
super( "minecraft:number_range", key );
3260
this.width = width;
3361
this.label = label;
3462
this.labelFormat = labelFormat;
3563
this.start = start;
3664
this.end = end;
37-
this.steps = steps;
65+
this.step = step;
3866
this.initial = initial;
3967
}
4068
}

dialog/src/main/java/net/md_5/bungee/api/dialog/input/TextInput.java

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,65 @@
1414
public class TextInput extends DialogInput
1515
{
1616

17+
/**
18+
* The width of this text input
19+
*/
1720
private int width;
21+
/**
22+
* The label of this text input
23+
*/
1824
private BaseComponent label;
25+
/**
26+
* The visibility of this text inputs label
27+
*/
1928
@SerializedName("label_visible")
2029
private boolean labelVisible;
30+
/**
31+
* The initial value of this text input
32+
*/
2133
private String initial;
34+
@SerializedName("max_length")
35+
private int maxLength;
36+
/**
37+
* if set, allows users to input multiple lines
38+
*/
39+
private Multiline multiline;
2240

2341
public TextInput(String key, BaseComponent label)
2442
{
25-
this( key, 200, label, true, "" );
43+
this( key, 200, label, true, null, 32, null );
2644
}
2745

28-
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial)
46+
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial, Integer maxLength)
47+
{
48+
this( key, width, label, labelVisible, initial, maxLength, null );
49+
}
50+
51+
public TextInput(String key, int width, BaseComponent label, boolean labelVisible, String initial, Integer maxLength, Multiline multiline)
2952
{
3053
super( "minecraft:text", key );
3154
this.width = width;
3255
this.label = label;
3356
this.labelVisible = labelVisible;
3457
this.initial = initial;
58+
this.maxLength = maxLength;
59+
this.multiline = multiline;
60+
}
61+
62+
@Data
63+
@Accessors(fluent = true)
64+
@ToString(callSuper = true)
65+
@EqualsAndHashCode(callSuper = false)
66+
public static class Multiline
67+
{
68+
/**
69+
* The maximum length of input, or null to disable any limits
70+
*/
71+
@SerializedName("max_lines")
72+
private Integer maxLines;
73+
/**
74+
* The height of this input, default value is 32
75+
*/
76+
private Integer height = 32;
3577
}
3678
}

protocol/src/main/java/net/md_5/bungee/protocol/ProtocolConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ProtocolConstants
5050
public static final int MINECRAFT_1_21_2 = 768;
5151
public static final int MINECRAFT_1_21_4 = 769;
5252
public static final int MINECRAFT_1_21_5 = 770;
53-
public static final int MINECRAFT_1_21_6 = 1073742074;
53+
public static final int MINECRAFT_1_21_6 = 1073742075;
5454
public static final List<String> SUPPORTED_VERSIONS;
5555
public static final List<Integer> SUPPORTED_VERSION_IDS;
5656

0 commit comments

Comments
 (0)