diff --git a/packs/BP/scripts/classes/Instance/InstanceForm.js b/packs/BP/scripts/classes/Instance/InstanceForm.js index 232b47b..375fc4e 100644 --- a/packs/BP/scripts/classes/Instance/InstanceForm.js +++ b/packs/BP/scripts/classes/Instance/InstanceForm.js @@ -155,13 +155,13 @@ export class InstanceForm { statsForm = await InstanceFormBuilder.buildStatistics(this.instance); } catch (e) { if (e.message === 'StructureVerifier is already running.') { - this.player.sendMessage('§cA verification is already in progress. Please wait until it finishes.'); + this.player.sendMessage({ translate: 'construct.instance.validation.alreadyRunning' }); return; } throw e; } if (!statsForm) { - this.player.sendMessage('§cFailed to build statistics form.'); + this.player.sendMessage({ translation: 'construct.instance.validation.formfail' }); return; } statsForm.form.show(this.player).then((response) => { diff --git a/packs/BP/scripts/classes/Instance/InstanceFormBuilder.js b/packs/BP/scripts/classes/Instance/InstanceFormBuilder.js index d54c6f9..16c19ab 100644 --- a/packs/BP/scripts/classes/Instance/InstanceFormBuilder.js +++ b/packs/BP/scripts/classes/Instance/InstanceFormBuilder.js @@ -11,12 +11,18 @@ export class InstanceFormBuilder { const location = instance.getLocation(); const form = new ActionFormData() .title(MenuFormBuilder.menuTitle) - let body = `Instance: §a${instance.getName()}\n§fStructure: §2${instance.getStructureId()}\n`; + let body = { rawtext: [ + { translate: 'construct.instance.menu.body', with: [instance.getName(), instance.getStructureId()] }, + { text: '\n' } + ]}; if (instance.hasLocation()) - body += `§7(${location.location.x} ${location.location.y} ${location.location.z} in ${location.dimensionId})\n`; + body.rawtext.push([ + { translate: 'construct.instance.menu.location', with: [String(location.location.x), String(location.location.y), String(location.location.z), location.dimensionId] }, + { text: '\n' } + ]); form.body(body); options.forEach(option => { - form.button(`${option}`); + form.button({ translate: option }); }); return form; } @@ -24,8 +30,8 @@ export class InstanceFormBuilder { static buildRenameInstance(currentName) { return new ModalFormData() .title(MenuFormBuilder.menuTitle) - .textField('Enter a new name for the instance:', currentName) - .submitButton('Rename'); + .textField({ translate: 'construct.isntance.menu.rename' }, currentName) + .submitButton({ translate: 'construct.menu.instance.button.rename' }); } static async buildStatistics(instance) { @@ -45,9 +51,9 @@ export class InstanceFormBuilder { static buildSettings(instance) { return new ModalFormData() .title(MenuFormBuilder.menuTitle) - .toggle('Block Validation', { defaultValue: instance.options.verifier.isEnabled, tooltip: 'Shows missing and incorrect block overlay.' }) - .slider("Layer", 0, instance.getMaxLayer(), { defaultValue: instance.getLayer(), valueStep: 1, tooltip: 'Changes the active layer. Use 0 for all layers.' }) - .submitButton('§2Apply'); + .toggle({ translate: 'construct.instance.option.validation' }, { defaultValue: instance.options.verifier.isEnabled, tooltip: { translate: 'construct.instance.option.validation.description' }}) + .slider({ translate: 'construct.instance.option.layer'}, 0, instance.getMaxLayer(), { defaultValue: instance.getLayer(), valueStep: 1, tooltip: { translate: 'construct.instance.option.layer.description' }}) + .submitButton({ translate: 'construct.menu.submit' }); } static buildMaterialList(instance, onlyMissing = false, player = false) { @@ -59,25 +65,25 @@ export class InstanceFormBuilder { if (onlyMissing) { const inventoryContainer = player?.getComponent(EntityComponentTypes.Inventory)?.container; if (!inventoryContainer) { - form.body('§cNo player inventory found.'); + form.body({ translate: 'construct.instance.materials.noinventory' }); return form; } - bodyText.rawtext.push({ text: `§cMaterials Missing From Inventory:` }); + bodyText.rawtext.push({ translate: 'construct.instance.materials.missing' }); if (instance.hasLayerSelected()) - bodyText.rawtext.push({ text: ` §7(layer ${instance.getLayer()})` }); + bodyText.rawtext.push({ translate: 'construct.instance.materials.layer', with: [String(instance.getLayer())] }); bodyText.rawtext.push({ text: `§f\n\n` }); bodyText.rawtext.push(materials.formatString(materials.getMaterialsDifference(inventoryContainer))); - buttonText = "Show All Materials"; + buttonText = "construct.instance.materials.all.button"; } else { - bodyText.rawtext.push({ text: `§aAll Materials:` }); + bodyText.rawtext.push({ translate: `construct.instance.materials.all` }); if (instance.hasLayerSelected()) - bodyText.rawtext.push({ text: ` §7(layer ${instance.getLayer()})` }); + bodyText.rawtext.push({ translate: 'construct.instance.materials.layer', with: [String(instance.getLayer())] }); bodyText.rawtext.push({ text: `§f\n\n` }); bodyText.rawtext.push(materials.formatString()); - buttonText = "Show Missing Materials"; + buttonText = "construct.instance.materials.missing.button"; } form.body(bodyText); - form.button(buttonText); + form.button({ translate: buttonText }); return form; } } \ No newline at end of file diff --git a/packs/RP/texts/en_US.lang b/packs/RP/texts/en_US.lang index d074c65..c06c26e 100644 --- a/packs/RP/texts/en_US.lang +++ b/packs/RP/texts/en_US.lang @@ -28,4 +28,19 @@ construct.menu.instance.nameEmpty=§cInstance name cannot be empty. construct.instance.flexibleMove.alreadyMoving=§cThis instance is already being moved. construct.instance.flexibleMove.start=§aNow moving "%s". Use the Construct item when finished. construct.instance.flexibleMove.finish=§aMoved "%1" to %2. -construct.instance.rename.error=§cError renaming instance: %s \ No newline at end of file +construct.instance.rename.error=§cError renaming instance: %s +construct.instance.validation.alreadyRunning=§cA verification is already in progress. Please wait until it finishes. +construct.instance.validation.formfail=§cFailed to build statistics form. +construct.instance.menu.body=Instance: §a%1\n§fStructure: §2%2 ## Shows the name of the instance and structure. +construct.instance.menu.location=§7(%1 %2 %3 in %4) ## Shows the location of the instance. +construct.isntance.menu.rename=Enter a new name for the instance: +construct.instance.option.validation=Block Validation +construct.instance.option.validation.description=Shows missing and incorrect block overlay. +construct.instance.option.layer=Layer +construct.instance.option.layer.description=Changes the active layer. Use 0 for all layers. +construct.instance.materials.noinventory=§cNo player inventory found. +construct.instance.materials.missing=`§cMaterials Missing From Inventory: +construct.instance.materials.missing.button=Show Missing Materials +construct.instance.materials.layer= §7(layer %s) ## Is added to the header when the instance is in layer mode. +construct.instance.materials.all=§aAll Materials: +construct.instance.materials.all.button=Show All Materials \ No newline at end of file