-
Notifications
You must be signed in to change notification settings - Fork 10
ZenCommandTree
youyihj edited this page Nov 12, 2020
·
3 revisions
This is command tree.
It might be required to import the class to avoid errors.
import mods.zenutils.command.ZenCommandTree;
Before you can add command tree, you need to create a ZenCommandTree instance, and set some properities of the command tree you want to add.
// Return a new ZenCommand instance
ZenCommandTree.create(String name, ZenCommand... subCommands);
You can use name
ZenGetter to get the name of ZenCommandTree.
name | type | default value | required |
---|---|---|---|
requiredPermissionLevel | int | 0 | No |
You need to call register
method to register it, otherwise nothing will happen!
import mods.zenutils.command.ZenCommand;
import mods.zenutils.command.CommandUtils;
import mods.zenutils.command.IGetTabCompletion;
import mods.zenutils.command.ZenCommandTree;
val statusMessage as ZenCommand = ZenCommand.create("statusmessage");
statusMessage.getCommandUsage = function(sender) {
return "commands.statusmessage.usage";
};
statusMessage.requiredPermissionLevel = 2;
statusMessage.tabCompletionGetters = [IGetTabCompletion.player()];
statusMessage.execute = function(command, server, sender, args) {
if (args.length == 1) {
CommandUtils.getCommandSenderAsPlayer(sender).sendStatusMessage(args[0], true);
} else if (args.length == 2) {
CommandUtils.getPlayer(server, sender, args[0]).sendStatusMessage(args[1], true);
} else {
CommandUtils.notifyWrongUsage(command, sender);
}
};
val helloWorld as ZenCommand = ZenCommand.create("helloworld");
helloWorld.getCommandUsage = function(sender) {
return "commands.helloworld.usage";
}
helloWorld.requiredPermissionLevel = 0;
helloWorld.execute = function(command, server, sender, args) {
sender.sendMessage("hello, world!");
};
ZenCommandTree.create("zenutils", statusMessage, helloWorld).register();
- GlobalFunctions
- ScriptReloading
- SuppressErrorPreprocessor
- HardFailPreprocessor
- OrderlyMap
- IData Deep Update
- Template String
- Native Method Access
- Mixin
- CrTI18n
- CrTUUID
- CrTItemHandler
- CrTLiquidHandler
- ILiquidTankProperties
- StringList
- HexHelper
- StaticString
- Catenation
- PersistedCatenation
- PlayerStat
- IStatFormatter
- GameRuleHelper
- ZenCommand
- ZenCommandTree
- ZenUtilsCommandSender
- IGetCommandUsage
- ICommandExecute
- IGetTabCompletion
- CommandUtils