feat(cli): add construct:verifier command
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
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 VerifierCommand extends Command {
|
||||
constructor() {
|
||||
super({
|
||||
name: 'verifier',
|
||||
description: 'construct.commands.verifier',
|
||||
mandatoryParameters: [
|
||||
{ name: 'instanceName', type: CustomCommandParamType.String },
|
||||
{ name: 'state', type: CustomCommandParamType.Boolean }
|
||||
],
|
||||
callback: (source, instanceName, state) => this.run(source, instanceName, state)
|
||||
});
|
||||
}
|
||||
|
||||
run(source, instanceName, state) {
|
||||
try {
|
||||
const instance = findInstance(source, instanceName);
|
||||
if (!instance) return { status: CustomCommandStatus.Failure };
|
||||
system.run(() => {
|
||||
instance.setVerifierEnabled(state);
|
||||
source.sendMessage({
|
||||
rawtext: [{ translate: 'construct.commands.verifier.success',
|
||||
with: [instanceName, String(state)] }]
|
||||
});
|
||||
});
|
||||
return { status: CustomCommandStatus.Success };
|
||||
} catch (err) {
|
||||
return commandError(source, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const verifierCommand = new VerifierCommand();
|
||||
@@ -21,6 +21,7 @@ import './commands/ActiveCommand';
|
||||
import './commands/LayerCommand';
|
||||
import './commands/NextLayerCommand';
|
||||
import './commands/PrevLayerCommand';
|
||||
import './commands/VerifierCommand';
|
||||
|
||||
// Other
|
||||
import './classes/BlockInfo';
|
||||
|
||||
Reference in New Issue
Block a user