forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionForm.js
More file actions
43 lines (43 loc) · 1.02 KB
/
ActionForm.js
File metadata and controls
43 lines (43 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ActionFormData } from "@minecraft/server-ui";
export class ActionFormButton {
constructor(text, iconPath) {
this.text = text;
this.iconPath = iconPath;
}
;
}
;
/**
* Builds a simple player form with buttons that let the player
* take action.
*/
export class ActionFormBuilder {
constructor() {
/**
* Buttons of the the modal dialog.
*/
this.buttons = [];
}
body(bodyText) {
this.bodyText = bodyText;
return this;
}
button(text, iconPath) {
this.buttons.push(new ActionFormButton(text, iconPath));
return this;
}
show(player) {
const form = new ActionFormData();
if (!!this.titleText)
form.title(this.titleText);
if (!!this.bodyText)
form.body(this.bodyText);
this.buttons.forEach(item => form.button(item.text, item.iconPath));
return form.show(player);
}
title(titleText) {
this.titleText = titleText;
return this;
}
}
;