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


Java ChatMessageComponent.createFromTranslationKey方法代码示例

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


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

示例1: processCommand

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    if (par2ArrayOfStr.length > 0)
    {
        EnumGameType enumgametype = this.getGameModeFromCommand(par1ICommandSender, par2ArrayOfStr[0]);
        EntityPlayerMP entityplayermp = par2ArrayOfStr.length >= 2 ? getPlayer(par1ICommandSender, par2ArrayOfStr[1]) : getCommandSenderAsPlayer(par1ICommandSender);
        entityplayermp.setGameType(enumgametype);
        entityplayermp.fallDistance = 0.0F;
        ChatMessageComponent chatmessagecomponent = ChatMessageComponent.createFromTranslationKey("gameMode." + enumgametype.getName());

        if (entityplayermp != par1ICommandSender)
        {
            notifyAdmins(par1ICommandSender, 1, "commands.gamemode.success.other", new Object[] {entityplayermp.getEntityName(), chatmessagecomponent});
        }
        else
        {
            notifyAdmins(par1ICommandSender, 1, "commands.gamemode.success.self", new Object[] {chatmessagecomponent});
        }
    }
    else
    {
        throw new WrongUsageException("commands.gamemode.usage", new Object[0]);
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:25,代码来源:CommandGameMode.java

示例2: format

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
private ChatMessageComponent format(String str)
{
    return ChatMessageComponent.createFromTranslationKey(str);
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:5,代码来源:ClientCommandHandler.java

示例3: processCommand

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
public void processCommand(ICommandSender par1ICommandSender, String[] par2ArrayOfStr)
{
    if (par2ArrayOfStr.length < 2)
    {
        throw new WrongUsageException("commands.effect.usage", new Object[0]);
    }
    else
    {
        EntityPlayerMP entityplayermp = getPlayer(par1ICommandSender, par2ArrayOfStr[0]);

        if (par2ArrayOfStr[1].equals("clear"))
        {
            if (entityplayermp.getActivePotionEffects().isEmpty())
            {
                throw new CommandException("commands.effect.failure.notActive.all", new Object[] {entityplayermp.getEntityName()});
            }

            entityplayermp.clearActivePotions();
            notifyAdmins(par1ICommandSender, "commands.effect.success.removed.all", new Object[] {entityplayermp.getEntityName()});
        }
        else
        {
            int i = parseIntWithMin(par1ICommandSender, par2ArrayOfStr[1], 1);
            int j = 600;
            int k = 30;
            int l = 0;

            if (i < 0 || i >= Potion.potionTypes.length || Potion.potionTypes[i] == null)
            {
                throw new NumberInvalidException("commands.effect.notFound", new Object[] {Integer.valueOf(i)});
            }

            if (par2ArrayOfStr.length >= 3)
            {
                k = parseIntBounded(par1ICommandSender, par2ArrayOfStr[2], 0, 1000000);

                if (Potion.potionTypes[i].isInstant())
                {
                    j = k;
                }
                else
                {
                    j = k * 20;
                }
            }
            else if (Potion.potionTypes[i].isInstant())
            {
                j = 1;
            }

            if (par2ArrayOfStr.length >= 4)
            {
                l = parseIntBounded(par1ICommandSender, par2ArrayOfStr[3], 0, 255);
            }

            if (k == 0)
            {
                if (!entityplayermp.isPotionActive(i))
                {
                    throw new CommandException("commands.effect.failure.notActive", new Object[] {ChatMessageComponent.createFromTranslationKey(Potion.potionTypes[i].getName()), entityplayermp.getEntityName()});
                }

                entityplayermp.removePotionEffect(i);
                notifyAdmins(par1ICommandSender, "commands.effect.success.removed", new Object[] {ChatMessageComponent.createFromTranslationKey(Potion.potionTypes[i].getName()), entityplayermp.getEntityName()});
            }
            else
            {
                PotionEffect potioneffect = new PotionEffect(i, j, l);
                entityplayermp.addPotionEffect(potioneffect);
                notifyAdmins(par1ICommandSender, "commands.effect.success", new Object[] {ChatMessageComponent.createFromTranslationKey(potioneffect.getEffectName()), Integer.valueOf(i), Integer.valueOf(l), entityplayermp.getEntityName(), Integer.valueOf(k)});
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:75,代码来源:CommandEffect.java


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