Java 类net.minecraft.network.play.server.SPacketChat 实例源码

项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
    if (message == null) return;

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(message, false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(message);
    }
}
项目:morecommands    文件:ChatChannel.java   
/**
 * Sends a chat message to this channel and, if a child wants to
 * receive messages from its parent, also to all child channels.
 * 
 * @param message the message
 * @param msgType the message type
 */
public void sendChatMessage(ITextComponent message, ChatType msgType) {
    checkState();
    ITextComponent msgToSend = message;

    if (MoreCommandsConfig.prefixChannelName)
        msgToSend = new TextComponentString("[" + this.getName() + "] ").appendSibling(message);

    SPacketChat packet = new SPacketChat(msgToSend, msgType);

    for (EntityPlayerMP player : this.members)
        player.connection.sendPacket(packet);

    for (ChatChannel child : this.children)
        if (child.receiveParentMessages)
            child.sendChatMessage(message, msgType);
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    net.minecraft.util.text.ITextComponent message = net.minecraftforge.event.ForgeEventFactory.onClientChat(packetIn.getType(), packetIn.getChatComponent());
    if (message == null) return;

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(message, false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(message);
    }
}
项目:Zombe-Modpack    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation, (byte)2));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
项目:Zombe-Modpack    文件:NetHandlerPlayServer.java   
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN && spacketchat.getType() != 2)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
    }
}
项目:Backmemed    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < 64.0D && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation, (byte)2));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
}
项目:Backmemed    文件:NetHandlerPlayServer.java   
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN && spacketchat.getType() != 2)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
public void handleChat(SPacketChat packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.getType() == 2)
    {
        this.gameController.ingameGUI.setRecordPlaying(packetIn.getChatComponent(), false);
    }
    else
    {
        this.gameController.ingameGUI.getChatGUI().printChatMessage(packetIn.getChatComponent());
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        double dist = playerEntity.interactionManager.getBlockReachDistance() + 3;
        dist *= dist;
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    itemstack = this.playerEntity.getHeldItem(enumhand);

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.setHeldItem(enumhand, (ItemStack)null);
        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.playerEntity, itemstack, enumhand);
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayServer.java   
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
项目:ExpandedRailsMod    文件:NetHandlerPlayServer.java   
public void processRightClickBlock(CPacketPlayerTryUseItemOnBlock packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());
    WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
    EnumHand enumhand = packetIn.getHand();
    ItemStack itemstack = this.playerEntity.getHeldItem(enumhand);
    BlockPos blockpos = packetIn.getPos();
    EnumFacing enumfacing = packetIn.getDirection();
    this.playerEntity.markPlayerActive();

    if (blockpos.getY() < this.serverController.getBuildLimit() - 1 || enumfacing != EnumFacing.UP && blockpos.getY() < this.serverController.getBuildLimit())
    {
        double dist = playerEntity.interactionManager.getBlockReachDistance() + 3;
        dist *= dist;
        if (this.targetPos == null && this.playerEntity.getDistanceSq((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D) < dist && !this.serverController.isBlockProtected(worldserver, blockpos, this.playerEntity) && worldserver.getWorldBorder().contains(blockpos))
        {
            this.playerEntity.interactionManager.processRightClickBlock(this.playerEntity, worldserver, itemstack, enumhand, blockpos, enumfacing, packetIn.getFacingX(), packetIn.getFacingY(), packetIn.getFacingZ());
        }
    }
    else
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("build.tooHigh", new Object[] {Integer.valueOf(this.serverController.getBuildLimit())});
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.playerEntity.connection.sendPacket(new SPacketChat(textcomponenttranslation));
    }

    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos));
    this.playerEntity.connection.sendPacket(new SPacketBlockChange(worldserver, blockpos.offset(enumfacing)));
    itemstack = this.playerEntity.getHeldItem(enumhand);

    if (itemstack != null && itemstack.stackSize == 0)
    {
        this.playerEntity.setHeldItem(enumhand, (ItemStack)null);
        net.minecraftforge.event.ForgeEventFactory.onPlayerDestroyItem(this.playerEntity, itemstack, enumhand);
    }
}
项目:ExpandedRailsMod    文件:NetHandlerPlayServer.java   
public void sendPacket(final Packet<?> packetIn)
{
    if (packetIn instanceof SPacketChat)
    {
        SPacketChat spacketchat = (SPacketChat)packetIn;
        EntityPlayer.EnumChatVisibility entityplayer$enumchatvisibility = this.playerEntity.getChatVisibility();

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.HIDDEN)
        {
            return;
        }

        if (entityplayer$enumchatvisibility == EntityPlayer.EnumChatVisibility.SYSTEM && !spacketchat.isSystem())
        {
            return;
        }
    }

    try
    {
        this.netManager.sendPacket(packetIn);
    }
    catch (Throwable throwable)
    {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Sending packet");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Packet being sent");
        crashreportcategory.setDetail("Packet class", new ICrashReportDetail<String>()
        {
            public String call() throws Exception
            {
                return packetIn.getClass().getCanonicalName();
            }
        });
        throw new ReportedException(crashreport);
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void addChatComponentMessage(ITextComponent chatComponent, boolean p_146105_2_)
{
    this.connection.sendPacket(new SPacketChat(chatComponent, (byte)(p_146105_2_ ? 2 : 0)));
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    this.connection.sendPacket(new SPacketChat(component));
}
项目:Zombe-Modpack    文件:NetHandlerPlayServer.java   
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        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
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatComponentMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)), true);
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void addChatComponentMessage(ITextComponent chatComponent, boolean p_146105_2_)
{
    this.connection.sendPacket(new SPacketChat(chatComponent, (byte)(p_146105_2_ ? 2 : 0)));
}
项目:Backmemed    文件:EntityPlayerMP.java   
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    this.connection.sendPacket(new SPacketChat(component));
}
项目:Backmemed    文件:NetHandlerPlayServer.java   
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        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
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", new Object[] {this.playerEntity.getDisplayName(), s});
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
项目:Backmemed    文件:PlayerList.java   
public void sendChatMsgImpl(ITextComponent component, boolean isSystem)
{
    this.mcServer.addChatMessage(component);
    byte b0 = (byte)(isSystem ? 1 : 0);
    this.sendPacketToAllPlayers(new SPacketChat(component, b0));
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void addChatComponentMessage(ITextComponent chatComponent)
{
    this.connection.sendPacket(new SPacketChat(chatComponent));
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    this.connection.sendPacket(new SPacketChat(component));
}
项目:CustomWorldGen    文件:NetHandlerPlayServer.java   
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        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
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
            itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent);
            if (itextcomponent == null) return;
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
项目:CustomWorldGen    文件:PlayerList.java   
public void sendChatMsgImpl(ITextComponent component, boolean isSystem)
{
    this.mcServer.addChatMessage(component);
    byte b0 = (byte)(isSystem ? 1 : 0);
    this.sendPacketToAllPlayers(new SPacketChat(component, b0));
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * Displays the GUI for interacting with a chest inventory.
 */
public void displayGUIChest(IInventory chestInventory)
{
    if (chestInventory instanceof ILootContainer && ((ILootContainer)chestInventory).getLootTable() != null && this.isSpectator())
    {
        this.addChatMessage((new TextComponentTranslation("container.spectatorCantOpen", new Object[0])).setStyle((new Style()).setColor(TextFormatting.RED)));
    }
    else
    {
        if (this.openContainer != this.inventoryContainer)
        {
            this.closeScreen();
        }

        if (chestInventory instanceof ILockableContainer)
        {
            ILockableContainer ilockablecontainer = (ILockableContainer)chestInventory;

            if (ilockablecontainer.isLocked() && !this.canOpen(ilockablecontainer.getLockCode()) && !this.isSpectator())
            {
                this.connection.sendPacket(new SPacketChat(new TextComponentTranslation("container.isLocked", new Object[] {chestInventory.getDisplayName()}), (byte)2));
                this.connection.sendPacket(new SPacketSoundEffect(SoundEvents.BLOCK_CHEST_LOCKED, SoundCategory.BLOCKS, this.posX, this.posY, this.posZ, 1.0F, 1.0F));
                return;
            }
        }

        this.getNextWindowId();

        if (chestInventory instanceof IInteractionObject)
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, ((IInteractionObject)chestInventory).getGuiID(), chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = ((IInteractionObject)chestInventory).createContainer(this.inventory, this);
        }
        else
        {
            this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:container", chestInventory.getDisplayName(), chestInventory.getSizeInventory()));
            this.openContainer = new ContainerChest(this.inventory, chestInventory, this);
        }

        this.openContainer.windowId = this.currentWindowId;
        this.openContainer.addListener(this);
        net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void addChatComponentMessage(ITextComponent chatComponent)
{
    this.connection.sendPacket(new SPacketChat(chatComponent));
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
/**
 * Send a chat message to the CommandSender
 */
public void addChatMessage(ITextComponent component)
{
    this.connection.sendPacket(new SPacketChat(component));
}
项目:ExpandedRailsMod    文件:NetHandlerPlayServer.java   
/**
 * Process chat messages (broadcast back to clients) and commands (executes)
 */
public void processChatMessage(CPacketChatMessage packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.getChatVisibility() == EntityPlayer.EnumChatVisibility.HIDDEN)
    {
        TextComponentTranslation textcomponenttranslation = new TextComponentTranslation("chat.cannotSend", new Object[0]);
        textcomponenttranslation.getStyle().setColor(TextFormatting.RED);
        this.sendPacket(new SPacketChat(textcomponenttranslation));
    }
    else
    {
        this.playerEntity.markPlayerActive();
        String s = packetIn.getMessage();
        s = StringUtils.normalizeSpace(s);

        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
        {
            ITextComponent itextcomponent = new TextComponentTranslation("chat.type.text", this.playerEntity.getDisplayName(), net.minecraftforge.common.ForgeHooks.newChatWithLinks(s));
            itextcomponent = net.minecraftforge.common.ForgeHooks.onServerChatEvent(this, s, itextcomponent);
            if (itextcomponent == null) return;
            this.serverController.getPlayerList().sendChatMsgImpl(itextcomponent, false);
        }

        this.chatSpamThresholdCount += 20;

        if (this.chatSpamThresholdCount > 200 && !this.serverController.getPlayerList().canSendCommands(this.playerEntity.getGameProfile()))
        {
            this.kickPlayerFromServer("disconnect.spam");
        }
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
void handleChat(SPacketChat packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Prints a chatmessage in the chat GUI
 */
void handleChat(SPacketChat packetIn);