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


Java ChatMessageComponent.createFromTranslationWithSubstitutions方法代码示例

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


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

示例1: getDeathMessage

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
/**
 * Returns the message to be displayed on player death.
 */
@Override
public ChatMessageComponent getDeathMessage(EntityLivingBase hurtEnemy)
{
    String throwername = this.thrower == null ? this.damageSourceEntity.getTranslatedEntityName() : this.thrower.getTranslatedEntityName();
    ItemStack itemstack = this.thrower instanceof EntityLivingBase ? ((EntityLivingBase)this.thrower).getHeldItem() : null;
    String damageType = "death.attack.bomb";
    
    String src = "";
    if(thrower != null && thrower != getSourceOfDamage())
    {
    	if(thrower == hurtEnemy)
    	{
    		src = ".suicide";
    	}
    	else
    	{
    		src = ".thrown";
    	}
    }
    String s2 = damageType + src;
    return  ChatMessageComponent.createFromTranslationWithSubstitutions(s2, new Object[] {hurtEnemy.getTranslatedEntityName(), throwername});
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:26,代码来源:EntityDamageSourceBomb.java

示例2: getDeathMessage

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
@Override
public ChatMessageComponent getDeathMessage(EntityLivingBase entity)
{
    ItemStack itemstack = this.damageSourceEntity instanceof EntityLivingBase ? ((EntityLivingBase)this.damageSourceEntity).getHeldItem() : null;
    String s = "death.attack." + this.damageType;
    String s1 = s + ".item";
    return itemstack != null && itemstack.hasDisplayName() && StatCollector.func_94522_b(s1) ? ChatMessageComponent.createFromTranslationWithSubstitutions(s1, new Object[] {entity.getTranslatedEntityName(), this.damageSourceEntity.getTranslatedEntityName(), itemstack.getDisplayName()}): ChatMessageComponent.createFromTranslationWithSubstitutions(s, new Object[] {entity.getTranslatedEntityName(), this.damageSourceEntity.getTranslatedEntityName()});
}
 
开发者ID:TheAwesomeGem,项目名称:MineFantasy,代码行数:9,代码来源:DamageSourceWeaponBonus.java

示例3: notifyAdmins

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
/**
 * Sends a message to the admins of the server from a given CommandSender with the given resource string and given
 * extra srings. If the int par2 is even or zero, the original sender is also notified.
 */
public void notifyAdmins(ICommandSender par1ICommandSender, int par2, String par3Str, Object ... par4ArrayOfObj)
{
    boolean flag = true;

    if (par1ICommandSender instanceof TileEntityCommandBlock && !MinecraftServer.getServer().worldServers[0].getGameRules().getGameRuleBooleanValue("commandBlockOutput"))
    {
        flag = false;
    }

    ChatMessageComponent chatmessagecomponent = ChatMessageComponent.createFromTranslationWithSubstitutions("chat.type.admin", new Object[] {par1ICommandSender.getCommandSenderName(), ChatMessageComponent.createFromTranslationWithSubstitutions(par3Str, par4ArrayOfObj)});
    chatmessagecomponent.setColor(EnumChatFormatting.GRAY);
    chatmessagecomponent.setItalic(Boolean.valueOf(true));

    if (flag)
    {
        Iterator iterator = MinecraftServer.getServer().getConfigurationManager().playerEntityList.iterator();

        while (iterator.hasNext())
        {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)iterator.next();

            if (entityplayermp != par1ICommandSender && MinecraftServer.getServer().getConfigurationManager().isPlayerOpped(entityplayermp.getCommandSenderName()))
            {
                entityplayermp.sendChatToPlayer(chatmessagecomponent);
            }
        }
    }

    if (par1ICommandSender != MinecraftServer.getServer())
    {
        MinecraftServer.getServer().sendChatToPlayer(chatmessagecomponent);
    }

    if ((par2 & 1) != 1)
    {
        par1ICommandSender.sendChatToPlayer(ChatMessageComponent.createFromTranslationWithSubstitutions(par3Str, par4ArrayOfObj));
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:43,代码来源:ServerCommandManager.java

示例4: format

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

示例5: handleChat

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
public void handleChat(Packet3Chat par1Packet3Chat)
{
    par1Packet3Chat = FMLNetworkHandler.handleChatMessage(this, par1Packet3Chat);

    if (par1Packet3Chat == null || par1Packet3Chat.message == null)
    {
        return;
    }
    if (this.playerEntity.getChatVisibility() == 2)
    {
        this.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromTranslationKey("chat.cannotSend").setColor(EnumChatFormatting.RED)));
    }
    else
    {
        this.playerEntity.func_143004_u();
        String s = par1Packet3Chat.message;

        if (s.length() > 100)
        {
            this.kickPlayerFromServer("Chat message too long");
        }
        else
        {
            for (int i = 0; i < s.length(); ++i)
            {
                if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
                {
                    this.kickPlayerFromServer("Illegal characters in chat");
                    return;
                }
            }

            if (s.startsWith("/"))
            {
                this.handleSlashCommand(s);
            }
            else
            {
                if (this.playerEntity.getChatVisibility() == 1)
                {
                    this.sendPacketToPlayer(new Packet3Chat(ChatMessageComponent.createFromTranslationKey("chat.cannotSend").setColor(EnumChatFormatting.RED)));
                    return;
                }

                ChatMessageComponent chatmessagecomponent = ChatMessageComponent.createFromTranslationWithSubstitutions("chat.type.text", new Object[] {this.playerEntity.getTranslatedEntityName(), s});
                chatmessagecomponent = ForgeHooks.onServerChatEvent(this, s, chatmessagecomponent);
                if (chatmessagecomponent == null) return;
                this.mcServer.getConfigurationManager().func_110459_a(chatmessagecomponent, false);
            }

            this.chatSpamThresholdCount += 20;

            if (this.chatSpamThresholdCount > 200 && !this.mcServer.getConfigurationManager().isPlayerOpped(this.playerEntity.getCommandSenderName()))
            {
                this.kickPlayerFromServer("disconnect.spam");
            }
        }
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:60,代码来源:NetServerHandler.java

示例6: actionPerformed

import net.minecraft.util.ChatMessageComponent; //导入方法依赖的package包/类
/**
 * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
 */
protected void actionPerformed(GuiButton par1GuiButton)
{
    if (par1GuiButton.id == 102)
    {
        this.mc.displayGuiScreen(this.parentScreen);
    }
    else if (par1GuiButton.id == 104)
    {
        if (this.gameMode.equals("survival"))
        {
            this.gameMode = "creative";
        }
        else if (this.gameMode.equals("creative"))
        {
            this.gameMode = "adventure";
        }
        else
        {
            this.gameMode = "survival";
        }

        this.func_74088_g();
    }
    else if (par1GuiButton.id == 103)
    {
        this.allowCommands = !this.allowCommands;
        this.func_74088_g();
    }
    else if (par1GuiButton.id == 101)
    {
        this.mc.displayGuiScreen((GuiScreen)null);
        String s = this.mc.getIntegratedServer().shareToLAN(EnumGameType.getByName(this.gameMode), this.allowCommands);
        ChatMessageComponent chatmessagecomponent;

        if (s != null)
        {
            chatmessagecomponent = ChatMessageComponent.createFromTranslationWithSubstitutions("commands.publish.started", new Object[] {s});
        }
        else
        {
            chatmessagecomponent = ChatMessageComponent.createFromText("commands.publish.failed");
        }

        this.mc.ingameGUI.getChatGUI().printChatMessage(chatmessagecomponent.toStringWithFormatting(true));
    }
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:50,代码来源:GuiShareToLan.java


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