-
Notifications
You must be signed in to change notification settings - Fork 10
IGetTabCompletion
youyihj edited this page Dec 7, 2020
·
4 revisions
IGetTabCompletion function is used to get command's tab completion.
It might be required for you to import the package if you encounter any issues (like casting an Array), so better be safe than sorry and add the import.
import mods.zenutils.command.IGetTabCompletion;
The IGetTabCompletion function is a function with the following parameters (in this order):
- IServer server: the server where the command is executed.
- ZenUtilsCommandSender sender: the sender that executes the command.
- @Nullable IBlockPos pos: the target position.
The function should return a StringList.
These below are pre-registered IGetTabCompletions by zenutils. You can call these method to get them. For example: IGetTabCompletion.item()
.
- empty: Empty List
- item: All items in the game
- block: All blocks in the game
- player: All online players in the server
- potion: All potions in the game
- x: the target position's X coordinate
- y: the target position's Y coordinate
- z: the target position's Z coordinate
The example script needs GameStage to run.
import mods.zenutils.command.ZenCommand;
import mods.zenutils.command.CommandUtils;
import mods.zenutils.command.IGetTabCompletion;
import mods.zenutils.StringList;
val stageGetter as IGetTabCompletion = function(server, sender, pos) {
return StringList.create([
"one",
"two",
"three",
"four",
"five",
"six",
"alpha",
"beta"
]);
};
val addGameStage as ZenCommand = ZenCommand.create("addstage");
addGameStage.getCommandUsage = function(sender) {
return "commands.addstage.usage";
};
addGameStage.requiredPermissionLevel = 3;
addGameStage.tabCompletionGetters = [IGetTabCompletion.player(), stageGetter];
addGameStage.execute = function(command, server, sender, args) {
if (args.length == 2) {
CommandUtils.getPlayer(server, sender, args[0]).addGameStage(args[1]);
} else {
CommandUtils.notifyWrongUsage(command, sender);
}
}
addGameStage.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