form start

This commit is contained in:
ForestOfLight
2025-04-12 19:53:42 -07:00
Unverified
parent 0c90e13e2c
commit e43fb49d48
13 changed files with 372 additions and 48 deletions
+3 -2
View File
@@ -1,3 +1,4 @@
import { system } from '@minecraft/server';
import { FormCancelationReason } from '@minecraft/server-ui';
export async function forceShow(player, form, timeout = Infinity) {
@@ -5,9 +6,9 @@ export async function forceShow(player, form, timeout = Infinity) {
while ((system.currentTick - startTick) < timeout) {
const response = await form.show(player);
if (startTick + 1 === system.currentTick && response.cancelationReason === FormCancelationReason.UserBusy)
player.sendMessage({ translate: 'commands.canopy.menu.busy' });
player.sendMessage("§8Close your chat window to access the menu.");
if (response.cancelationReason !== FormCancelationReason.UserBusy)
return response;
}
throw new Error({ translate: 'commands.canopy.menu.timeout', with: [String(timeout)] });
throw new Error("Menu timed out.");
};