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


Java MinecraftServer.addChatMessage方法代码示例

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


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

示例1: notifyOperators

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Send an informative message to the server operators
 */
public void notifyOperators(ICommandSender sender, ICommand command, int flags, String msgFormat, Object... msgParams)
{
    boolean flag = true;
    MinecraftServer minecraftserver = MinecraftServer.getServer();

    if (!sender.sendCommandFeedback())
    {
        flag = false;
    }

    IChatComponent ichatcomponent = new ChatComponentTranslation("chat.type.admin", new Object[] {sender.getName(), new ChatComponentTranslation(msgFormat, msgParams)});
    ichatcomponent.getChatStyle().setColor(EnumChatFormatting.GRAY);
    ichatcomponent.getChatStyle().setItalic(Boolean.valueOf(true));

    if (flag)
    {
        for (EntityPlayer entityplayer : minecraftserver.getConfigurationManager().func_181057_v())
        {
            if (entityplayer != sender && minecraftserver.getConfigurationManager().canSendCommands(entityplayer.getGameProfile()) && command.canCommandSenderUseCommand(sender))
            {
                boolean flag1 = sender instanceof MinecraftServer && MinecraftServer.getServer().func_183002_r();
                boolean flag2 = sender instanceof RConConsoleSource && MinecraftServer.getServer().func_181034_q();

                if (flag1 || flag2 || !(sender instanceof RConConsoleSource) && !(sender instanceof MinecraftServer))
                {
                    entityplayer.addChatMessage(ichatcomponent);
                }
            }
        }
    }

    if (sender != minecraftserver && minecraftserver.worldServers[0].getGameRules().getBoolean("logAdminCommands"))
    {
        minecraftserver.addChatMessage(ichatcomponent);
    }

    boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");

    if (sender instanceof CommandBlockLogic)
    {
        flag3 = ((CommandBlockLogic)sender).shouldTrackOutput();
    }

    if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer)
    {
        sender.addChatMessage(new ChatComponentTranslation(msgFormat, msgParams));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:52,代码来源:ServerCommandManager.java

示例2: notifyListener

import net.minecraft.server.MinecraftServer; //导入方法依赖的package包/类
/**
 * Send an informative message to the server operators
 */
public void notifyListener(ICommandSender sender, ICommand command, int flags, String translationKey, Object... translationArgs)
{
    boolean flag = true;
    MinecraftServer minecraftserver = this.server;

    if (!sender.sendCommandFeedback())
    {
        flag = false;
    }

    ITextComponent itextcomponent = new TextComponentTranslation("chat.type.admin", new Object[] {sender.getName(), new TextComponentTranslation(translationKey, translationArgs)});
    itextcomponent.getStyle().setColor(TextFormatting.GRAY);
    itextcomponent.getStyle().setItalic(Boolean.valueOf(true));

    if (flag)
    {
        for (EntityPlayer entityplayer : minecraftserver.getPlayerList().getPlayerList())
        {
            if (entityplayer != sender && minecraftserver.getPlayerList().canSendCommands(entityplayer.getGameProfile()) && command.checkPermission(this.server, sender))
            {
                boolean flag1 = sender instanceof MinecraftServer && this.server.shouldBroadcastConsoleToOps();
                boolean flag2 = sender instanceof RConConsoleSource && this.server.shouldBroadcastRconToOps();

                if (flag1 || flag2 || !(sender instanceof RConConsoleSource) && !(sender instanceof MinecraftServer))
                {
                    entityplayer.addChatMessage(itextcomponent);
                }
            }
        }
    }

    if (sender != minecraftserver && minecraftserver.worldServers[0].getGameRules().getBoolean("logAdminCommands"))
    {
        minecraftserver.addChatMessage(itextcomponent);
    }

    boolean flag3 = minecraftserver.worldServers[0].getGameRules().getBoolean("sendCommandFeedback");

    if (sender instanceof CommandBlockBaseLogic)
    {
        flag3 = ((CommandBlockBaseLogic)sender).shouldTrackOutput();
    }

    if ((flags & 1) != 1 && flag3 || sender instanceof MinecraftServer)
    {
        sender.addChatMessage(new TextComponentTranslation(translationKey, translationArgs));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:52,代码来源:ServerCommandManager.java


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