feat(cli): add construct:delete command

This commit is contained in:
ForestOfLight
2026-05-19 21:30:49 -07:00
Unverified
parent 50ed8c3e02
commit c682d7a199
4 changed files with 45 additions and 0 deletions
@@ -0,0 +1,36 @@
import { CustomCommandParamType, CustomCommandStatus, system } from '@minecraft/server';
import { Command } from '../classes/Commands/Command';
import { structureCollection } from '../classes/Structure/StructureCollection';
import { findInstance } from '../classes/Commands/lib/findInstance';
import { commandError } from '../classes/Commands/lib/commandError';
export class DeleteCommand extends Command {
constructor() {
super({
name: 'delete',
description: 'construct.commands.delete',
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 };
system.run(() => {
structureCollection.delete(instanceName);
source.sendMessage({
rawtext: [{ translate: 'construct.commands.delete.success', with: [instanceName] }]
});
});
return { status: CustomCommandStatus.Success };
} catch (err) {
return commandError(source, err);
}
}
}
export const deleteCommand = new DeleteCommand();
+1
View File
@@ -12,6 +12,7 @@ import './classes/MenuItemHandler';
// Commands
import './commands/ConstructCommand';
import './commands/NewCommand';
import './commands/DeleteCommand';
// Other
import './classes/BlockInfo';
+4
View File
@@ -116,3 +116,7 @@ construct.commands.new=Create a new instance bound to a structure.
construct.commands.new.success=§aCreated instance "%1" bound to structure "%2".
construct.commands.new.duplicateName=§cAn instance named "%1" already exists.
construct.commands.new.unknownStructure=§cNo structure with id "%1" found in the world.
## construct:delete
construct.commands.delete=Permanently delete an instance.
construct.commands.delete.success=§aDeleted instance "%1".
+4
View File
@@ -116,3 +116,7 @@ construct.commands.new=Create a new instance bound to a structure.
construct.commands.new.success=§aCreated instance "%1" bound to structure "%2".
construct.commands.new.duplicateName=§cAn instance named "%1" already exists.
construct.commands.new.unknownStructure=§cNo structure with id "%1" found in the world.
## construct:delete
construct.commands.delete=Permanently delete an instance.
construct.commands.delete.success=§aDeleted instance "%1".