From b22c3e971bbeb7e8e26fd8bb0a537795f552a83a Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Wed, 20 May 2026 03:01:14 -0700 Subject: [PATCH] feat(cli): add construct:info command --- packs/BP/scripts/commands/InfoCommand.js | 57 ++++++++++++++++++++++++ packs/BP/scripts/main.js | 1 + packs/RP/texts/en_US.lang | 11 +++++ packs/RP/texts/zh_CN.lang | 11 +++++ 4 files changed, 80 insertions(+) create mode 100644 packs/BP/scripts/commands/InfoCommand.js diff --git a/packs/BP/scripts/commands/InfoCommand.js b/packs/BP/scripts/commands/InfoCommand.js new file mode 100644 index 0000000..155aa4f --- /dev/null +++ b/packs/BP/scripts/commands/InfoCommand.js @@ -0,0 +1,57 @@ +import { CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server'; +import { Command } from '../classes/Commands/Command'; +import { findInstance } from '../classes/Commands/lib/findInstance'; +import { commandError } from '../classes/Commands/lib/commandError'; + +export class InfoCommand extends Command { + constructor() { + super({ + name: 'info', + description: 'construct.commands.info', + mandatoryParameters: [ + { name: 'instanceName', type: CustomCommandParamType.String } + ], + callback: (source, instanceName) => this.run(source, instanceName) + }); + } + + run(source, instanceName) { + try { + const instance = findInstance(source, instanceName); + if (!instance) return { status: CustomCommandStatus.Failure }; + const rawtext = [ + { translate: 'construct.commands.info.header', with: [instance.getName()] }, + { text: '\n' }, + { translate: 'construct.commands.info.structure', with: [instance.getStructureId()] }, + { text: '\n' }, + { translate: 'construct.commands.info.enabled', with: [String(instance.isEnabled())] }, + { text: '\n' } + ]; + if (instance.hasLocation()) { + const { dimensionId, location } = instance.getLocation(); + rawtext.push({ translate: 'construct.commands.info.location', + with: [String(location.x), String(location.y), String(location.z), + dimensionId.replace('minecraft:', '')] }); + } else { + rawtext.push({ translate: 'construct.commands.info.noLocation' }); + } + rawtext.push({ text: '\n' }); + rawtext.push({ translate: 'construct.commands.info.layer', + with: [String(instance.getLayer()), String(instance.getMaxLayer())] }); + rawtext.push({ text: '\n' }); + rawtext.push({ translate: 'construct.commands.info.verifier', + with: [String(instance.options.verifier.isEnabled)] }); + rawtext.push({ text: '\n' }); + const bounds = instance.getBounds(); + rawtext.push({ translate: 'construct.commands.info.bounds', + with: [String(bounds.min.x), String(bounds.min.y), String(bounds.min.z), + String(bounds.max.x), String(bounds.max.y), String(bounds.max.z)] }); + system.run(() => source.sendMessage({ rawtext })); + return { status: CustomCommandStatus.Success }; + } catch (err) { + return commandError(source, err); + } + } +} + +export const infoCommand = new InfoCommand(); diff --git a/packs/BP/scripts/main.js b/packs/BP/scripts/main.js index d3dfad0..3c97ef5 100644 --- a/packs/BP/scripts/main.js +++ b/packs/BP/scripts/main.js @@ -23,6 +23,7 @@ import './commands/NextLayerCommand'; import './commands/PrevLayerCommand'; import './commands/VerifierCommand'; import './commands/OptionCommand'; +import './commands/InfoCommand'; // Other import './classes/BlockInfo'; diff --git a/packs/RP/texts/en_US.lang b/packs/RP/texts/en_US.lang index 12f4d0a..44f8892 100644 --- a/packs/RP/texts/en_US.lang +++ b/packs/RP/texts/en_US.lang @@ -167,3 +167,14 @@ construct.commands.verifier.success=§aSet instance "%1" verifier=%2. construct.commands.option=Toggle a per-player builder option. construct.commands.option.success=§aSet option "%1" = %2. construct.commands.option.unknownOption=§cUnknown option "%1". + +## construct:info +construct.commands.info=Print instance details to chat. +construct.commands.info.header=§e=== Instance "%1" ===§r +construct.commands.info.structure=§7Structure:§r %1 +construct.commands.info.enabled=§7Enabled:§r %1 +construct.commands.info.location=§7Location:§r %1 %2 %3 in %4 +construct.commands.info.noLocation=§7Location:§r (none) +construct.commands.info.layer=§7Layer:§r %1 / %2 +construct.commands.info.verifier=§7Verifier:§r %1 +construct.commands.info.bounds=§7Bounds:§r (%1, %2, %3) -> (%4, %5, %6) diff --git a/packs/RP/texts/zh_CN.lang b/packs/RP/texts/zh_CN.lang index ed3e58e..b752943 100644 --- a/packs/RP/texts/zh_CN.lang +++ b/packs/RP/texts/zh_CN.lang @@ -167,3 +167,14 @@ construct.commands.verifier.success=§aSet instance "%1" verifier=%2. construct.commands.option=Toggle a per-player builder option. construct.commands.option.success=§aSet option "%1" = %2. construct.commands.option.unknownOption=§cUnknown option "%1". + +## construct:info +construct.commands.info=Print instance details to chat. +construct.commands.info.header=§e=== Instance "%1" ===§r +construct.commands.info.structure=§7Structure:§r %1 +construct.commands.info.enabled=§7Enabled:§r %1 +construct.commands.info.location=§7Location:§r %1 %2 %3 in %4 +construct.commands.info.noLocation=§7Location:§r (none) +construct.commands.info.layer=§7Layer:§r %1 / %2 +construct.commands.info.verifier=§7Verifier:§r %1 +construct.commands.info.bounds=§7Bounds:§r (%1, %2, %3) -> (%4, %5, %6)