當前位置: 首頁>>代碼示例>>Java>>正文


Java ICommand.processCommand方法代碼示例

本文整理匯總了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);
}
 
開發者ID:wildex999,項目名稱:TickDynamic,代碼行數:31,代碼來源:CommandHandler.java

示例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;
}
 
開發者ID:alexandrage,項目名稱:CauldronGit,代碼行數:64,代碼來源:ClientCommandHandler.java

示例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;
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:64,代碼來源:ClientCommandHandler.java


注:本文中的net.minecraft.command.ICommand.processCommand方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。