@minecraft/server-ui 2.1.0-beta.1.26.3-stable → 2.1.0-beta.1.26.30-preview.21
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/README.md +16 -16
- package/index.d.ts +730 -117
- package/package.json +19 -19
package/README.md
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
# `@minecraft/server-ui`
|
|
2
|
-
|
|
3
|
-
The `@minecraft/server-ui` module contains types for expressing simple dialog-based user experiences.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* [*@minecraft/server-ui.ActionFormData*](../../../scriptapi/minecraft/server-ui/ActionFormData.md) contain a list of buttons with captions and images that can be used for presenting a set of options to a player.
|
|
8
|
-
|
|
9
|
-
* [*@minecraft/server-ui.MessageFormData*](../../../scriptapi/minecraft/server-ui/MessageFormData.md) are simple two-button message experiences that are functional for Yes/No or OK/Cancel questions.
|
|
10
|
-
|
|
11
|
-
* [*@minecraft/server-ui.ModalFormData*](../../../scriptapi/minecraft/server-ui/ModalFormData.md) allow for a more flexible "questionnaire-style" list of controls that can be used to take input.
|
|
12
|
-
|
|
13
|
-
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
14
|
-
|
|
15
|
-
See full documentation for this module here:
|
|
16
|
-
|
|
1
|
+
# `@minecraft/server-ui`
|
|
2
|
+
|
|
3
|
+
The `@minecraft/server-ui` module contains types for expressing simple dialog-based user experiences.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
* [*@minecraft/server-ui.ActionFormData*](../../../scriptapi/minecraft/server-ui/ActionFormData.md) contain a list of buttons with captions and images that can be used for presenting a set of options to a player.
|
|
8
|
+
|
|
9
|
+
* [*@minecraft/server-ui.MessageFormData*](../../../scriptapi/minecraft/server-ui/MessageFormData.md) are simple two-button message experiences that are functional for Yes/No or OK/Cancel questions.
|
|
10
|
+
|
|
11
|
+
* [*@minecraft/server-ui.ModalFormData*](../../../scriptapi/minecraft/server-ui/ModalFormData.md) allow for a more flexible "questionnaire-style" list of controls that can be used to take input.
|
|
12
|
+
|
|
13
|
+
## **NOTE: This version of this module is still in pre-release. It may change or it may be removed in future releases.**
|
|
14
|
+
|
|
15
|
+
See full documentation for this module here:
|
|
16
|
+
|
|
17
17
|
https://learn.microsoft.com/en-us/minecraft/creator/scriptapi/minecraft/server-ui/minecraft-server-ui
|
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
|
* });
|
|
@@ -238,6 +301,153 @@ export class ActionFormResponse extends FormResponse {
|
|
|
238
301
|
readonly selection?: number;
|
|
239
302
|
}
|
|
240
303
|
|
|
304
|
+
/**
|
|
305
|
+
* @beta
|
|
306
|
+
* A customizable form that lets you put buttons, labels,
|
|
307
|
+
* toggles, dropdowns, sliders, and more into a form! Built on
|
|
308
|
+
* top of Observable, the form will update when the
|
|
309
|
+
* Observables' value changes.
|
|
310
|
+
*/
|
|
311
|
+
export declare class CustomForm {
|
|
312
|
+
/**
|
|
313
|
+
* @remarks
|
|
314
|
+
* Inserts a button into the Custom form. onClick is called
|
|
315
|
+
* when the button is pressed.
|
|
316
|
+
*
|
|
317
|
+
*/
|
|
318
|
+
button(
|
|
319
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
320
|
+
onClick: () => void,
|
|
321
|
+
options?: ButtonOptions,
|
|
322
|
+
): CustomForm;
|
|
323
|
+
/**
|
|
324
|
+
* @remarks
|
|
325
|
+
* Tell the client to close the form. Throws an error if the
|
|
326
|
+
* form is not open.
|
|
327
|
+
*
|
|
328
|
+
*/
|
|
329
|
+
close(): void;
|
|
330
|
+
/**
|
|
331
|
+
* @remarks
|
|
332
|
+
* Adds a close "X" button to the form.
|
|
333
|
+
*
|
|
334
|
+
*/
|
|
335
|
+
closeButton(): CustomForm;
|
|
336
|
+
/**
|
|
337
|
+
* @remarks
|
|
338
|
+
* Inserts a divider (i.e. a line) into the Custom form.
|
|
339
|
+
*
|
|
340
|
+
*/
|
|
341
|
+
divider(options?: DividerOptions): CustomForm;
|
|
342
|
+
/**
|
|
343
|
+
* @remarks
|
|
344
|
+
* Inserts a dropdown into the Custom form with the provided
|
|
345
|
+
* items. The value is based on the items value that selected.
|
|
346
|
+
*
|
|
347
|
+
*/
|
|
348
|
+
dropdown(
|
|
349
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
350
|
+
value: Observable<number>,
|
|
351
|
+
items: DropdownItem[],
|
|
352
|
+
options?: DropdownOptions,
|
|
353
|
+
): CustomForm;
|
|
354
|
+
/**
|
|
355
|
+
* @remarks
|
|
356
|
+
* Inserts a header (i.e. large sized text) into the Custom
|
|
357
|
+
* form.
|
|
358
|
+
*
|
|
359
|
+
*/
|
|
360
|
+
header(
|
|
361
|
+
text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
362
|
+
options?: TextOptions,
|
|
363
|
+
): CustomForm;
|
|
364
|
+
/**
|
|
365
|
+
* @remarks
|
|
366
|
+
* Returns true if the form is currently being shown to the
|
|
367
|
+
* player.
|
|
368
|
+
*
|
|
369
|
+
*/
|
|
370
|
+
isShowing(): boolean;
|
|
371
|
+
/**
|
|
372
|
+
* @remarks
|
|
373
|
+
* Inserts a label (i.e. medium sized text) into the Custom
|
|
374
|
+
* form.
|
|
375
|
+
*
|
|
376
|
+
*/
|
|
377
|
+
label(
|
|
378
|
+
text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
379
|
+
options?: TextOptions,
|
|
380
|
+
): CustomForm;
|
|
381
|
+
/**
|
|
382
|
+
* @remarks
|
|
383
|
+
* Shows the form to the player. Will return false if the
|
|
384
|
+
* client was busy (i.e. in another menu or this one is open).
|
|
385
|
+
* Will throw if the user disconnects.
|
|
386
|
+
*
|
|
387
|
+
* @throws
|
|
388
|
+
* *
|
|
389
|
+
*/
|
|
390
|
+
show(): Promise<DataDrivenScreenClosedReason>;
|
|
391
|
+
/**
|
|
392
|
+
* @remarks
|
|
393
|
+
* Creates a slider that lets players pick a number between
|
|
394
|
+
* minValue and maxValue. value must be client writable.
|
|
395
|
+
*
|
|
396
|
+
*/
|
|
397
|
+
slider(
|
|
398
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
399
|
+
value: Observable<number>,
|
|
400
|
+
minValue: Observable<number> | number,
|
|
401
|
+
maxValue: Observable<number> | number,
|
|
402
|
+
options?: SliderOptions,
|
|
403
|
+
): CustomForm;
|
|
404
|
+
/**
|
|
405
|
+
* @remarks
|
|
406
|
+
* Inserts a space into the Custom form.
|
|
407
|
+
*
|
|
408
|
+
*/
|
|
409
|
+
spacer(options?: SpacingOptions): CustomForm;
|
|
410
|
+
/**
|
|
411
|
+
* @remarks
|
|
412
|
+
* Inserts a text field into the Custom for that players can
|
|
413
|
+
* enter text into.
|
|
414
|
+
*
|
|
415
|
+
*/
|
|
416
|
+
textField(
|
|
417
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
418
|
+
text: Observable<string>,
|
|
419
|
+
options?: TextFieldOptions,
|
|
420
|
+
): CustomForm;
|
|
421
|
+
/**
|
|
422
|
+
* @remarks
|
|
423
|
+
* Inserts an on/off toggle that players can interact with into
|
|
424
|
+
* the Custom form.
|
|
425
|
+
*
|
|
426
|
+
*/
|
|
427
|
+
toggle(
|
|
428
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
429
|
+
toggled: Observable<boolean>,
|
|
430
|
+
options?: ToggleOptions,
|
|
431
|
+
): CustomForm;
|
|
432
|
+
/**
|
|
433
|
+
* @remarks
|
|
434
|
+
* Creates a Custom form to show to the player. Use this
|
|
435
|
+
* instead of a constructor.
|
|
436
|
+
*
|
|
437
|
+
*/
|
|
438
|
+
static create(
|
|
439
|
+
player: minecraftserver.Player,
|
|
440
|
+
title: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
441
|
+
): CustomForm;
|
|
442
|
+
}
|
|
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
|
+
|
|
241
451
|
/**
|
|
242
452
|
* Base type for a form response.
|
|
243
453
|
*/
|
|
@@ -258,24 +468,86 @@ export class FormResponse {
|
|
|
258
468
|
readonly canceled: boolean;
|
|
259
469
|
}
|
|
260
470
|
|
|
471
|
+
/**
|
|
472
|
+
* @beta
|
|
473
|
+
* A simple message form UI, 2 buttons and a text body.
|
|
474
|
+
*/
|
|
475
|
+
export declare class MessageBox {
|
|
476
|
+
/**
|
|
477
|
+
* @remarks
|
|
478
|
+
* Sets the data for the text in the body of the message box.
|
|
479
|
+
* It is contained within a scroll view to allow for lots of
|
|
480
|
+
* text.
|
|
481
|
+
*
|
|
482
|
+
*/
|
|
483
|
+
body(text: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage): MessageBox;
|
|
484
|
+
/**
|
|
485
|
+
* @remarks
|
|
486
|
+
* Sets the data for the top button in the message box.
|
|
487
|
+
*
|
|
488
|
+
*/
|
|
489
|
+
button1(
|
|
490
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
491
|
+
tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
492
|
+
): MessageBox;
|
|
493
|
+
/**
|
|
494
|
+
* @remarks
|
|
495
|
+
* Sets the data for the bottom button in the message box.
|
|
496
|
+
*
|
|
497
|
+
*/
|
|
498
|
+
button2(
|
|
499
|
+
label: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
500
|
+
tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
501
|
+
): MessageBox;
|
|
502
|
+
/**
|
|
503
|
+
* @remarks
|
|
504
|
+
* Tell the client to close the message box. Throws {@link
|
|
505
|
+
* FormCloseError} if the message box is not open.
|
|
506
|
+
*
|
|
507
|
+
*/
|
|
508
|
+
close(): void;
|
|
509
|
+
/**
|
|
510
|
+
* @remarks
|
|
511
|
+
* Returns true if the message box is currently being shown to
|
|
512
|
+
* the player.
|
|
513
|
+
*
|
|
514
|
+
*/
|
|
515
|
+
isShowing(): boolean;
|
|
516
|
+
/**
|
|
517
|
+
* @remarks
|
|
518
|
+
* Show this message box to the player. Will return a result
|
|
519
|
+
* even if the client was busy (i.e. in another menu). Will
|
|
520
|
+
* throw if the user disconnects.
|
|
521
|
+
*
|
|
522
|
+
*/
|
|
523
|
+
show(): Promise<MessageBoxResult>;
|
|
524
|
+
/**
|
|
525
|
+
* @remarks
|
|
526
|
+
* Creates a message box for a certain player. Use this instead
|
|
527
|
+
* of a constructor.
|
|
528
|
+
*
|
|
529
|
+
*/
|
|
530
|
+
static create(
|
|
531
|
+
player: minecraftserver.Player,
|
|
532
|
+
title: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage,
|
|
533
|
+
): MessageBox;
|
|
534
|
+
}
|
|
535
|
+
|
|
261
536
|
/**
|
|
262
537
|
* Builds a simple two-button modal dialog.
|
|
263
538
|
* @example showBasicMessageForm.ts
|
|
264
539
|
* ```typescript
|
|
265
|
-
* import { world, DimensionLocation } from
|
|
266
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
540
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
541
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
267
542
|
*
|
|
268
|
-
* function showBasicMessageForm(
|
|
269
|
-
* log: (message: string, status?: number) => void,
|
|
270
|
-
* targetLocation: DimensionLocation
|
|
271
|
-
* ) {
|
|
543
|
+
* function showBasicMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
272
544
|
* const players = world.getPlayers();
|
|
273
545
|
*
|
|
274
546
|
* const messageForm = new MessageFormData()
|
|
275
|
-
* .title(
|
|
276
|
-
* .body(
|
|
277
|
-
* .button1(
|
|
278
|
-
* .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');
|
|
279
551
|
*
|
|
280
552
|
* messageForm
|
|
281
553
|
* .show(players[0])
|
|
@@ -285,30 +557,27 @@ export class FormResponse {
|
|
|
285
557
|
* return;
|
|
286
558
|
* }
|
|
287
559
|
*
|
|
288
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
560
|
+
* log(`You selected ${formData.selection === 0 ? 'Button 1' : 'Button 2'}`);
|
|
289
561
|
* })
|
|
290
562
|
* .catch((error: Error) => {
|
|
291
|
-
* log(
|
|
563
|
+
* log('Failed to show form: ' + error);
|
|
292
564
|
* return -1;
|
|
293
565
|
* });
|
|
294
566
|
* }
|
|
295
567
|
* ```
|
|
296
568
|
* @example showTranslatedMessageForm.ts
|
|
297
569
|
* ```typescript
|
|
298
|
-
* import { world, DimensionLocation } from
|
|
299
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
570
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
571
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
300
572
|
*
|
|
301
|
-
* function showTranslatedMessageForm(
|
|
302
|
-
* log: (message: string, status?: number) => void,
|
|
303
|
-
* targetLocation: DimensionLocation
|
|
304
|
-
* ) {
|
|
573
|
+
* function showTranslatedMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
305
574
|
* const players = world.getPlayers();
|
|
306
575
|
*
|
|
307
576
|
* const messageForm = new MessageFormData()
|
|
308
|
-
* .title({ translate:
|
|
309
|
-
* .body({ translate:
|
|
310
|
-
* .button1(
|
|
311
|
-
* .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');
|
|
312
581
|
*
|
|
313
582
|
* messageForm
|
|
314
583
|
* .show(players[0])
|
|
@@ -318,10 +587,10 @@ export class FormResponse {
|
|
|
318
587
|
* return;
|
|
319
588
|
* }
|
|
320
589
|
*
|
|
321
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
590
|
+
* log(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
322
591
|
* })
|
|
323
592
|
* .catch((error: Error) => {
|
|
324
|
-
* log(
|
|
593
|
+
* log('Failed to show form: ' + error);
|
|
325
594
|
* return -1;
|
|
326
595
|
* });
|
|
327
596
|
* }
|
|
@@ -380,20 +649,17 @@ export class MessageFormData {
|
|
|
380
649
|
* form.
|
|
381
650
|
* @example showBasicMessageForm.ts
|
|
382
651
|
* ```typescript
|
|
383
|
-
* import { world, DimensionLocation } from
|
|
384
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
652
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
653
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
385
654
|
*
|
|
386
|
-
* function showBasicMessageForm(
|
|
387
|
-
* log: (message: string, status?: number) => void,
|
|
388
|
-
* targetLocation: DimensionLocation
|
|
389
|
-
* ) {
|
|
655
|
+
* function showBasicMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
390
656
|
* const players = world.getPlayers();
|
|
391
657
|
*
|
|
392
658
|
* const messageForm = new MessageFormData()
|
|
393
|
-
* .title(
|
|
394
|
-
* .body(
|
|
395
|
-
* .button1(
|
|
396
|
-
* .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');
|
|
397
663
|
*
|
|
398
664
|
* messageForm
|
|
399
665
|
* .show(players[0])
|
|
@@ -403,30 +669,27 @@ export class MessageFormData {
|
|
|
403
669
|
* return;
|
|
404
670
|
* }
|
|
405
671
|
*
|
|
406
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
672
|
+
* log(`You selected ${formData.selection === 0 ? 'Button 1' : 'Button 2'}`);
|
|
407
673
|
* })
|
|
408
674
|
* .catch((error: Error) => {
|
|
409
|
-
* log(
|
|
675
|
+
* log('Failed to show form: ' + error);
|
|
410
676
|
* return -1;
|
|
411
677
|
* });
|
|
412
678
|
* }
|
|
413
679
|
* ```
|
|
414
680
|
* @example showTranslatedMessageForm.ts
|
|
415
681
|
* ```typescript
|
|
416
|
-
* import { world, DimensionLocation } from
|
|
417
|
-
* import { MessageFormResponse, MessageFormData } from
|
|
682
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
683
|
+
* import { MessageFormResponse, MessageFormData } from '@minecraft/server-ui';
|
|
418
684
|
*
|
|
419
|
-
* function showTranslatedMessageForm(
|
|
420
|
-
* log: (message: string, status?: number) => void,
|
|
421
|
-
* targetLocation: DimensionLocation
|
|
422
|
-
* ) {
|
|
685
|
+
* function showTranslatedMessageForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
423
686
|
* const players = world.getPlayers();
|
|
424
687
|
*
|
|
425
688
|
* const messageForm = new MessageFormData()
|
|
426
|
-
* .title({ translate:
|
|
427
|
-
* .body({ translate:
|
|
428
|
-
* .button1(
|
|
429
|
-
* .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');
|
|
430
693
|
*
|
|
431
694
|
* messageForm
|
|
432
695
|
* .show(players[0])
|
|
@@ -436,10 +699,10 @@ export class MessageFormData {
|
|
|
436
699
|
* return;
|
|
437
700
|
* }
|
|
438
701
|
*
|
|
439
|
-
* log(`You selected ${formData.selection === 0 ?
|
|
702
|
+
* log(`You selected ${formData.selection === 0 ? 'Player 1' : 'Player 2'}`);
|
|
440
703
|
* })
|
|
441
704
|
* .catch((error: Error) => {
|
|
442
|
-
* log(
|
|
705
|
+
* log('Failed to show form: ' + error);
|
|
443
706
|
* return -1;
|
|
444
707
|
* });
|
|
445
708
|
* }
|
|
@@ -461,33 +724,33 @@ export class MessageFormResponse extends FormResponse {
|
|
|
461
724
|
* player.
|
|
462
725
|
* @example showBasicModalForm.ts
|
|
463
726
|
* ```typescript
|
|
464
|
-
* import { world, DimensionLocation } from
|
|
465
|
-
* import { ModalFormData } from
|
|
727
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
728
|
+
* import { ModalFormData } from '@minecraft/server-ui';
|
|
466
729
|
*
|
|
467
730
|
* function showBasicModalForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
468
731
|
* const players = world.getPlayers();
|
|
469
732
|
*
|
|
470
|
-
* const modalForm = new ModalFormData().title(
|
|
733
|
+
* const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r');
|
|
471
734
|
*
|
|
472
|
-
* modalForm.toggle(
|
|
473
|
-
* modalForm.toggle(
|
|
735
|
+
* modalForm.toggle('Toggle w/o default');
|
|
736
|
+
* modalForm.toggle('Toggle w/ default', true);
|
|
474
737
|
*
|
|
475
|
-
* modalForm.slider(
|
|
476
|
-
* modalForm.slider(
|
|
738
|
+
* modalForm.slider('Slider w/o default', 0, 50, 5);
|
|
739
|
+
* modalForm.slider('Slider w/ default', 0, 50, 5, 30);
|
|
477
740
|
*
|
|
478
|
-
* modalForm.dropdown(
|
|
479
|
-
* 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);
|
|
480
743
|
*
|
|
481
|
-
* modalForm.textField(
|
|
482
|
-
* modalForm.textField(
|
|
744
|
+
* modalForm.textField('Input w/o default', 'type text here');
|
|
745
|
+
* modalForm.textField('Input w/ default', 'type text here', 'this is default');
|
|
483
746
|
*
|
|
484
747
|
* modalForm
|
|
485
748
|
* .show(players[0])
|
|
486
|
-
* .then(
|
|
749
|
+
* .then(formData => {
|
|
487
750
|
* players[0].sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`);
|
|
488
751
|
* })
|
|
489
752
|
* .catch((error: Error) => {
|
|
490
|
-
* log(
|
|
753
|
+
* log('Failed to show form: ' + error);
|
|
491
754
|
* return -1;
|
|
492
755
|
* });
|
|
493
756
|
* }
|
|
@@ -609,33 +872,33 @@ export class ModalFormData {
|
|
|
609
872
|
* Returns data about player responses to a modal form.
|
|
610
873
|
* @example showBasicModalForm.ts
|
|
611
874
|
* ```typescript
|
|
612
|
-
* import { world, DimensionLocation } from
|
|
613
|
-
* import { ModalFormData } from
|
|
875
|
+
* import { world, DimensionLocation } from '@minecraft/server';
|
|
876
|
+
* import { ModalFormData } from '@minecraft/server-ui';
|
|
614
877
|
*
|
|
615
878
|
* function showBasicModalForm(log: (message: string, status?: number) => void, targetLocation: DimensionLocation) {
|
|
616
879
|
* const players = world.getPlayers();
|
|
617
880
|
*
|
|
618
|
-
* const modalForm = new ModalFormData().title(
|
|
881
|
+
* const modalForm = new ModalFormData().title('Example Modal Controls for §o§7ModalFormData§r');
|
|
619
882
|
*
|
|
620
|
-
* modalForm.toggle(
|
|
621
|
-
* modalForm.toggle(
|
|
883
|
+
* modalForm.toggle('Toggle w/o default');
|
|
884
|
+
* modalForm.toggle('Toggle w/ default', true);
|
|
622
885
|
*
|
|
623
|
-
* modalForm.slider(
|
|
624
|
-
* modalForm.slider(
|
|
886
|
+
* modalForm.slider('Slider w/o default', 0, 50, 5);
|
|
887
|
+
* modalForm.slider('Slider w/ default', 0, 50, 5, 30);
|
|
625
888
|
*
|
|
626
|
-
* modalForm.dropdown(
|
|
627
|
-
* 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);
|
|
628
891
|
*
|
|
629
|
-
* modalForm.textField(
|
|
630
|
-
* modalForm.textField(
|
|
892
|
+
* modalForm.textField('Input w/o default', 'type text here');
|
|
893
|
+
* modalForm.textField('Input w/ default', 'type text here', 'this is default');
|
|
631
894
|
*
|
|
632
895
|
* modalForm
|
|
633
896
|
* .show(players[0])
|
|
634
|
-
* .then(
|
|
897
|
+
* .then(formData => {
|
|
635
898
|
* players[0].sendMessage(`Modal form results: ${JSON.stringify(formData.formValues, undefined, 2)}`);
|
|
636
899
|
* })
|
|
637
900
|
* .catch((error: Error) => {
|
|
638
|
-
* log(
|
|
901
|
+
* log('Failed to show form: ' + error);
|
|
639
902
|
* return -1;
|
|
640
903
|
* });
|
|
641
904
|
* }
|
|
@@ -653,6 +916,84 @@ export class ModalFormResponse extends FormResponse {
|
|
|
653
916
|
readonly formValues?: (boolean | number | string | undefined)[];
|
|
654
917
|
}
|
|
655
918
|
|
|
919
|
+
/**
|
|
920
|
+
* @beta
|
|
921
|
+
* A class that represents data that can be Observed.
|
|
922
|
+
* Extensively used for UI.
|
|
923
|
+
*/
|
|
924
|
+
export declare class Observable<T extends string | number | boolean | UIRawMessage> {
|
|
925
|
+
/**
|
|
926
|
+
* @remarks
|
|
927
|
+
* Gets the data from the Observable.
|
|
928
|
+
*
|
|
929
|
+
*/
|
|
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[]>;
|
|
946
|
+
/**
|
|
947
|
+
* @remarks
|
|
948
|
+
* Sets the data on this Observable and notifies the
|
|
949
|
+
* subscribers.
|
|
950
|
+
*
|
|
951
|
+
*/
|
|
952
|
+
setData(data: T): void;
|
|
953
|
+
/**
|
|
954
|
+
* @remarks
|
|
955
|
+
* Subscribes a callback to any changes that occur to the
|
|
956
|
+
* Observable. The return value can be passed into the
|
|
957
|
+
* `unsubscribe` function to stop listening to changes.
|
|
958
|
+
*
|
|
959
|
+
*/
|
|
960
|
+
subscribe(listener: (newValue: T) => void): (newValue: T) => void;
|
|
961
|
+
toJSON(): unknown;
|
|
962
|
+
/**
|
|
963
|
+
* @remarks
|
|
964
|
+
* Unsubscribe a callback from any changes that occur to the
|
|
965
|
+
* Observable. This takes the return value from the `subscribe`
|
|
966
|
+
* function.
|
|
967
|
+
*
|
|
968
|
+
*/
|
|
969
|
+
unsubscribe(listener: (newValue: T) => void): void;
|
|
970
|
+
/**
|
|
971
|
+
* @remarks
|
|
972
|
+
* Creates an Observable, use this instead of a constructor.
|
|
973
|
+
*
|
|
974
|
+
*/
|
|
975
|
+
static create<T extends string | number | boolean | UIRawMessage>(
|
|
976
|
+
data: T,
|
|
977
|
+
options?: ObservableOptions,
|
|
978
|
+
): Observable<T>;
|
|
979
|
+
}
|
|
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
|
+
|
|
656
997
|
export class UIManager {
|
|
657
998
|
private constructor();
|
|
658
999
|
/**
|
|
@@ -664,6 +1005,116 @@ export class UIManager {
|
|
|
664
1005
|
closeAllForms(player: minecraftserver.Player): void;
|
|
665
1006
|
}
|
|
666
1007
|
|
|
1008
|
+
/**
|
|
1009
|
+
* @beta
|
|
1010
|
+
* The options for including a button in {@link CustomForm}.
|
|
1011
|
+
*/
|
|
1012
|
+
export interface ButtonOptions {
|
|
1013
|
+
/**
|
|
1014
|
+
* @remarks
|
|
1015
|
+
* Whether or not this button is disabled.
|
|
1016
|
+
*
|
|
1017
|
+
*/
|
|
1018
|
+
disabled?: Observable<boolean> | boolean;
|
|
1019
|
+
/**
|
|
1020
|
+
* @remarks
|
|
1021
|
+
* The tooltip for this button, shown when hovering the button.
|
|
1022
|
+
*
|
|
1023
|
+
*/
|
|
1024
|
+
tooltip?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
|
|
1025
|
+
/**
|
|
1026
|
+
* @remarks
|
|
1027
|
+
* Whether or not this button is visible.
|
|
1028
|
+
*
|
|
1029
|
+
*/
|
|
1030
|
+
visible?: Observable<boolean> | boolean;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* @beta
|
|
1035
|
+
* The options for including a spacer in {@link CustomForm}.
|
|
1036
|
+
*/
|
|
1037
|
+
export interface DividerOptions {
|
|
1038
|
+
/**
|
|
1039
|
+
* @remarks
|
|
1040
|
+
* Whether or not this divider is visible
|
|
1041
|
+
*
|
|
1042
|
+
*/
|
|
1043
|
+
visible?: Observable<boolean> | boolean;
|
|
1044
|
+
}
|
|
1045
|
+
|
|
1046
|
+
/**
|
|
1047
|
+
* @beta
|
|
1048
|
+
* Dropdown data for use in {@link CustomForm}.
|
|
1049
|
+
*/
|
|
1050
|
+
export interface DropdownItem {
|
|
1051
|
+
/**
|
|
1052
|
+
* @remarks
|
|
1053
|
+
* The description of the dropdown item shown when it is
|
|
1054
|
+
* selected.
|
|
1055
|
+
*
|
|
1056
|
+
*/
|
|
1057
|
+
description?: UIRawMessage | string;
|
|
1058
|
+
/**
|
|
1059
|
+
* @remarks
|
|
1060
|
+
* The label of the dropdown item in the dropdown.
|
|
1061
|
+
*
|
|
1062
|
+
*/
|
|
1063
|
+
label: UIRawMessage | string;
|
|
1064
|
+
/**
|
|
1065
|
+
* @remarks
|
|
1066
|
+
* The value the dropdown will be set to when this item is
|
|
1067
|
+
* selected.
|
|
1068
|
+
*
|
|
1069
|
+
*/
|
|
1070
|
+
value: number;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* @beta
|
|
1075
|
+
* The options for including a dropdown in {@link CustomForm}.
|
|
1076
|
+
*/
|
|
1077
|
+
export interface DropdownOptions {
|
|
1078
|
+
/**
|
|
1079
|
+
* @remarks
|
|
1080
|
+
* The description of the dropdown, shown in the UI.
|
|
1081
|
+
*
|
|
1082
|
+
*/
|
|
1083
|
+
description?: Observable<string> | string | UIRawMessage;
|
|
1084
|
+
/**
|
|
1085
|
+
* @remarks
|
|
1086
|
+
* Whether or not this dropdown is disabled.
|
|
1087
|
+
*
|
|
1088
|
+
*/
|
|
1089
|
+
disabled?: Observable<boolean> | boolean;
|
|
1090
|
+
/**
|
|
1091
|
+
* @remarks
|
|
1092
|
+
* Whether or not this dropdown is visible.
|
|
1093
|
+
*
|
|
1094
|
+
*/
|
|
1095
|
+
visible?: Observable<boolean> | boolean;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
/**
|
|
1099
|
+
* @beta
|
|
1100
|
+
* The result when a {@link MessageBox} is closed.
|
|
1101
|
+
*/
|
|
1102
|
+
export interface MessageBoxResult {
|
|
1103
|
+
/**
|
|
1104
|
+
* @remarks
|
|
1105
|
+
* The reason the message box was closed.
|
|
1106
|
+
*
|
|
1107
|
+
*/
|
|
1108
|
+
closeReason: DataDrivenScreenClosedReason;
|
|
1109
|
+
/**
|
|
1110
|
+
* @remarks
|
|
1111
|
+
* The button that was selected, undefined if it was closed
|
|
1112
|
+
* without pressing a button.
|
|
1113
|
+
*
|
|
1114
|
+
*/
|
|
1115
|
+
selection?: number;
|
|
1116
|
+
}
|
|
1117
|
+
|
|
667
1118
|
/**
|
|
668
1119
|
* An interface that is passed into {@link
|
|
669
1120
|
* @minecraft/Server-ui.ModalFormData.dropdown} to provide
|
|
@@ -756,6 +1207,168 @@ export interface ModalFormDataToggleOptions {
|
|
|
756
1207
|
tooltip?: minecraftserver.RawMessage | string;
|
|
757
1208
|
}
|
|
758
1209
|
|
|
1210
|
+
/**
|
|
1211
|
+
* @beta
|
|
1212
|
+
* An interface passed into `Observable.create`.
|
|
1213
|
+
*/
|
|
1214
|
+
export interface ObservableOptions {
|
|
1215
|
+
/**
|
|
1216
|
+
* @remarks
|
|
1217
|
+
* If set to true, the client can update this value. This
|
|
1218
|
+
* should be used for things like dropdown values, toggles,
|
|
1219
|
+
* textfields, etc. If unset or false, the client cannot write
|
|
1220
|
+
* to this observable.
|
|
1221
|
+
*
|
|
1222
|
+
*/
|
|
1223
|
+
clientWritable?: boolean;
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* @beta
|
|
1228
|
+
* The options for including a slider in {@link CustomForm}.
|
|
1229
|
+
*/
|
|
1230
|
+
export interface SliderOptions {
|
|
1231
|
+
/**
|
|
1232
|
+
* @remarks
|
|
1233
|
+
* The description of the slider, shown in the UI.
|
|
1234
|
+
*
|
|
1235
|
+
*/
|
|
1236
|
+
description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
|
|
1237
|
+
/**
|
|
1238
|
+
* @remarks
|
|
1239
|
+
* Whether or not this slider is disabled.
|
|
1240
|
+
*
|
|
1241
|
+
*/
|
|
1242
|
+
disabled?: Observable<boolean> | boolean;
|
|
1243
|
+
/**
|
|
1244
|
+
* @remarks
|
|
1245
|
+
* The step size of the slider. For example, if this is 2 and
|
|
1246
|
+
* the min is 0 and the max is 10, the only selectable values
|
|
1247
|
+
* will be 0, 2, 4, 6, 8, 10.
|
|
1248
|
+
*
|
|
1249
|
+
*/
|
|
1250
|
+
step?: Observable<number> | number;
|
|
1251
|
+
/**
|
|
1252
|
+
* @remarks
|
|
1253
|
+
* Whether or not this slider is visible.
|
|
1254
|
+
*
|
|
1255
|
+
*/
|
|
1256
|
+
visible?: Observable<boolean> | boolean;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
/**
|
|
1260
|
+
* @beta
|
|
1261
|
+
* The options for including a spacer in {@link CustomForm}.
|
|
1262
|
+
*/
|
|
1263
|
+
export interface SpacingOptions {
|
|
1264
|
+
/**
|
|
1265
|
+
* @remarks
|
|
1266
|
+
* Whether or not this spacer is visible
|
|
1267
|
+
*
|
|
1268
|
+
*/
|
|
1269
|
+
visible?: Observable<boolean> | boolean;
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* @beta
|
|
1274
|
+
* The options for including a textfield in {@link CustomForm}.
|
|
1275
|
+
*/
|
|
1276
|
+
export interface TextFieldOptions {
|
|
1277
|
+
/**
|
|
1278
|
+
* @remarks
|
|
1279
|
+
* The description for this text field, shown in the UI.
|
|
1280
|
+
*
|
|
1281
|
+
*/
|
|
1282
|
+
description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
|
|
1283
|
+
/**
|
|
1284
|
+
* @remarks
|
|
1285
|
+
* Whether or not this text field is disabled.
|
|
1286
|
+
*
|
|
1287
|
+
*/
|
|
1288
|
+
disabled?: Observable<boolean> | boolean;
|
|
1289
|
+
/**
|
|
1290
|
+
* @remarks
|
|
1291
|
+
* Whether or not this text field is visible.
|
|
1292
|
+
*
|
|
1293
|
+
*/
|
|
1294
|
+
visible?: Observable<boolean> | boolean;
|
|
1295
|
+
}
|
|
1296
|
+
|
|
1297
|
+
/**
|
|
1298
|
+
* @beta
|
|
1299
|
+
* The options for including a label or header in {@link
|
|
1300
|
+
* CustomForm}.
|
|
1301
|
+
*/
|
|
1302
|
+
export interface TextOptions {
|
|
1303
|
+
/**
|
|
1304
|
+
* @remarks
|
|
1305
|
+
* Whether or not this label is visible
|
|
1306
|
+
*
|
|
1307
|
+
*/
|
|
1308
|
+
visible?: Observable<boolean> | boolean;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
/**
|
|
1312
|
+
* @beta
|
|
1313
|
+
* The options for including a toggle in {@link CustomForm}.
|
|
1314
|
+
*/
|
|
1315
|
+
export interface ToggleOptions {
|
|
1316
|
+
/**
|
|
1317
|
+
* @remarks
|
|
1318
|
+
* The description for this toggle, shown in the UI.
|
|
1319
|
+
*
|
|
1320
|
+
*/
|
|
1321
|
+
description?: Observable<string> | Observable<UIRawMessage> | string | UIRawMessage;
|
|
1322
|
+
/**
|
|
1323
|
+
* @remarks
|
|
1324
|
+
* Whether or not this toggle is disabled.
|
|
1325
|
+
*
|
|
1326
|
+
*/
|
|
1327
|
+
disabled?: Observable<boolean> | boolean;
|
|
1328
|
+
/**
|
|
1329
|
+
* @remarks
|
|
1330
|
+
* Whether or not this toggle is visible.
|
|
1331
|
+
*
|
|
1332
|
+
*/
|
|
1333
|
+
visible?: Observable<boolean> | boolean;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
/**
|
|
1337
|
+
* @beta
|
|
1338
|
+
* A message that can be sent to the client. This is a subset
|
|
1339
|
+
* of the RawMessage type, and is used for UI messages.
|
|
1340
|
+
*/
|
|
1341
|
+
export interface UIRawMessage {
|
|
1342
|
+
/**
|
|
1343
|
+
* @remarks
|
|
1344
|
+
* Provides a raw-text equivalent of the current message.
|
|
1345
|
+
*
|
|
1346
|
+
*/
|
|
1347
|
+
rawtext?: UIRawMessage[];
|
|
1348
|
+
/**
|
|
1349
|
+
* @remarks
|
|
1350
|
+
* Provides a string literal value to use.
|
|
1351
|
+
*
|
|
1352
|
+
*/
|
|
1353
|
+
text?: string;
|
|
1354
|
+
/**
|
|
1355
|
+
* @remarks
|
|
1356
|
+
* Provides a translation token where, if the client has an
|
|
1357
|
+
* available resource in the players' language which matches
|
|
1358
|
+
* the token, will get translated on the client.
|
|
1359
|
+
*
|
|
1360
|
+
*/
|
|
1361
|
+
translate?: string;
|
|
1362
|
+
/**
|
|
1363
|
+
* @remarks
|
|
1364
|
+
* Arguments for the translation token. Can be either an array
|
|
1365
|
+
* of strings or UIRawMessage containing an array of raw text
|
|
1366
|
+
* objects.
|
|
1367
|
+
*
|
|
1368
|
+
*/
|
|
1369
|
+
with?: string[] | UIRawMessage;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
759
1372
|
// @ts-ignore Class inheritance allowed for native defined classes
|
|
760
1373
|
export class FormRejectError extends Error {
|
|
761
1374
|
private constructor();
|
|
@@ -764,7 +1377,7 @@ export class FormRejectError extends Error {
|
|
|
764
1377
|
* This property can be read in early-execution mode.
|
|
765
1378
|
*
|
|
766
1379
|
*/
|
|
767
|
-
reason: FormRejectReason;
|
|
1380
|
+
readonly reason: FormRejectReason;
|
|
768
1381
|
}
|
|
769
1382
|
|
|
770
1383
|
export const uiManager: UIManager;
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@minecraft/server-ui",
|
|
3
|
-
"version": "2.1.0-beta.1.26.
|
|
4
|
-
"description": "",
|
|
5
|
-
"contributors": [
|
|
6
|
-
{
|
|
7
|
-
"name": "Jake Shirley",
|
|
8
|
-
"email": "jake@xbox.com"
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
"name": "Mike Ammerlaan",
|
|
12
|
-
"email": "mikeam@microsoft.com"
|
|
13
|
-
}
|
|
14
|
-
],
|
|
15
|
-
"peerDependencies": {
|
|
16
|
-
"@minecraft/common": "^1.0.0",
|
|
17
|
-
"@minecraft/server": "^2.0.0 || ^2.
|
|
18
|
-
},
|
|
19
|
-
"license": "MIT"
|
|
1
|
+
{
|
|
2
|
+
"name": "@minecraft/server-ui",
|
|
3
|
+
"version": "2.1.0-beta.1.26.30-preview.21",
|
|
4
|
+
"description": "",
|
|
5
|
+
"contributors": [
|
|
6
|
+
{
|
|
7
|
+
"name": "Jake Shirley",
|
|
8
|
+
"email": "jake@xbox.com"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
"name": "Mike Ammerlaan",
|
|
12
|
+
"email": "mikeam@microsoft.com"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@minecraft/common": "^1.0.0",
|
|
17
|
+
"@minecraft/server": "^2.0.0 || ^2.9.0-beta.1.26.30-preview.21"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT"
|
|
20
20
|
}
|