当前位置: 首页>>代码示例>>Java>>正文


Java CommandException.getMessage方法代码示例

本文整理汇总了Java中net.minecraft.command.CommandException.getMessage方法的典型用法代码示例。如果您正苦于以下问题:Java CommandException.getMessage方法的具体用法?Java CommandException.getMessage怎么用?Java CommandException.getMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.command.CommandException的用法示例。


在下文中一共展示了CommandException.getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: func_175780_b

import net.minecraft.command.CommandException; //导入方法依赖的package包/类
private boolean func_175780_b(ICommandSender p_175780_1_, String[] p_175780_2_) throws CommandException
{
    int i = -1;

    for (int j = 0; j < p_175780_2_.length; ++j)
    {
        if (this.isUsernameIndex(p_175780_2_, j) && "*".equals(p_175780_2_[j]))
        {
            if (i >= 0)
            {
                throw new CommandException("commands.scoreboard.noMultiWildcard", new Object[0]);
            }

            i = j;
        }
    }

    if (i < 0)
    {
        return false;
    }
    else
    {
        List<String> list1 = Lists.newArrayList(this.getScoreboard().getObjectiveNames());
        String s = p_175780_2_[i];
        List<String> list = Lists.<String>newArrayList();

        for (String s1 : list1)
        {
            p_175780_2_[i] = s1;

            try
            {
                this.processCommand(p_175780_1_, p_175780_2_);
                list.add(s1);
            }
            catch (CommandException commandexception)
            {
                ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(commandexception.getMessage(), commandexception.getErrorObjects());
                chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
                p_175780_1_.addChatMessage(chatcomponenttranslation);
            }
        }

        p_175780_2_[i] = s;
        p_175780_1_.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, list.size());

        if (list.size() == 0)
        {
            throw new WrongUsageException("commands.scoreboard.allMatchesFailed", new Object[0]);
        }
        else
        {
            return true;
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:58,代码来源:CommandScoreboard.java

示例2: handleUserWildcards

import net.minecraft.command.CommandException; //导入方法依赖的package包/类
private boolean handleUserWildcards(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    int i = -1;

    for (int j = 0; j < args.length; ++j)
    {
        if (this.isUsernameIndex(args, j) && "*".equals(args[j]))
        {
            if (i >= 0)
            {
                throw new CommandException("commands.scoreboard.noMultiWildcard", new Object[0]);
            }

            i = j;
        }
    }

    if (i < 0)
    {
        return false;
    }
    else
    {
        List<String> list1 = Lists.newArrayList(this.getScoreboard(server).getObjectiveNames());
        String s = args[i];
        List<String> list = Lists.<String>newArrayList();

        for (String s1 : list1)
        {
            args[i] = s1;

            try
            {
                this.execute(server, sender, args);
                list.add(s1);
            }
            catch (CommandException commandexception)
            {
                TextComponentTranslation textcomponenttranslation = new TextComponentTranslation(commandexception.getMessage(), commandexception.getErrorObjects());
                textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
                sender.addChatMessage(textcomponenttranslation);
            }
        }

        args[i] = s;
        sender.setCommandStat(CommandResultStats.Type.AFFECTED_ENTITIES, list.size());

        if (list.isEmpty())
        {
            throw new WrongUsageException("commands.scoreboard.allMatchesFailed", new Object[0]);
        }
        else
        {
            return true;
        }
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:58,代码来源:CommandScoreboard.java


注:本文中的net.minecraft.command.CommandException.getMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。