feat(cli): add construct:prevlayer command
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
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 PrevLayerCommand extends Command {
|
||||
constructor() {
|
||||
super({
|
||||
name: 'prevlayer',
|
||||
description: 'construct.commands.prevlayer',
|
||||
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(() => {
|
||||
instance.decreaseLayer();
|
||||
source.sendMessage({
|
||||
rawtext: [{ translate: 'construct.commands.prevlayer.success',
|
||||
with: [instanceName, String(instance.getLayer())] }]
|
||||
});
|
||||
});
|
||||
return { status: CustomCommandStatus.Success };
|
||||
} catch (err) {
|
||||
return commandError(source, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const prevLayerCommand = new PrevLayerCommand();
|
||||
@@ -20,6 +20,7 @@ import './commands/MoveCommand';
|
||||
import './commands/ActiveCommand';
|
||||
import './commands/LayerCommand';
|
||||
import './commands/NextLayerCommand';
|
||||
import './commands/PrevLayerCommand';
|
||||
|
||||
// Other
|
||||
import './classes/BlockInfo';
|
||||
|
||||
Reference in New Issue
Block a user