@minecraft/server-ui 2.1.0-beta.1.26.20-preview.20 → 2.1.0-beta.1.26.20-preview.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +212 -122
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -33,6 +33,36 @@
|
|
|
33
33
|
*/
|
|
34
34
|
import * as minecraftcommon from '@minecraft/common';
|
|
35
35
|
import * as minecraftserver from '@minecraft/server';
|
|
36
|
+
/**
|
|
37
|
+
* @beta
|
|
38
|
+
* The reason why a data driven screen (i.e. MessageBox or
|
|
39
|
+
* CustomForm) was closed.
|
|
40
|
+
*/
|
|
41
|
+
export declare enum DataDrivenScreenClosedReason {
|
|
42
|
+
/**
|
|
43
|
+
* @remarks
|
|
44
|
+
* Closed because it was programmatically told by the server to
|
|
45
|
+
* close using `form.close()`.
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
ServerClose = 'ServerClose',
|
|
49
|
+
/**
|
|
50
|
+
* @remarks
|
|
51
|
+
* Closed because the user was busy (i.e. other UI was open).
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
UserBusy = 'UserBusy',
|
|
55
|
+
/**
|
|
56
|
+
* @remarks
|
|
57
|
+
* Closed because the client closed the form. This can be with
|
|
58
|
+
* a close button on the form (i.e. the X in the corner of a
|
|
59
|
+
* message box, the 'Close' button on a custom form, or either
|
|
60
|
+
* button in the message box)
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
UserClose = 'UserClose',
|
|
64
|
+
}
|
|
65
|
+
|
|
36
66
|
export enum FormCancelationReason {
|
|
37
67
|
UserBusy = 'UserBusy',
|
|
38
68
|
UserClosed = 'UserClosed',
|
|
@@ -44,33 +74,66 @@ export enum FormRejectReason {
|
|
|
44
74
|
ServerShutdown = 'ServerShutdown',
|
|
45
75
|
}
|
|
46
76
|
|
|
77
|
+
/**
|
|
78
|
+
* @beta
|
|
79
|
+
* An enum representing the errors that can occur during text
|
|
80
|
+
* filtering. This is used to provide more context about the
|
|
81
|
+
* filtering process.
|
|
82
|
+
*/
|
|
83
|
+
export declare enum TextFilteringError {
|
|
84
|
+
/**
|
|
85
|
+
* @remarks
|
|
86
|
+
* The text was not filtered because the player disabled text
|
|
87
|
+
* filtering in their settings.
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
DisabledByPlayer = 'DisabledByPlayer',
|
|
91
|
+
/**
|
|
92
|
+
* @remarks
|
|
93
|
+
* The text was not filtered because the service is
|
|
94
|
+
* unreachable. This can occur if there are network issues or
|
|
95
|
+
* if the service is down for maintenance.
|
|
96
|
+
*
|
|
97
|
+
*/
|
|
98
|
+
TextProcessorServiceUnreachable = 'TextProcessorServiceUnreachable',
|
|
99
|
+
/**
|
|
100
|
+
* @remarks
|
|
101
|
+
* An unknown error occurred during text filtering. This can
|
|
102
|
+
* occur if there is an unexpected issue with the text
|
|
103
|
+
* filtering service or if the service returns an error that is
|
|
104
|
+
* not categorized under the other error types.
|
|
105
|
+
*
|
|
106
|
+
*/
|
|
107
|
+
Unknown = 'Unknown',
|
|
108
|
+
}
|
|
109
|
+
|
|
47
110
|
/**
|
|
48
111
|
* Builds a simple player form with buttons that let the player
|
|
49
112
|
* take action.
|
|
50
113
|
* @example showActionForm.ts
|
|
51
114
|
* ```typescript
|
|
52
|
-
* import { world, DimensionLocation } from
|
|
53
|
-
* import { ActionFormData, ActionFormResponse } from
|
|
115
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
116
|
+
* import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';
|
|
54
117
|
*
|
|
55
118
|
* function showActionForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
56
119
|
* const playerList = world.getPlayers();
|
|
57
120
|
*
|
|
58
121
|
* if (playerList.length >= 1) {
|
|
59
122
|
* const form = new ActionFormData()
|
|
60
|
-
* .title(
|
|
61
|
-
* .body(
|
|
62
|
-
* .button(
|
|
63
|
-
* .button(
|
|
64
|
-
* .button(
|
|
65
|
-
* .button(
|
|
66
|
-
* .button(
|
|
123
|
+
* .title('Test Title')
|
|
124
|
+
* .body('Body text here!')
|
|
125
|
+
* .button('btn 1')
|
|
126
|
+
* .button('btn 2')
|
|
127
|
+
* .button('btn 3')
|
|
128
|
+
* .button('btn 4')
|
|
129
|
+
* .button('btn 5');
|
|
67
130
|
*
|
|
68
131
|
* form.show(playerList[0]).then((result: ActionFormResponse) => {
|
|
69
132
|
* if (result.canceled) {
|
|
70
|
-
* log(
|
|
133
|
+
* log('Player exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.');
|
|
71
134
|
* return -1;
|
|
72
135
|
* } else {
|
|
73
|
-
* log(
|
|
136
|
+
* log('Your result was: ' + result.selection);
|
|
74
137
|
* }
|
|
75
138
|
* });
|
|
76
139
|
* }
|
|
@@ -78,25 +141,25 @@ export enum FormRejectReason {
|
|
|
78
141
|
* ```
|
|
79
142
|
* @example showFavoriteMonth.ts
|
|
80
143
|
* ```typescript
|
|
81
|
-
* import { world, DimensionLocation } from
|
|
82
|
-
* import { ActionFormData, ActionFormResponse } from
|
|
144
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
145
|
+
* import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';
|
|
83
146
|
*
|
|
84
147
|
* function showFavoriteMonth(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
85
148
|
* const players = world.getPlayers();
|
|
86
149
|
*
|
|
87
150
|
* if (players.length >= 1) {
|
|
88
151
|
* const form = new ActionFormData()
|
|
89
|
-
* .title(
|
|
90
|
-
* .body(
|
|
91
|
-
* .button(
|
|
92
|
-
* .button(
|
|
93
|
-
* .button(
|
|
94
|
-
* .button(
|
|
95
|
-
* .button(
|
|
152
|
+
* .title('Months')
|
|
153
|
+
* .body('Choose your favorite month!')
|
|
154
|
+
* .button('January')
|
|
155
|
+
* .button('February')
|
|
156
|
+
* .button('March')
|
|
157
|
+
* .button('April')
|
|
158
|
+
* .button('May');
|
|
96
159
|
*
|
|
97
160
|
* form.show(players[0]).then((response: ActionFormResponse) => {
|
|
98
161
|
* if (response.selection === 3) {
|
|
99
|
-
* log(
|
|
162
|
+
* log('I like April too!');
|
|
100
163
|
* return -1;
|
|
101
164
|
* }
|
|
102
165
|
* });
|
|
@@ -172,28 +235,28 @@ export class ActionFormData {
|
|
|
172
235
|
* form.
|
|
173
236
|
* @example showActionForm.ts
|
|
174
237
|
* ```typescript
|
|
175
|
-
* import { world, DimensionLocation } from
|
|
176
|
-
* import { ActionFormData, ActionFormResponse } from
|
|
238
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
239
|
+
* import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';
|
|
177
240
|
*
|
|
178
241
|
* function showActionForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
179
242
|
* const playerList = world.getPlayers();
|
|
180
243
|
*
|
|
181
244
|
* if (playerList.length >= 1) {
|
|
182
245
|
* const form = new ActionFormData()
|
|
183
|
-
* .title(
|
|
184
|
-
* .body(
|
|
185
|
-
* .button(
|
|
186
|
-
* .button(
|
|
187
|
-
* .button(
|
|
188
|
-
* .button(
|
|
189
|
-
* .button(
|
|
246
|
+
* .title('Test Title')
|
|
247
|
+
* .body('Body text here!')
|
|
248
|
+
* .button('btn 1')
|
|
249
|
+
* .button('btn 2')
|
|
250
|
+
* .button('btn 3')
|
|
251
|
+
* .button('btn 4')
|
|
252
|
+
* .button('btn 5');
|
|
190
253
|
*
|
|
191
254
|
* form.show(playerList[0]).then((result: ActionFormResponse) => {
|
|
192
255
|
* if (result.canceled) {
|
|
193
|
-
* log(
|
|
256
|
+
* log('Player exited out of the dialog. Note that if the chat window is up, dialogs are automatically canceled.');
|
|
194
257
|
* return -1;
|
|
195
258
|
* } else {
|
|
196
|
-
* log(
|
|
259
|
+
* log('Your result was: ' + result.selection);
|
|
197
260
|
* }
|
|
198
261
|
* });
|
|
199
262
|
* }
|
|
@@ -201,25 +264,25 @@ export class ActionFormData {
|
|
|
201
264
|
* ```
|
|
202
265
|
* @example showFavoriteMonth.ts
|
|
203
266
|
* ```typescript
|
|
204
|
-
* import { world, DimensionLocation } from
|
|
205
|
-
* import { ActionFormData, ActionFormResponse } from
|
|
267
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
268
|
+
* import { ActionFormData, ActionFormResponse } from '@minecraft/server-ui';
|
|
206
269
|
*
|
|
207
270
|
* function showFavoriteMonth(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
208
271
|
* const players = world.getPlayers();
|
|
209
272
|
*
|
|
210
273
|
* if (players.length >= 1) {
|
|
211
274
|
* const form = new ActionFormData()
|
|
212
|
-
* .title(
|
|
213
|
-
* .body(
|
|
214
|
-
* .button(
|
|
215
|
-
* .button(
|
|
216
|
-
* .button(
|
|
217
|
-
* .button(
|
|
218
|
-
* .button(
|
|
275
|
+
* .title('Months')
|
|
276
|
+
* .body('Choose your favorite month!')
|
|
277
|
+
* .button('January')
|
|
278
|
+
* .button('February')
|
|
279
|
+
* .button('March')
|
|
280
|
+
* .button('April')
|
|
281
|
+
* .button('May');
|
|
219
282
|
*
|
|
220
283
|
* form.show(players[0]).then((response: ActionFormResponse) => {
|
|
221
284
|
* if (response.selection === 3) {
|
|
222
|
-
* log(
|
|
285
|
+
* log('I like April too!');
|
|
223
286
|
* return -1;
|
|
224
287
|
* }
|
|
225
288
|
* });
|
|
@@ -324,7 +387,7 @@ export declare class CustomForm {
|
|
|
324
387
|
* @throws
|
|
325
388
|
* *
|
|
326
389
|
*/
|
|
327
|
-
show(): Promise<
|
|
390
|
+
show(): Promise<DataDrivenScreenClosedReason>;
|
|
328
391
|
/**
|
|
329
392
|
* @remarks
|
|
330
393
|
* Creates a slider that lets players pick a number between
|
|
@@ -378,6 +441,13 @@ export declare class CustomForm {
|
|
|
378
441
|
): CustomForm;
|
|
379
442
|
}
|
|
380
443
|
|
|
444
|
+
/**
|
|
445
|
+
* @beta
|
|
446
|
+
* Thrown when attempting to close a DDUI form that isn't open.
|
|
447
|
+
*/
|
|
448
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
449
|
+
export declare class FormCloseError extends Error {}
|
|
450
|
+
|
|
381
451
|
/**
|
|
382
452
|
* Base type for a form response.
|
|
383
453
|
*/
|
|
@@ -467,20 +537,17 @@ export declare class MessageBox {
|
|
|
467
537
|
* Builds a simple two-button modal dialog.
|
|
468
538
|
* @example showBasicMessageForm.ts
|
|
469
539
|
* ```typescript
|
|
470
|
-
* import { world, DimensionLocation } from
|
|
471
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
540
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
541
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
472
542
|
*
|
|
473
|
-
* function showBasicMessageForm(
|
|
474
|
-
* log: (message: string, status?: number) => void,
|
|
475
|
-
* targetLocation: DimensionLocation
|
|
476
|
-
* ) {
|
|
543
|
+
* function showBasicMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
477
544
|
* const players = world.getPlayers();
|
|
478
545
|
*
|
|
479
546
|
* const messageForm = new MessageFormData()
|
|
480
|
-
* .title(
|
|
481
|
-
* .body(
|
|
482
|
-
* .button1(
|
|
483
|
-
* .button2(
|
|
547
|
+
* .title('Message Form Example')
|
|
548
|
+
* .body('This shows a simple example using §o§7MessageFormData§r.')
|
|
549
|
+
* .button1('Button 1')
|
|
550
|
+
* .button2('Button 2');
|
|
484
551
|
*
|
|
485
552
|
* messageForm
|
|
486
553
|
* .show(players[0])
|
|
@@ -490,30 +557,27 @@ export declare class MessageBox {
|
|
|
490
557
|
* return;
|
|
491
558
|
* }
|
|
492
559
|
*
|
|
493
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
560
|
+
* log(`You selected ${formData.selection === 0 ? 'Button 1' : 'Button 2'}`);
|
|
494
561
|
* })
|
|
495
562
|
* .catch((error: Error) => {
|
|
496
|
-
* log(
|
|
563
|
+
* log('Failed to show form: ' + error);
|
|
497
564
|
* return -1;
|
|
498
565
|
* });
|
|
499
566
|
* }
|
|
500
567
|
* ```
|
|
501
568
|
* @example showTranslatedMessageForm.ts
|
|
502
569
|
* ```typescript
|
|
503
|
-
* import { world, DimensionLocation } from
|
|
504
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
570
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
571
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
505
572
|
*
|
|
506
|
-
* function showTranslatedMessageForm(
|
|
507
|
-
* log: (message: string, status?: number) => void,
|
|
508
|
-
* targetLocation: DimensionLocation
|
|
509
|
-
* ) {
|
|
573
|
+
* function showTranslatedMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
510
574
|
* const players = world.getPlayers();
|
|
511
575
|
*
|
|
512
576
|
* const messageForm = new MessageFormData()
|
|
513
|
-
* .title({ translate:
|
|
514
|
-
* .body({ translate:
|
|
515
|
-
* .button1(
|
|
516
|
-
* .button2(
|
|
577
|
+
* .title({ translate: 'permissions.removeplayer' })
|
|
578
|
+
* .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] })
|
|
579
|
+
* .button1('Player 1')
|
|
580
|
+
* .button2('Player 2');
|
|
517
581
|
*
|
|
518
582
|
* messageForm
|
|
519
583
|
* .show(players[0])
|
|
@@ -523,10 +587,10 @@ export declare class MessageBox {
|
|
|
523
587
|
* return;
|
|
524
588
|
* }
|
|
525
589
|
*
|
|
526
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
590
|
+
* log(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
527
591
|
* })
|
|
528
592
|
* .catch((error: Error) => {
|
|
529
|
-
* log(
|
|
593
|
+
* log('Failed to show form: ' + error);
|
|
530
594
|
* return -1;
|
|
531
595
|
* });
|
|
532
596
|
* }
|
|
@@ -585,20 +649,17 @@ export class MessageFormData {
|
|
|
585
649
|
* form.
|
|
586
650
|
* @example showBasicMessageForm.ts
|
|
587
651
|
* ```typescript
|
|
588
|
-
* import { world, DimensionLocation } from
|
|
589
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
652
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
653
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
590
654
|
*
|
|
591
|
-
* function showBasicMessageForm(
|
|
592
|
-
* log: (message: string, status?: number) => void,
|
|
593
|
-
* targetLocation: DimensionLocation
|
|
594
|
-
* ) {
|
|
655
|
+
* function showBasicMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
595
656
|
* const players = world.getPlayers();
|
|
596
657
|
*
|
|
597
658
|
* const messageForm = new MessageFormData()
|
|
598
|
-
* .title(
|
|
599
|
-
* .body(
|
|
600
|
-
* .button1(
|
|
601
|
-
* .button2(
|
|
659
|
+
* .title('Message Form Example')
|
|
660
|
+
* .body('This shows a simple example using §o§7MessageFormData§r.')
|
|
661
|
+
* .button1('Button 1')
|
|
662
|
+
* .button2('Button 2');
|
|
602
663
|
*
|
|
603
664
|
* messageForm
|
|
604
665
|
* .show(players[0])
|
|
@@ -608,30 +669,27 @@ export class MessageFormData {
|
|
|
608
669
|
* return;
|
|
609
670
|
* }
|
|
610
671
|
*
|
|
611
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
672
|
+
* log(`You selected ${formData.selection === 0 ? 'Button 1' : 'Button 2'}`);
|
|
612
673
|
* })
|
|
613
674
|
* .catch((error: Error) => {
|
|
614
|
-
* log(
|
|
675
|
+
* log('Failed to show form: ' + error);
|
|
615
676
|
* return -1;
|
|
616
677
|
* });
|
|
617
678
|
* }
|
|
618
679
|
* ```
|
|
619
680
|
* @example showTranslatedMessageForm.ts
|
|
620
681
|
* ```typescript
|
|
621
|
-
* import { world, DimensionLocation } from
|
|
622
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
682
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
683
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
623
684
|
*
|
|
624
|
-
* function showTranslatedMessageForm(
|
|
625
|
-
* log: (message: string, status?: number) => void,
|
|
626
|
-
* targetLocation: DimensionLocation
|
|
627
|
-
* ) {
|
|
685
|
+
* function showTranslatedMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
628
686
|
* const players = world.getPlayers();
|
|
629
687
|
*
|
|
630
688
|
* const messageForm = new MessageFormData()
|
|
631
|
-
* .title({ translate:
|
|
632
|
-
* .body({ translate:
|
|
633
|
-
* .button1(
|
|
634
|
-
* .button2(
|
|
689
|
+
* .title({ translate: 'permissions.removeplayer' })
|
|
690
|
+
* .body({ translate: 'accessibility.list.or.two', with: ['Player 1', 'Player 2'] })
|
|
691
|
+
* .button1('Player 1')
|
|
692
|
+
* .button2('Player 2');
|
|
635
693
|
*
|
|
636
694
|
* messageForm
|
|
637
695
|
* .show(players[0])
|
|
@@ -641,10 +699,10 @@ export class MessageFormData {
|
|
|
641
699
|
* return;
|
|
642
700
|
* }
|
|
643
701
|
*
|
|
644
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
702
|
+
* log(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
645
703
|
* })
|
|
646
704
|
* .catch((error: Error) => {
|
|
647
|
-
* log(
|
|
705
|
+
* log('Failed to show form: ' + error);
|
|
648
706
|
* return -1;
|
|
649
707
|
* });
|
|
650
708
|
* }
|
|
@@ -666,33 +724,33 @@ export class MessageFormResponse extends FormResponse {
|
|
|
666
724
|
* player.
|
|
667
725
|
* @example showBasicModalForm.ts
|
|
668
726
|
* ```typescript
|
|
669
|
-
* import { world, DimensionLocation } from
|
|
670
|
-
* import { ModalFormData } from
|
|
727
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
728
|
+
* import { ModalFormData } from '@minecraft/server-ui';
|
|
671
729
|
*
|
|
672
730
|
* function showBasicModalForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
673
731
|
* const players = world.getPlayers();
|
|
674
732
|
*
|
|
675
|
-
* const modalForm = new ModalFormData().title(
|
|
733
|
+
* const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r');
|
|
676
734
|
*
|
|
677
|
-
* modalForm.toggle(
|
|
678
|
-
* modalForm.toggle(
|
|
735
|
+
* modalForm.toggle('Toggle w/o default');
|
|
736
|
+
* modalForm.toggle('Toggle w/ default', true);
|
|
679
737
|
*
|
|
680
|
-
* modalForm.slider(
|
|
681
|
-
* modalForm.slider(
|
|
738
|
+
* modalForm.slider('Slider w/o default', 0, 50, 5);
|
|
739
|
+
* modalForm.slider('Slider w/ default', 0, 50, 5, 30);
|
|
682
740
|
*
|
|
683
|
-
* modalForm.dropdown(
|
|
684
|
-
* modalForm.dropdown(
|
|
741
|
+
* modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']);
|
|
742
|
+
* modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2);
|
|
685
743
|
*
|
|
686
|
-
* modalForm.textField(
|
|
687
|
-
* modalForm.textField(
|
|
744
|
+
* modalForm.textField('Input w/o default', 'type text here');
|
|
745
|
+
* modalForm.textField('Input w/ default', 'type text here', 'this is default');
|
|
688
746
|
*
|
|
689
747
|
* modalForm
|
|
690
748
|
* .show(players[0])
|
|
691
|
-
* .then(
|
|
749
|
+
* .then(formData => {
|
|
692
750
|
* players[0].sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`);
|
|
693
751
|
* })
|
|
694
752
|
* .catch((error: Error) => {
|
|
695
|
-
* log(
|
|
753
|
+
* log('Failed to show form: ' + error);
|
|
696
754
|
* return -1;
|
|
697
755
|
* });
|
|
698
756
|
* }
|
|
@@ -814,33 +872,33 @@ export class ModalFormData {
|
|
|
814
872
|
* Returns data about player responses to a modal form.
|
|
815
873
|
* @example showBasicModalForm.ts
|
|
816
874
|
* ```typescript
|
|
817
|
-
* import { world, DimensionLocation } from
|
|
818
|
-
* import { ModalFormData } from
|
|
875
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
876
|
+
* import { ModalFormData } from '@minecraft/server-ui';
|
|
819
877
|
*
|
|
820
878
|
* function showBasicModalForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
821
879
|
* const players = world.getPlayers();
|
|
822
880
|
*
|
|
823
|
-
* const modalForm = new ModalFormData().title(
|
|
881
|
+
* const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r');
|
|
824
882
|
*
|
|
825
|
-
* modalForm.toggle(
|
|
826
|
-
* modalForm.toggle(
|
|
883
|
+
* modalForm.toggle('Toggle w/o default');
|
|
884
|
+
* modalForm.toggle('Toggle w/ default', true);
|
|
827
885
|
*
|
|
828
|
-
* modalForm.slider(
|
|
829
|
-
* modalForm.slider(
|
|
886
|
+
* modalForm.slider('Slider w/o default', 0, 50, 5);
|
|
887
|
+
* modalForm.slider('Slider w/ default', 0, 50, 5, 30);
|
|
830
888
|
*
|
|
831
|
-
* modalForm.dropdown(
|
|
832
|
-
* modalForm.dropdown(
|
|
889
|
+
* modalForm.dropdown('Dropdown w/o default', ['option 1', 'option 2', 'option 3']);
|
|
890
|
+
* modalForm.dropdown('Dropdown w/ default', ['option 1', 'option 2', 'option 3'], 2);
|
|
833
891
|
*
|
|
834
|
-
* modalForm.textField(
|
|
835
|
-
* modalForm.textField(
|
|
892
|
+
* modalForm.textField('Input w/o default', 'type text here');
|
|
893
|
+
* modalForm.textField('Input w/ default', 'type text here', 'this is default');
|
|
836
894
|
*
|
|
837
895
|
* modalForm
|
|
838
896
|
* .show(players[0])
|
|
839
|
-
* .then(
|
|
897
|
+
* .then(formData => {
|
|
840
898
|
* players[0].sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`);
|
|
841
899
|
* })
|
|
842
900
|
* .catch((error: Error) => {
|
|
843
|
-
* log(
|
|
901
|
+
* log('Failed to show form: ' + error);
|
|
844
902
|
* return -1;
|
|
845
903
|
* });
|
|
846
904
|
* }
|
|
@@ -870,6 +928,21 @@ export declare class Observable<T extends string | number | boolean | UIRawMessa
|
|
|
870
928
|
*
|
|
871
929
|
*/
|
|
872
930
|
getData(): T;
|
|
931
|
+
/**
|
|
932
|
+
* @remarks
|
|
933
|
+
* Gets filtered data from the Observable (only available for
|
|
934
|
+
* strings). In case of failure, it will return an array of
|
|
935
|
+
* TextFilteringError that can provide more context about the
|
|
936
|
+
* filtering process. For testing purposes, the options are
|
|
937
|
+
* available under "Creator -> Text Filtering" settings menu.
|
|
938
|
+
* This delay is only applied to the getFilteredText function
|
|
939
|
+
* and can be used to simulate network latency when testing.
|
|
940
|
+
*
|
|
941
|
+
*/
|
|
942
|
+
getFilteredText(
|
|
943
|
+
this: Observable<T & string>,
|
|
944
|
+
player: minecraftserver.Player,
|
|
945
|
+
): Promise<string | TextFilteringError[]>;
|
|
873
946
|
/**
|
|
874
947
|
* @remarks
|
|
875
948
|
* Sets the data on this Observable and notifies the
|
|
@@ -885,6 +958,7 @@ export declare class Observable<T extends string | number | boolean | UIRawMessa
|
|
|
885
958
|
*
|
|
886
959
|
*/
|
|
887
960
|
subscribe(listener: (newValue: T) => void): (newValue: T) => void;
|
|
961
|
+
toJSON(): unknown;
|
|
888
962
|
/**
|
|
889
963
|
* @remarks
|
|
890
964
|
* Unsubscribe a callback from any changes that occur to the
|
|
@@ -904,6 +978,22 @@ export declare class Observable<T extends string | number | boolean | UIRawMessa
|
|
|
904
978
|
): Observable<T>;
|
|
905
979
|
}
|
|
906
980
|
|
|
981
|
+
/**
|
|
982
|
+
* @beta
|
|
983
|
+
* Thrown when a DDUI screen is rejected because the player
|
|
984
|
+
* left before responding.
|
|
985
|
+
*/
|
|
986
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
987
|
+
export declare class PlayerLeftError extends Error {}
|
|
988
|
+
|
|
989
|
+
/**
|
|
990
|
+
* @beta
|
|
991
|
+
* Thrown when a DDUI screen is rejected because the server is
|
|
992
|
+
* shutting down.
|
|
993
|
+
*/
|
|
994
|
+
// @ts-ignore Class inheritance allowed for native defined classes
|
|
995
|
+
export declare class ServerShutdownError extends Error {}
|
|
996
|
+
|
|
907
997
|
export class UIManager {
|
|
908
998
|
private constructor();
|
|
909
999
|
/**
|
|
@@ -1012,17 +1102,17 @@ export interface DropdownOptions {
|
|
|
1012
1102
|
export interface MessageBoxResult {
|
|
1013
1103
|
/**
|
|
1014
1104
|
* @remarks
|
|
1015
|
-
* The
|
|
1016
|
-
* without pressing a button.
|
|
1105
|
+
* The reason the message box was closed.
|
|
1017
1106
|
*
|
|
1018
1107
|
*/
|
|
1019
|
-
|
|
1108
|
+
closeReason: DataDrivenScreenClosedReason;
|
|
1020
1109
|
/**
|
|
1021
1110
|
* @remarks
|
|
1022
|
-
*
|
|
1111
|
+
* The button that was selected, undefined if it was closed
|
|
1112
|
+
* without pressing a button.
|
|
1023
1113
|
*
|
|
1024
1114
|
*/
|
|
1025
|
-
|
|
1115
|
+
selection?: number;
|
|
1026
1116
|
}
|
|
1027
1117
|
|
|
1028
1118
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minecraft/server-ui",
|
|
3
|
-
"version": "2.1.0-beta.1.26.20-preview.
|
|
3
|
+
"version": "2.1.0-beta.1.26.20-preview.23",
|
|
4
4
|
"description": "",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"peerDependencies": {
|
|
16
16
|
"@minecraft/common": "^1.0.0",
|
|
17
|
-
"@minecraft/server": "^2.0.0 || ^2.8.0-beta.1.26.20-preview.
|
|
17
|
+
"@minecraft/server": "^2.0.0 || ^2.8.0-beta.1.26.20-preview.23"
|
|
18
18
|
},
|
|
19
19
|
"license": "MIT"
|
|
20
20
|
}
|