Skip to content

Commit 1087a0a

Browse files
authored
Upload generated files for scripts (JaylyDev#208)
* Upload generated files * Fix JaylyDev#219
1 parent 71c56ad commit 1087a0a

9 files changed

Lines changed: 114 additions & 10 deletions

File tree

scripts/anti-32k/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* --------------------------------------------------------------------------
1616
*/
1717
import { world, EntityInventoryComponent, system, ItemEnchantsComponent } from "@minecraft/server";
18-
import { MinecraftEnchantmentTypes } from "@minecraft/vanilla-data";
18+
import { MinecraftEnchantmentTypes } from "@minecraft/vanilla-data/lib/index.js";
1919

2020
function onTick () {
2121
for (const player of world.getPlayers()) {

scripts/critical-hit/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# critical-hit
2+
3+
## Description
4+
> This README is auto generated, Edit the README so that users know what this package does.
5+
6+
## Credits
7+
These scripts were written by [Jayly](https://github.com/JaylyDev)

scripts/jaylydb/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Author: Jayly <https://github.com/JaylyDev>
33
// Project: https://github.com/JaylyDev/ScriptAPI
44
var _a, _b, _c;
5+
// Script example for ScriptAPI
6+
// Author: Jayly <https://github.com/JaylyDev>
7+
// Project: https://github.com/JaylyDev/ScriptAPI
58
import { ScoreboardIdentityType, world } from "@minecraft/server";
69
const str = () => ('00000000000000000' + (Math.random() * 0xffffffffffffffff).toString(16)).slice(-16);
710
/**
@@ -74,9 +77,8 @@ const DisplayName = new (_b = class DisplayName {
7477
*/
7578
class JaylyDB {
7679
constructor(id) {
77-
var _b;
7880
this[_c] = JaylyDB.name;
79-
this.objective = (_b = world.scoreboard.getObjective(`jaylydb:` + id)) !== null && _b !== void 0 ? _b : world.scoreboard.addObjective(`jaylydb:` + id, uuid());
81+
this.objective = world.scoreboard.getObjective(`jaylydb:` + id) ?? world.scoreboard.addObjective(`jaylydb:` + id, uuid());
8082
}
8183
;
8284
getParticipant(key) {

scripts/tsconfig-base.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@minecraft/server-gametest": [ "../node_modules/@minecraft/server-gametest/index" ],
1414
"@minecraft/server-editor": [ "../lib/@minecraft/server-editor/index" ],
1515
"@minecraft/server-editor-bindings": [ "../lib/@minecraft/server-editor-bindings/index" ],
16-
"@minecraft/vanilla-data": [ "../node_modules/@minecraft/vanilla-data/lib/index" ]
16+
"@minecraft/vanilla-data/*": [ "../node_modules/@minecraft/vanilla-data/*" ]
1717
},
1818
"types": [],
1919
"typeRoots": [],

scripts/ui-wrapper/ActionForm.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { ActionFormData } from "@minecraft/server-ui";
2+
export class ActionFormButton {
3+
constructor(text, iconPath) {
4+
this.text = text;
5+
this.iconPath = iconPath;
6+
}
7+
;
8+
}
9+
;
10+
/**
11+
* Builds a simple player form with buttons that let the player
12+
* take action.
13+
*/
14+
export class ActionFormBuilder extends ActionFormData {
15+
constructor() {
16+
super(...arguments);
17+
/**
18+
* Buttons of the the modal dialog.
19+
*/
20+
this.buttons = [];
21+
}
22+
body(bodyText) {
23+
this.bodyText = bodyText;
24+
return this;
25+
}
26+
button(text, iconPath) {
27+
this.buttons.push(new ActionFormButton(text, iconPath));
28+
return this;
29+
}
30+
show(player) {
31+
if (!!this.titleText)
32+
super.title(this.titleText);
33+
if (!!this.bodyText)
34+
super.body(this.bodyText);
35+
this.buttons.forEach(item => super.button(item.text, item.iconPath));
36+
return super.show(player);
37+
}
38+
title(titleText) {
39+
this.titleText = titleText;
40+
return this;
41+
}
42+
}
43+
;

scripts/ui-wrapper/MessageForm.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { MessageFormData } from "@minecraft/server-ui";
2+
export class MessageFormButton {
3+
constructor(text) {
4+
this.text = text;
5+
}
6+
;
7+
}
8+
;
9+
/**
10+
* Builds a simple player form with buttons that let the player
11+
* take action.
12+
*/
13+
export class MessageFormBuilder extends MessageFormData {
14+
constructor() {
15+
super(...arguments);
16+
this.buttons = [];
17+
}
18+
body(bodyText) {
19+
this.bodyText = bodyText;
20+
return this;
21+
}
22+
button1(text) {
23+
this.buttons[0] = new MessageFormButton(text);
24+
return this;
25+
}
26+
button2(text) {
27+
this.buttons[1] = new MessageFormButton(text);
28+
return this;
29+
}
30+
show(player) {
31+
const [button1, button2] = this.buttons;
32+
if (!!this.titleText)
33+
super.title(this.titleText);
34+
if (!!this.bodyText)
35+
super.body(this.bodyText);
36+
if (!!button1)
37+
super.button1(button1.text);
38+
if (!!button2)
39+
super.button2(button2.text);
40+
return super.show(player);
41+
}
42+
title(titleText) {
43+
this.titleText = titleText;
44+
return this;
45+
}
46+
}
47+
;

scripts/ui-wrapper/ModalForm.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ModalFormData } from "@minecraft/server-ui";
2-
class ModalFormDropdown {
2+
export class ModalFormDropdown {
33
constructor(label, options, defaultValueIndex) {
44
this.label = label;
55
this.options = options;
@@ -8,7 +8,7 @@ class ModalFormDropdown {
88
;
99
}
1010
;
11-
class ModalFormSlider {
11+
export class ModalFormSlider {
1212
constructor(label, minimumValue, maximumValue, valueStep, defaultValue) {
1313
this.label = label;
1414
this.minimumValue = minimumValue;
@@ -19,7 +19,7 @@ class ModalFormSlider {
1919
;
2020
}
2121
;
22-
class ModalFormTextField {
22+
export class ModalFormTextField {
2323
constructor(label, placeholderText, defaultValue) {
2424
this.label = label;
2525
this.placeholderText = placeholderText;
@@ -28,7 +28,7 @@ class ModalFormTextField {
2828
;
2929
}
3030
;
31-
class ModalFormToggle {
31+
export class ModalFormToggle {
3232
constructor(label, defaultValue) {
3333
this.label = label;
3434
this.defaultValue = defaultValue;
@@ -40,7 +40,7 @@ class ModalFormToggle {
4040
* Used to create a fully customizable pop-up form for a
4141
* player.
4242
*/
43-
class ModalFormBuilder extends ModalFormData {
43+
export class ModalFormBuilder extends ModalFormData {
4444
constructor() {
4545
super(...arguments);
4646
/**
@@ -86,4 +86,3 @@ class ModalFormBuilder extends ModalFormData {
8686
}
8787
}
8888
;
89-
export { ModalFormBuilder };

scripts/ui-wrapper/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
// Author: Jayly <https://github.com/JaylyDev>
33
// Project: https://github.com/JaylyDev/ScriptAPI
44
export * from "./ModalForm";
5+
export * from "./MessageForm";
6+
export * from "./ActionForm";

scripts/ui-wrapper/tests.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ form.title("My Modal Form");
1515
// Show the form to the player and wait for a response
1616
async function showModalForm(player) {
1717
const response = await form.show(player);
18+
if (!response.formValues)
19+
return;
1820
console.log(`Player ${player.name} selected option ${response.formValues[0]} and toggled option ${response.formValues[1]}`);
1921
console.log(`Player ${player.name} selected slider value ${response.formValues[2]} and entered text "${response.formValues[3]}"`);
2022
// Clear the form content
@@ -27,6 +29,8 @@ async function showModalForm(player) {
2729
form.title("My Second Modal Form");
2830
// Show the second form to the same player and wait for a response
2931
const response2 = await form.show(player);
32+
if (!response2.formValues)
33+
return;
3034
console.log(`Player ${player.name} selected option ${response2.formValues[0]} and toggled option ${response2.formValues[1]}`);
3135
}
3236
// Listen for chat messages and show the form to the player who sent a specific message

0 commit comments

Comments
 (0)