import { FormCancelationReason } from '@minecraft/server-ui'; export async function forceShow(player, form, timeout = Infinity) { const startTick = system.currentTick; 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' }); if (response.cancelationReason !== FormCancelationReason.UserBusy) return response; } throw new Error({ translate: 'commands.canopy.menu.timeout', with: [String(timeout)] }); };