1212 */
1313public class MultiActionDialogBuilder {
1414
15- private final UniDialogService service ;
16- private final Player player ;
17- private final UniDialogMultiActionRequest request = new UniDialogMultiActionRequest ();
18- private final HashMap <String , String > placeholders = new HashMap <String , String >();
19-
20- public MultiActionDialogBuilder (UniDialogService service , Player player ) {
21- this .service = service ;
22- this .player = player ;
23- }
24-
25- public MultiActionDialogBuilder placeholder (String placeholder , String value ) {
26- placeholders .put (placeholder , value );
27- return this ;
28- }
29-
30- public MultiActionDialogBuilder placeholders (HashMap <String , String > placeholders ) {
31- if (placeholders != null ) {
32- this .placeholders .putAll (placeholders );
33- }
34- return this ;
35- }
36-
37- public MultiActionDialogBuilder title (String title ) {
38- request .setTitle (DialogTextFormatter .format (player , title , placeholders ));
39- return this ;
40- }
41-
42- public MultiActionDialogBuilder body (String body ) {
43- request .setBody (DialogTextFormatter .format (player , body , placeholders ));
44- return this ;
45- }
46-
47- public MultiActionDialogBuilder namespace (String namespace ) {
48- request .setNamespace (namespace );
49- return this ;
50- }
51-
52- public MultiActionDialogBuilder columns (int columns ) {
53- request .setColumns (columns );
54- return this ;
55- }
56-
57- public MultiActionDialogBuilder buttonWidth (int width ) {
58- request .setButtonWidth (Integer .valueOf (width ));
59- return this ;
60- }
61-
62- public MultiActionDialogBuilder button (String text , Consumer <DialogPayload > callback ) {
63- UniDialogButton button = new UniDialogButton ();
64- button .setText (DialogTextFormatter .format (player , text , placeholders ));
65- button .setCallback (callback );
66- request .getButtons ().add (button );
67- return this ;
68- }
69-
70- public MultiActionDialogBuilder button (String text , String tooltip , Consumer <DialogPayload > callback ) {
71- UniDialogButton button = new UniDialogButton ();
72- button .setText (DialogTextFormatter .format (player , text , placeholders ));
73- button .setTooltip (DialogTextFormatter .format (player , tooltip , placeholders ));
74- button .setCallback (callback );
75- request .getButtons ().add (button );
76- return this ;
77- }
78-
79- public MultiActionDialogBuilder button (String text , String tooltip , Integer width , String actionId ,
80- Consumer <DialogPayload > callback ) {
81- UniDialogButton button = new UniDialogButton ();
82- button .setText (DialogTextFormatter .format (player , text , placeholders ));
83- button .setTooltip (DialogTextFormatter .format (player , tooltip , placeholders ));
84- button .setWidth (width );
85- button .setActionId (actionId );
86- button .setCallback (callback );
87- request .getButtons ().add (button );
88- return this ;
89- }
90-
91- public void open () {
92- service .showMultiAction (player , request );
93- }
15+ private final UniDialogService service ;
16+ private final Player player ;
17+ private final UniDialogMultiActionRequest request = new UniDialogMultiActionRequest ();
18+ private final HashMap <String , String > placeholders = new HashMap <String , String >();
19+
20+ public MultiActionDialogBuilder (UniDialogService service , Player player ) {
21+ this .service = service ;
22+ this .player = player ;
23+ }
24+
25+ public MultiActionDialogBuilder placeholder (String placeholder , String value ) {
26+ placeholders .put (placeholder , value );
27+ return this ;
28+ }
29+
30+ public MultiActionDialogBuilder placeholders (HashMap <String , String > placeholders ) {
31+ if (placeholders != null ) {
32+ this .placeholders .putAll (placeholders );
33+ }
34+ return this ;
35+ }
36+
37+ public MultiActionDialogBuilder title (String title ) {
38+ request .setTitle (DialogTextFormatter .format (player , title , placeholders ));
39+ return this ;
40+ }
41+
42+ public MultiActionDialogBuilder body (String body ) {
43+ request .setBody (DialogTextFormatter .format (player , body , placeholders ));
44+ return this ;
45+ }
46+
47+ public MultiActionDialogBuilder namespace (String namespace ) {
48+ request .setNamespace (namespace );
49+ return this ;
50+ }
51+
52+ public MultiActionDialogBuilder columns (int columns ) {
53+ request .setColumns (columns );
54+ return this ;
55+ }
56+
57+ public MultiActionDialogBuilder buttonWidth (int width ) {
58+ request .setButtonWidth (Integer .valueOf (width ));
59+ return this ;
60+ }
61+
62+ public MultiActionDialogBuilder input (String id , java .util .function .Consumer <DialogInputBuilder > builderConsumer ) {
63+ DialogInputBuilder builder = new DialogInputBuilder (id , player , placeholders );
64+ builderConsumer .accept (builder );
65+ request .addInput (builder .build ());
66+ return this ;
67+ }
68+
69+ public MultiActionDialogBuilder button (String text , Consumer <DialogPayload > callback ) {
70+ UniDialogButton button = new UniDialogButton ();
71+ button .setText (DialogTextFormatter .format (player , text , placeholders ));
72+ button .setCallback (callback );
73+ request .getButtons ().add (button );
74+ return this ;
75+ }
76+
77+ public MultiActionDialogBuilder button (String text , String tooltip , Consumer <DialogPayload > callback ) {
78+ UniDialogButton button = new UniDialogButton ();
79+ button .setText (DialogTextFormatter .format (player , text , placeholders ));
80+ button .setTooltip (DialogTextFormatter .format (player , tooltip , placeholders ));
81+ button .setCallback (callback );
82+ request .getButtons ().add (button );
83+ return this ;
84+ }
85+
86+ public MultiActionDialogBuilder button (String text , String tooltip , Integer width , String actionId ,
87+ Consumer <DialogPayload > callback ) {
88+ UniDialogButton button = new UniDialogButton ();
89+ button .setText (DialogTextFormatter .format (player , text , placeholders ));
90+ button .setTooltip (DialogTextFormatter .format (player , tooltip , placeholders ));
91+ button .setWidth (width );
92+ button .setActionId (actionId );
93+ button .setCallback (callback );
94+ request .getButtons ().add (button );
95+ return this ;
96+ }
97+
98+ public void open () {
99+ service .showMultiAction (player , request );
100+ }
94101}
0 commit comments