Form Error handling & small code cleanup

This commit is contained in:
ForestOfLight
2025-04-13 14:27:41 -07:00
Unverified
parent b74362166f
commit 1a56192682
7 changed files with 31 additions and 23 deletions
+1 -10
View File
@@ -2,7 +2,6 @@ import { forceShow } from '../utils';
import { structureCollection } from './StructureCollection';
import { MenuFormBuilder } from './MenuFormBuilder';
import { InstanceEditForm } from './InstanceEditForm';
import { world } from '@minecraft/server';
export class MenuForm {
constructor(player, { jumpToInstance = true } = {}) {
@@ -13,7 +12,7 @@ export class MenuForm {
async show(jumpToInstance = true) {
let instanceName;
if (jumpToInstance) {
instanceName = this.getInstanceNameAtLocation();
instanceName = structureCollection.getStructure(this.player.dimension.id, this.player.location, { useLayers: false })?.name;
if (instanceName) {
new InstanceEditForm(this.player, instanceName);
return;
@@ -25,14 +24,6 @@ export class MenuForm {
new InstanceEditForm(this.player, instanceName);
}
getInstanceNameAtLocation() {
const locatedStructures = structureCollection.getStructures(this.player.dimension.id, this.player.location, { useLayers: false });
if (locatedStructures.length === 0)
return void 0;
const structure = locatedStructures[0];
return structure.name;
}
async getInstanceNameFromForm() {
try {
return forceShow(this.player, MenuFormBuilder.buildAllInstanceName()).then((response) => {