本文整理汇总了Java中net.minecraft.command.ICommand.processCommand方法的典型用法代码示例。如果您正苦于以下问题:Java ICommand.processCommand方法的具体用法?Java ICommand.processCommand怎么用?Java ICommand.processCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.command.ICommand
的用法示例。
在下文中一共展示了ICommand.processCommand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processCommand
import net.minecraft.command.ICommand; //导入方法依赖的package包/类
@Override
public void processCommand(ICommandSender sender, String[] args) {
if(args.length == 0)
{
sender.addChatMessage(new ChatComponentText("Usage: " + getCommandUsage(sender)));
return;
}
if(args[0].equals("tps"))
{
sender.addChatMessage(new ChatComponentText("Average TPS: " + getTPSFormatted(mod) + " TPS"));
return;
} else if(args[0].equals("identify")) {
sender.addChatMessage(new ChatComponentText("Command not yet implemented! This will allow you to check what group a Tile or Entity belongs to by right clicking it.(And other info, like TPS)"));
return;
} else if(args[0].equals("help")) {
sender.addChatMessage(new ChatComponentText("You can find the documentation over at http://mods.stjerncraft.com/tickdynamic"));
return;
}
//Send it over to subCommand handler
ICommand subHandler = subCommandHandlers.get(args[0]);
if(subHandler == null)
{
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.RED + "No handler for the command " + EnumChatFormatting.ITALIC + args[0]));
return;
}
subHandler.processCommand(sender, args);
}
示例2: executeCommand
import net.minecraft.command.ICommand; //导入方法依赖的package包/类
/**
* @return 1 if successfully executed, 0 if wrong usage, it doesn't exist or
* it was canceled.
*/
@Override
public int executeCommand(ICommandSender sender, String message)
{
message = message.trim();
if (message.startsWith("/"))
{
message = message.substring(1);
}
String[] temp = message.split(" ");
String[] args = new String[temp.length - 1];
String commandName = temp[0];
System.arraycopy(temp, 1, args, 0, args.length);
ICommand icommand = (ICommand) getCommands().get(commandName);
try
{
if (icommand == null)
{
return 0;
}
if (icommand.canCommandSenderUseCommand(sender))
{
CommandEvent event = new CommandEvent(icommand, sender, args);
if (MinecraftForge.EVENT_BUS.post(event))
{
if (event.exception != null)
{
throw event.exception;
}
return 0;
}
icommand.processCommand(sender, args);
return 1;
}
else
{
sender.addChatMessage(format(RED, "commands.generic.permission"));
}
}
catch (WrongUsageException wue)
{
sender.addChatMessage(format(RED, "commands.generic.usage", format(RED, wue.getMessage(), wue.getErrorOjbects())));
}
catch (CommandException ce)
{
sender.addChatMessage(format(RED, ce.getMessage(), ce.getErrorOjbects()));
}
catch (Throwable t)
{
sender.addChatMessage(format(RED, "commands.generic.exception"));
t.printStackTrace();
}
return 0;
}
示例3: executeCommand
import net.minecraft.command.ICommand; //导入方法依赖的package包/类
/**
* @return 1 if successfully executed, 0 if wrong usage, it doesn't exist or
* it was canceled.
*/
@Override
public int executeCommand(ICommandSender sender, String message)
{
message = message.trim();
if (message.startsWith("/"))
{
message = message.substring(1);
}
String[] temp = message.split(" ");
String[] args = new String[temp.length - 1];
String commandName = temp[0];
System.arraycopy(temp, 1, args, 0, args.length);
ICommand icommand = (ICommand) getCommands().get(commandName);
try
{
if (icommand == null)
{
return 0;
}
if (icommand.canCommandSenderUseCommand(sender))
{
CommandEvent event = new CommandEvent(icommand, sender, args);
if (MinecraftForge.EVENT_BUS.post(event))
{
if (event.exception != null)
{
throw event.exception;
}
return 0;
}
icommand.processCommand(sender, args);
return 1;
}
else
{
sender.sendChatToPlayer(format("commands.generic.permission").setColor(RED));
}
}
catch (WrongUsageException wue)
{
sender.sendChatToPlayer(format("commands.generic.usage", format(wue.getMessage(), wue.getErrorOjbects())).setColor(RED));
}
catch (CommandException ce)
{
sender.sendChatToPlayer(format(ce.getMessage(), ce.getErrorOjbects()).setColor(RED));
}
catch (Throwable t)
{
sender.sendChatToPlayer(format("commands.generic.exception").setColor(RED));
t.printStackTrace();
}
return 0;
}