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/ActiveCommand';
|
||||||
import './commands/LayerCommand';
|
import './commands/LayerCommand';
|
||||||
import './commands/NextLayerCommand';
|
import './commands/NextLayerCommand';
|
||||||
|
import './commands/PrevLayerCommand';
|
||||||
|
|
||||||
// Other
|
// Other
|
||||||
import './classes/BlockInfo';
|
import './classes/BlockInfo';
|
||||||
|
|||||||
@@ -154,3 +154,7 @@ construct.commands.layer.outOfBounds=§cLayer %1 is out of bounds for instance "
|
|||||||
## construct:nextlayer
|
## construct:nextlayer
|
||||||
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
|
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
|
||||||
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.
|
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.
|
||||||
|
|
||||||
|
## construct:prevlayer
|
||||||
|
construct.commands.prevlayer=Step layer down by one (wraps 0 to max).
|
||||||
|
construct.commands.prevlayer.success=§aInstance "%1" stepped back to layer %2.
|
||||||
|
|||||||
@@ -154,3 +154,7 @@ construct.commands.layer.outOfBounds=§cLayer %1 is out of bounds for instance "
|
|||||||
## construct:nextlayer
|
## construct:nextlayer
|
||||||
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
|
construct.commands.nextlayer=Step layer up by one (wraps max to 0).
|
||||||
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.
|
construct.commands.nextlayer.success=§aInstance "%1" advanced to layer %2.
|
||||||
|
|
||||||
|
## construct:prevlayer
|
||||||
|
construct.commands.prevlayer=Step layer down by one (wraps 0 to max).
|
||||||
|
construct.commands.prevlayer.success=§aInstance "%1" stepped back to layer %2.
|
||||||
|
|||||||
Reference in New Issue
Block a user