@@ -68,8 +68,7 @@ public void showNotice(Player player, UniDialogNoticeRequest request) {
6868 registerCustomAction (namespace , actionId , request .getCallback ());
6969 }
7070
71- PaperNoticeDialog dialog = manager .createNoticeDialog ()
72- .title (request .getTitle ())
71+ PaperNoticeDialog dialog = manager .createNoticeDialog ().title (request .getTitle ())
7372 .body (builder -> builder .text ().text (request .getBody ()));
7473
7574 applyInputs (dialog , request .getInputs ());
@@ -96,8 +95,7 @@ public void showConfirmation(Player player, UniDialogConfirmationRequest request
9695 registerCustomAction (namespace , noActionId , request .getNoCallback ());
9796 }
9897
99- PaperConfirmationDialog dialog = manager .createConfirmationDialog ()
100- .title (request .getTitle ())
98+ PaperConfirmationDialog dialog = manager .createConfirmationDialog ().title (request .getTitle ())
10199 .body (builder -> builder .text ().text (request .getBody ()));
102100
103101 applyInputs (dialog , request .getInputs ());
@@ -119,10 +117,8 @@ public void showConfirmation(Player player, UniDialogConfirmationRequest request
119117 public void showMultiAction (Player player , UniDialogMultiActionRequest request ) {
120118 String namespace = resolveNamespace (request .getNamespace ());
121119
122- PaperMultiActionDialog dialog = manager .createMultiActionDialog ()
123- .title (request .getTitle ())
124- .body (builder -> builder .text ().text (request .getBody ()))
125- .columns (request .getColumns ());
120+ PaperMultiActionDialog dialog = manager .createMultiActionDialog ().title (request .getTitle ())
121+ .body (builder -> builder .text ().text (request .getBody ())).columns (request .getColumns ());
126122
127123 applyInputs (dialog , request .getInputs ());
128124
@@ -156,12 +152,6 @@ public void showMultiAction(Player player, UniDialogMultiActionRequest request)
156152 dialog .opener ().open (player .getUniqueId ());
157153 }
158154
159- /**
160- * Apply inputs to a notice dialog.
161- *
162- * @param dialog the dialog
163- * @param inputs the inputs
164- */
165155 private void applyInputs (PaperNoticeDialog dialog , Iterable <UniDialogInput > inputs ) {
166156 if (inputs == null ) {
167157 return ;
@@ -172,12 +162,6 @@ private void applyInputs(PaperNoticeDialog dialog, Iterable<UniDialogInput> inpu
172162 }
173163 }
174164
175- /**
176- * Apply inputs to a confirmation dialog.
177- *
178- * @param dialog the dialog
179- * @param inputs the inputs
180- */
181165 private void applyInputs (PaperConfirmationDialog dialog , Iterable <UniDialogInput > inputs ) {
182166 if (inputs == null ) {
183167 return ;
@@ -188,12 +172,6 @@ private void applyInputs(PaperConfirmationDialog dialog, Iterable<UniDialogInput
188172 }
189173 }
190174
191- /**
192- * Apply inputs to a multi-action dialog.
193- *
194- * @param dialog the dialog
195- * @param inputs the inputs
196- */
197175 private void applyInputs (PaperMultiActionDialog dialog , Iterable <UniDialogInput > inputs ) {
198176 if (inputs == null ) {
199177 return ;
@@ -204,75 +182,75 @@ private void applyInputs(PaperMultiActionDialog dialog, Iterable<UniDialogInput>
204182 }
205183 }
206184
207- /**
208- * Apply a single input to a notice dialog.
209- *
210- * @param dialog the dialog
211- * @param input the input
212- */
213185 private void applyInput (PaperNoticeDialog dialog , UniDialogInput input ) {
214186 if (input == null || input .getId () == null || input .getId ().isEmpty ()) {
215187 return ;
216188 }
217189
218190 dialog .input (input .getId (), builder -> {
219- String label = getInputLabel (input );
220- builder .textInput ().label (label );
191+ if (input .getType () == UniDialogInput .InputType .BOOLEAN ) {
192+ builder .booleanInput ().label (getInputLabel (input )).initial (input .isInitialBoolean ());
193+ } else {
194+ String initial = getInputInitial (input );
195+ if (initial != null && !initial .isEmpty ()) {
196+ builder .textInput ().label (getInputLabel (input )).initial (initial );
197+ } else {
198+ builder .textInput ().label (getInputLabel (input ));
199+ }
200+ }
221201 });
222202 }
223203
224- /**
225- * Apply a single input to a confirmation dialog.
226- *
227- * @param dialog the dialog
228- * @param input the input
229- */
230204 private void applyInput (PaperConfirmationDialog dialog , UniDialogInput input ) {
231205 if (input == null || input .getId () == null || input .getId ().isEmpty ()) {
232206 return ;
233207 }
234208
235209 dialog .input (input .getId (), builder -> {
236- String label = getInputLabel (input );
237- builder .textInput ().label (label );
210+ if (input .getType () == UniDialogInput .InputType .BOOLEAN ) {
211+ builder .booleanInput ().label (getInputLabel (input )).initial (input .isInitialBoolean ());
212+ } else {
213+ String initial = getInputInitial (input );
214+ if (initial != null && !initial .isEmpty ()) {
215+ builder .textInput ().label (getInputLabel (input )).initial (initial );
216+ } else {
217+ builder .textInput ().label (getInputLabel (input ));
218+ }
219+ }
238220 });
221+
239222 }
240223
241- /**
242- * Apply a single input to a multi-action dialog.
243- *
244- * @param dialog the dialog
245- * @param input the input
246- */
247224 private void applyInput (PaperMultiActionDialog dialog , UniDialogInput input ) {
248225 if (input == null || input .getId () == null || input .getId ().isEmpty ()) {
249226 return ;
250227 }
251228
252229 dialog .input (input .getId (), builder -> {
253- String label = getInputLabel (input );
254- builder .textInput ().label (label );
230+ if (input .getType () == UniDialogInput .InputType .BOOLEAN ) {
231+ builder .booleanInput ().label (getInputLabel (input )).initial (input .isInitialBoolean ());
232+ } else {
233+ String initial = getInputInitial (input );
234+ if (initial != null && !initial .isEmpty ()) {
235+ builder .textInput ().label (getInputLabel (input )).initial (initial );
236+ } else {
237+ builder .textInput ().label (getInputLabel (input ));
238+ }
239+ }
255240 });
256241 }
257242
258- /**
259- * Get the best label to use for an input.
260- *
261- * @param input the input
262- * @return the label
263- */
264243 private String getInputLabel (UniDialogInput input ) {
265244 String label = input .getLabel ();
266245
267- if ((label == null || label .isEmpty ()) && input .getPlaceholder () != null
268- && !input .getPlaceholder ().isEmpty ()) {
269- label = input .getPlaceholder ();
270- }
271-
272246 if (label == null || label .isEmpty ()) {
273247 label = input .getId ();
274248 }
275249
276250 return label ;
277251 }
278- }
252+
253+ private String getInputInitial (UniDialogInput input ) {
254+ return input .getInitialValue ();
255+ }
256+ }
0 commit comments