Skip to content

CommandUtils

youyihj edited this page Jan 24, 2022 · 4 revisions

CommandUtils

CommandUtils provide some static methods to help you to get player, entity that command acts on or notify command sender that he called command in wrong usage.

Importing the package

You'd better import the package to avoid errors and write script easier.

import mods.zenutils.command.CommandUtils;

Get player or entity

IPlayer getCommandSenderAsPlayer(ZenUtilsCommandSender sender);
IPlayer getPlayer(IServer server, ZenUtilsCommandSender sender, String target);
List<IPlayer> getPlayers(IServer server, ZenUtilsCommandSender sender, String target);
IEntity getEntity(IServer server, ZenUtilsCommandSender sender, String target);
List<IEntity> getEntityList(IServer server, ZenUtilsCommandSender sender, String target);
IItemDefinition getItemByText(ZenUtilsCommandSender sender, String id)
IBlockDefinition getBlockByText(ZenUtilsCommandSender sender, String id)

Notify Wrong Usage

The method throws WrongUsageException internally, so calling it will stop command from executing.

void notifyWrongUsage(String unlocalizedName);
void notifyWrongUsage(String unlocalizedName, String... replacements)
void notifyWrongUsage(ZenCommand command, ZenUtilsCommandSender sender); // call ZenCommand::getCommandUsage function internally
Clone this wiki locally