Skip to content

Commit a1d90a4

Browse files
authored
Merge pull request #41 from SpigotMC/master
[pull] master from SpigotMC:master
2 parents cebbd46 + 4d37c24 commit a1d90a4

17 files changed

+204
-16
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,27 @@
77
import lombok.experimental.Accessors;
88
import net.md_5.bungee.api.dialog.action.DialogClickAction;
99

10+
/**
11+
* Represents a simple dialog with text and two actions at the bottom (default:
12+
* "yes", "no").
13+
*/
1014
@Data
1115
@ToString
1216
@EqualsAndHashCode
1317
@AllArgsConstructor
1418
@Accessors(fluent = true)
15-
public class ConfirmationDialog implements Dialog
19+
public final class ConfirmationDialog implements Dialog
1620
{
1721

1822
@Accessors(fluent = false)
1923
private DialogBase base;
24+
/**
25+
* The "yes" click action / bottom (appears on the left).
26+
*/
2027
private DialogClickAction yes;
28+
/**
29+
* The "no" click action / bottom (appears on the right).
30+
*/
2131
private DialogClickAction no;
2232

2333
public ConfirmationDialog(DialogBase base)
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
11
package net.md_5.bungee.api.dialog;
22

3+
import org.jetbrains.annotations.ApiStatus;
4+
5+
/**
6+
* Represents a dialog GUI.
7+
*/
38
public interface Dialog
49
{
510

11+
/**
12+
* Gets the dialog base which contains the dialog title and other options
13+
* common to all types of dialogs.
14+
*
15+
* @return mutable reference to the dialog base
16+
*/
617
DialogBase getBase();
718

19+
/**
20+
* Sets the dialog base.
21+
* <br>
22+
* For internal use only as this is mandatory and should be specified in the
23+
* constructor.
24+
*
25+
* @param base the new dialog base
26+
*/
27+
@ApiStatus.Internal
828
void setBase(DialogBase base);
929
}

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,33 @@
66
import lombok.RequiredArgsConstructor;
77
import lombok.experimental.Accessors;
88
import net.md_5.bungee.api.chat.BaseComponent;
9+
import net.md_5.bungee.api.dialog.body.DialogBody;
910

11+
/**
12+
* Represents the title and other options common to all dialogs.
13+
*/
1014
@Data
1115
@AllArgsConstructor
1216
@RequiredArgsConstructor
1317
@Accessors(fluent = true)
14-
public class DialogBase
18+
public final class DialogBase
1519
{
1620

21+
/**
22+
* The mandatory dialog title.
23+
*/
1724
private final BaseComponent title;
25+
/**
26+
* The name which is used for any buttons leading to this dialog (eg from a
27+
* {@link DialogListDialog}). Otherwise defaults to {@link #title}.
28+
*/
1829
private BaseComponent externalTitle;
19-
private List<?> body;
30+
/**
31+
* The body elements which make up this dialog.
32+
*/
33+
private List<DialogBody> body;
34+
/**
35+
* Whether this dialog can be closed with the escape key (default: true).
36+
*/
2037
private boolean canCloseWithEscape;
2138
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,34 @@
99
import lombok.experimental.Accessors;
1010
import net.md_5.bungee.api.chat.ClickEvent;
1111

12+
/**
13+
* Represents a dialog which contains buttons that link to other dialogs.
14+
*/
1215
@Data
1316
@ToString
1417
@EqualsAndHashCode
1518
@Accessors(fluent = true)
16-
public class DialogListDialog implements Dialog
19+
public final class DialogListDialog implements Dialog
1720
{
1821

1922
@Accessors(fluent = false)
2023
private DialogBase base;
24+
/**
25+
* The child dialogs behind each button.
26+
*/
2127
private List<Dialog> dialogs;
28+
/**
29+
* The {@link ClickEvent} activated when the dialog is cancelled.
30+
*/
2231
@SerializedName("on_cancel")
2332
private ClickEvent onCancel;
33+
/**
34+
* The number of columns for the dialog buttons (default: 2).
35+
*/
2436
private int columns;
37+
/**
38+
* The width of the dialog buttons (default: 150).
39+
*/
2540
@SerializedName("button_width")
2641
private int buttonWidth;
2742

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,30 @@
1111
import net.md_5.bungee.api.chat.ClickEvent;
1212
import net.md_5.bungee.api.dialog.action.DialogClickAction;
1313

14+
/**
15+
* Represents a dialog with text a list of action buttons grouped into columns
16+
* and scrollable if necessary.
17+
*/
1418
@Data
1519
@ToString
1620
@EqualsAndHashCode
1721
@Accessors(fluent = true)
18-
public class MultiActionDialog implements Dialog
22+
public final class MultiActionDialog implements Dialog
1923
{
2024

2125
@Accessors(fluent = false)
2226
private DialogBase base;
27+
/**
28+
* The action buttons in the dialog. At least one must be provided.
29+
*/
2330
private List<DialogClickAction> actions;
31+
/**
32+
* The number of columns for the dialog buttons (default: 2).
33+
*/
2434
private int columns;
35+
/**
36+
* The {@link ClickEvent} activated when the dialog is cancelled.
37+
*/
2538
@SerializedName("on_cancel")
2639
private ClickEvent onCancel;
2740

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,50 @@
11
package net.md_5.bungee.api.dialog;
22

3+
import com.google.common.base.Preconditions;
4+
import java.util.Arrays;
35
import java.util.List;
4-
import lombok.AllArgsConstructor;
56
import lombok.Data;
67
import lombok.EqualsAndHashCode;
78
import lombok.ToString;
89
import lombok.experimental.Accessors;
9-
import net.md_5.bungee.api.dialog.action.DialogClickAction;
10+
import net.md_5.bungee.api.dialog.action.DialogSubmitAction;
1011
import net.md_5.bungee.api.dialog.input.DialogInput;
1112

13+
/**
14+
* Represents a dialog which contains a variety of inputs and a multiple submit
15+
* buttons at the bottom.
16+
*/
1217
@Data
1318
@ToString
1419
@EqualsAndHashCode
15-
@AllArgsConstructor
1620
@Accessors(fluent = true)
17-
public class MultiActionInputFormDialog implements Dialog
21+
public final class MultiActionInputFormDialog implements Dialog
1822
{
1923

2024
@Accessors(fluent = false)
2125
private DialogBase base;
26+
/**
27+
* The inputs to the dialog. At least one input must be provided.
28+
*/
2229
private List<DialogInput> inputs;
23-
private List<DialogClickAction> actions;
30+
/**
31+
* The action/submit buttons for the dialog. At least one action must be
32+
* provided.
33+
*/
34+
private List<DialogSubmitAction> actions;
2435

25-
public MultiActionInputFormDialog(DialogBase base)
36+
public MultiActionInputFormDialog(DialogBase base, DialogInput input, DialogSubmitAction action)
2637
{
27-
this( base, null, null );
38+
this( base, Arrays.asList( input ), Arrays.asList( action ) );
39+
}
40+
41+
public MultiActionInputFormDialog(DialogBase base, List<DialogInput> inputs, List<DialogSubmitAction> actions)
42+
{
43+
Preconditions.checkArgument( inputs != null && !inputs.isEmpty(), "At least one input must be provided" );
44+
Preconditions.checkArgument( actions != null && !actions.isEmpty(), "At least one action must be provided" );
45+
46+
this.base = base;
47+
this.inputs = inputs;
48+
this.actions = actions;
2849
}
2950
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@
77
import lombok.experimental.Accessors;
88
import net.md_5.bungee.api.dialog.action.DialogClickAction;
99

10+
/**
11+
* Represents a simple dialog with text and one action at the bottom (default:
12+
* "OK").
13+
*/
1014
@Data
1115
@ToString
1216
@EqualsAndHashCode
1317
@AllArgsConstructor
1418
@Accessors(fluent = true)
15-
public class NoticeDialog implements Dialog
19+
public final class NoticeDialog implements Dialog
1620
{
1721

1822
@Accessors(fluent = false)
1923
private DialogBase base;
24+
/**
25+
* The "OK" action button for the dialog.
26+
*/
2027
private DialogClickAction action;
2128

2229
public NoticeDialog(DialogBase base)

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,31 @@
88
import lombok.experimental.Accessors;
99
import net.md_5.bungee.api.chat.ClickEvent;
1010

11+
/**
12+
* Represents a dialog which shows the links configured/sent from the server.
13+
*/
1114
@Data
1215
@ToString
1316
@EqualsAndHashCode
1417
@AllArgsConstructor
1518
@Accessors(fluent = true)
16-
public class ServerLinksDialog implements Dialog
19+
public final class ServerLinksDialog implements Dialog
1720
{
1821

1922
@Accessors(fluent = false)
2023
private DialogBase base;
24+
/**
25+
* The optional {@link ClickEvent} for this dialog.
26+
*/
2127
@SerializedName("on_click")
2228
private ClickEvent onClick;
29+
/**
30+
* The number of columns for the dialog buttons (default: 2).
31+
*/
2332
private int columns;
33+
/**
34+
* The width of the dialog buttons (default: 150).
35+
*/
2436
@SerializedName("button_width")
2537
private int buttonWidth;
2638

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

Lines changed: 14 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.common.base.Preconditions;
34
import java.util.Arrays;
45
import java.util.List;
56
import lombok.Data;
@@ -9,16 +10,26 @@
910
import net.md_5.bungee.api.dialog.action.DialogSubmitAction;
1011
import net.md_5.bungee.api.dialog.input.DialogInput;
1112

13+
/**
14+
* Represents a dialog which contains a variety of inputs and a single submit
15+
* button at the bottom.
16+
*/
1217
@Data
1318
@ToString
1419
@EqualsAndHashCode
1520
@Accessors(fluent = true)
16-
public class SimpleInputFormDialog implements Dialog
21+
public final class SimpleInputFormDialog implements Dialog
1722
{
1823

1924
@Accessors(fluent = false)
2025
private DialogBase base;
26+
/**
27+
* The inputs to the dialog. At least one input must be provided.
28+
*/
2129
private List<DialogInput> inputs;
30+
/**
31+
* The action/submit buttons for the dialog.
32+
*/
2233
private DialogSubmitAction action;
2334

2435
public SimpleInputFormDialog(DialogBase base, DialogInput... inputs)
@@ -33,6 +44,8 @@ public SimpleInputFormDialog(DialogBase base, DialogSubmitAction action, DialogI
3344

3445
public SimpleInputFormDialog(DialogBase base, DialogSubmitAction action, List<DialogInput> inputs)
3546
{
47+
Preconditions.checkArgument( inputs != null && !inputs.isEmpty(), "At least one input must be provided" );
48+
3649
this.base = base;
3750
this.inputs = inputs;
3851
this.action = action;

dialog/src/main/java/net/md_5/bungee/api/dialog/action/DialogAction.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,25 @@
44
import lombok.Data;
55
import net.md_5.bungee.api.chat.BaseComponent;
66

7+
/**
8+
* Represents a dialog action which will usually appear as a button.
9+
*/
710
@Data
811
@AllArgsConstructor
912
public class DialogAction
1013
{
1114

15+
/**
16+
* The text label of the button, mandatory.
17+
*/
1218
private BaseComponent label;
19+
/**
20+
* The hover tooltip of the button.
21+
*/
1322
private BaseComponent tooltip;
23+
/**
24+
* The width of the button (default: 150).
25+
*/
1426
private int width;
1527

1628
public DialogAction(BaseComponent label)

0 commit comments

Comments
 (0)