Files
Construct/scripts/classes/MenuFormBuilder.js
T
2025-04-13 01:50:15 -07:00

54 lines
2.1 KiB
JavaScript

import { ActionFormData, ModalFormData } from '@minecraft/server-ui';
import { structureCollection } from './StructureCollection';
export class MenuFormBuilder {
static menuTitle = '§l§2StrucTool §8Menu';
static buildAllInstanceName() {
const allInstanceNameForm = new ActionFormData()
.title(this.menuTitle)
.body('Select an instance:');
structureCollection.getInstanceNames().forEach(instanceName => {
allInstanceNameForm.button(`§2${instanceName}`);
});
allInstanceNameForm.button('Create New Instance');
allInstanceNameForm.button('How to Add New Structures');
return allInstanceNameForm;
}
static buildNewInstance() {
return new ModalFormData()
.title(this.menuTitle)
.textField('Enter a name for the new instance:', 'example_instance')
.submitButton('Submit');
}
static buildAllStructures() {
const allStructuresForm = new ActionFormData()
.title(this.menuTitle)
.body('Select a structure:');
structureCollection.getWorldStructureIds().forEach(structureId => {
const structureName = structureId.replace('mystructure:', '');
allStructuresForm.button(`§2${structureName}`);
});
allStructuresForm.button('Other');
return allStructuresForm;
}
static buildOtherStructure() {
return new ModalFormData()
.title(this.menuTitle)
.textField('Enter the Structure ID:', 'example_structure')
.submitButton('Submit');
}
static buildHowToAddNewStructures() {
let body = "How to Add Structures:\n"
body += "§7- Save a structure using a structure block or the /structure command.\n"
body += "§7OR\n"
body += "§7- Add a mcstructure file to this pack's structures folder. It will not appear in the list of structures, so enter the filename (without '.mcstructure') as the Structure ID.";
return new ActionFormData()
.title(this.menuTitle)
.body(body);
}
}