public void handleCustomPayload(Packet250CustomPayload par1Packet250CustomPayload) { if ("MC|BEdit".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); ItemStack itemstack = Packet.readItemStack(datainputstream); if (!ItemWritableBook.validBookTagPages(itemstack.getTagCompound())) { throw new IOException("Invalid book tag!"); } ItemStack itemstack2 = playerEntity.inventory.getCurrentItem(); if (itemstack != null && itemstack.itemID == Item.writableBook.shiftedIndex && itemstack.itemID == itemstack2.itemID) { itemstack2.setTagCompound(itemstack.getTagCompound()); } } catch (Exception exception) { exception.printStackTrace(); } } else if ("MC|BSign".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream1 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); ItemStack itemstack1 = Packet.readItemStack(datainputstream1); if (!ItemEditableBook.validBookTagContents(itemstack1.getTagCompound())) { throw new IOException("Invalid book tag!"); } ItemStack itemstack3 = playerEntity.inventory.getCurrentItem(); if (itemstack1 != null && itemstack1.itemID == Item.writtenBook.shiftedIndex && itemstack3.itemID == Item.writableBook.shiftedIndex) { itemstack3.setTagCompound(itemstack1.getTagCompound()); itemstack3.itemID = Item.writtenBook.shiftedIndex; } } catch (Exception exception1) { exception1.printStackTrace(); } } else if ("MC|TrSel".equals(par1Packet250CustomPayload.channel)) { try { DataInputStream datainputstream2 = new DataInputStream(new ByteArrayInputStream(par1Packet250CustomPayload.data)); int i = datainputstream2.readInt(); Container container = playerEntity.craftingInventory; if (container instanceof ContainerMerchant) { ((ContainerMerchant) container).setCurrentRecipeIndex(i); } } catch (Exception exception2) { exception2.printStackTrace(); } } else { ModLoader.serverCustomPayload(this, par1Packet250CustomPayload); } }
public void handleChat(Packet3Chat par1Packet3Chat) { ModLoader.serverChat(this, par1Packet3Chat.message); if (playerEntity.getChatVisibility() == 2) { sendPacketToPlayer(new Packet3Chat("Cannot send chat message.")); return; } String s = par1Packet3Chat.message; if (s.length() > 100) { kickPlayerFromServer("Chat message too long"); return; } s = s.trim(); for (int i = 0; i < s.length(); i++) { if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) { kickPlayerFromServer("Illegal characters in chat"); return; } } if (s.startsWith("/")) { func_72566_d(s); } else { if (playerEntity.getChatVisibility() == 1) { sendPacketToPlayer(new Packet3Chat("Cannot send chat message.")); return; } s = (new StringBuilder()) .append("<") .append(playerEntity.username) .append("> ") .append(s) .toString(); logger.info(s); mcServer.getConfigurationManager().sendPacketToAllPlayers(new Packet3Chat(s, false)); } chatSpamThresholdCount += 20; if (chatSpamThresholdCount > 200 && !mcServer.getConfigurationManager().areCommandsAllowed(playerEntity.username)) { kickPlayerFromServer("disconnect.spam"); } }