Program: 10172
Project: 10172
Buggy source:
/** 
 * Handles all packets going out from the server.
 * @param player the player the packet is being sent to
 * @param packet the client-bound packet
 * @return whether to cancel sending the packet
 */
public static boolean sendPacket(final EntityPlayer player,final Packet packet){
  try {
    if (packet instanceof PacketPlayOutChat) {
      if (ExecuteCommand.silencedPlayers.contains(player.getUniqueID())) {
        return true;
      }
      final PlayerReceivesMessageScriptEvent event=PlayerReceivesMessageScriptEvent.instance;
      if (event.loaded) {
        FutureTask<Boolean> futureTask=new FutureTask<Boolean>(new Callable<Boolean>(){
          @Override public Boolean call() throws Exception {
            PacketPlayOutChat cPacket=(PacketPlayOutChat)packet;
            int pos=chat_position.getInt(cPacket);
            if (pos != 2) {
              IChatBaseComponent baseComponent=(IChatBaseComponent)chat_message.get(cPacket);
              boolean bungee=false;
              if (baseComponent != null) {
                event.message=new Element(baseComponent.toPlainText());
                event.rawJson=new Element(IChatBaseComponent.ChatSerializer.a(baseComponent));
              }
 else               if (cPacket.components != null) {
                event.message=new Element(BaseComponent.toPlainText(cPacket.components));
                event.rawJson=new Element(ComponentSerializer.toString(cPacket.components));
                bungee=true;
              }
              event.system=new Element(pos == 1);
              event.player=dPlayer.mirrorBukkitPlayer(player.getBukkitEntity());
              event.cancelled=false;
              event.fire();
              if (event.messageModified) {
                if (!bungee) {
                  chat_message.set(cPacket,new ChatComponentText(event.message.asString()));
                }
 else {
                  cPacket.components=new BaseComponent[]{new TextComponent(event.message.asString())};
                }
              }
 else               if (event.rawJsonModified) {
                if (!bungee) {
                  chat_message.set(cPacket,IChatBaseComponent.ChatSerializer.a(event.rawJson.asString()));
                }
 else {
                  cPacket.components=ComponentSerializer.parse(event.rawJson.asString());
                }
              }
              return event.cancelled;
            }
            return false;
          }
        }
);
        Bukkit.getScheduler().runTask(DenizenAPI.getCurrentInstance(),futureTask);
        return futureTask.get();
      }
    }
 else     if (packet instanceof PacketPlayOutSetSlot) {
      PacketPlayOutSetSlot ssPacket=(PacketPlayOutSetSlot)packet;
      ItemStack itemStack=(ItemStack)set_slot_itemStack.get(ssPacket);
      set_slot_itemStack.set(ssPacket,removeItemScriptLore(itemStack));
    }
 else     if (packet instanceof PacketPlayOutWindowItems) {
      PacketPlayOutWindowItems wiPacket=(PacketPlayOutWindowItems)packet;
      ItemStack[] itemStacks=(ItemStack[])window_items_itemStackArray.get(wiPacket);
      for (int i=0; i < itemStacks.length; i++) {
        itemStacks[i]=removeItemScriptLore(itemStacks[i]);
      }
      window_items_itemStackArray.set(wiPacket,itemStacks);
    }
 else     if (packet instanceof PacketPlayOutNamedEntitySpawn) {
      PacketPlayOutNamedEntitySpawn nesPacket=(PacketPlayOutNamedEntitySpawn)packet;
      int entityId=named_spawn_entityId.getInt(nesPacket);
      if (entityIsHiding(player,entityId)) {
        return true;
      }
      UUID entityUUID=(UUID)named_spawn_entityUUID.get(nesPacket);
      final Entity entity=((WorldServer)player.getWorld()).getEntity(entityUUID);
      if (entity instanceof EntityFakePlayer) {
        player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,(EntityFakePlayer)entity));
        Bukkit.getScheduler().runTaskLater(DenizenAPI.getCurrentInstance(),new Runnable(){
          @Override public void run(){
            player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER,(EntityFakePlayer)entity));
          }
        }
,5);
      }
    }
 else     if (packet instanceof PacketPlayOutSpawnEntity) {
      PacketPlayOutSpawnEntity sePacket=(PacketPlayOutSpawnEntity)packet;
      int entityId=spawn_entityId.getInt(sePacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityLiving) {
      PacketPlayOutSpawnEntityLiving selPacket=(PacketPlayOutSpawnEntityLiving)packet;
      int entityId=spawn_living_entityId.getInt(selPacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityPainting) {
      PacketPlayOutSpawnEntityPainting sepPacket=(PacketPlayOutSpawnEntityPainting)packet;
      int entityId=spawn_painting_entityId.getInt(sepPacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityExperienceOrb) {
      PacketPlayOutSpawnEntityExperienceOrb seePacket=(PacketPlayOutSpawnEntityExperienceOrb)packet;
      int entityId=spawn_experience_entityId.getInt(seePacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutEntityMetadata) {
      PacketPlayOutEntityMetadata emPacket=(PacketPlayOutEntityMetadata)packet;
      int eid=metadata_eid.getInt(emPacket);
      HashSet<UUID> players=GlowCommand.glowViewers.get(eid);
      if (players == null) {
        return false;
      }
      List<DataWatcher.Item<?>> items=(List<DataWatcher.Item<?>>)metadata_data.get(emPacket);
      for (      DataWatcher.Item<?> it : items) {
        if (it.a().a() == 0) {
          return !players.contains(player.getUniqueID());
        }
      }
      return false;
    }
 else     if (packet instanceof PacketPlayOutPlayerInfo) {
      PlayerProfileEditor.updatePlayerProfiles((PacketPlayOutPlayerInfo)packet);
    }
 else     if (packet instanceof PacketPlayOutCustomPayload) {
      PacketPlayOutCustomPayload cPacket=(PacketPlayOutCustomPayload)packet;
      String name=(String)custom_name.get(cPacket);
      if (name.equals("String_Node_Str")) {
        PacketDataSerializer serializer=(PacketDataSerializer)custom_serializer.get(cPacket);
        PacketDataSerializer newSerializer=new PacketDataSerializer(Unpooled.buffer());
        newSerializer.writeInt(serializer.readInt());
        byte trades=serializer.readByte();
        newSerializer.writeByte(trades);
        for (int i=0; i < trades; i++) {
          ItemStack buyItem1=serializer.k();
          newSerializer.a(removeItemScriptLore(buyItem1));
          ItemStack buyItem3=serializer.k();
          newSerializer.a(removeItemScriptLore(buyItem3));
          boolean hasItem2=serializer.readBoolean();
          newSerializer.writeBoolean(hasItem2);
          if (hasItem2) {
            ItemStack buyItem2=serializer.k();
            newSerializer.a(removeItemScriptLore(buyItem2));
          }
          boolean usedMax=serializer.readBoolean();
          newSerializer.writeBoolean(usedMax);
          int uses=serializer.readInt();
          newSerializer.writeInt(uses);
          int maxUses=serializer.readInt();
          newSerializer.writeInt(maxUses);
        }
        custom_serializer.set(cPacket,newSerializer);
      }
    }
  }
 catch (  Exception e) {
    dB.echoError(e);
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Handles all packets going out from the server.
 * @param player the player the packet is being sent to
 * @param packet the client-bound packet
 * @return whether to cancel sending the packet
 */
public static boolean sendPacket(final EntityPlayer player,final Packet packet){
  try {
    if (packet instanceof PacketPlayOutChat) {
      if (ExecuteCommand.silencedPlayers.contains(player.getUniqueID())) {
        return true;
      }
      final PlayerReceivesMessageScriptEvent event=PlayerReceivesMessageScriptEvent.instance;
      if (event.loaded) {
        FutureTask<Boolean> futureTask=new FutureTask<Boolean>(new Callable<Boolean>(){
          @Override public Boolean call() throws Exception {
            PacketPlayOutChat cPacket=(PacketPlayOutChat)packet;
            int pos=chat_position.getInt(cPacket);
            if (pos != 2) {
              IChatBaseComponent baseComponent=(IChatBaseComponent)chat_message.get(cPacket);
              boolean bungee=false;
              if (baseComponent != null) {
                event.message=new Element(baseComponent.toPlainText());
                event.rawJson=new Element(IChatBaseComponent.ChatSerializer.a(baseComponent));
              }
 else               if (cPacket.components != null) {
                event.message=new Element(BaseComponent.toPlainText(cPacket.components));
                event.rawJson=new Element(ComponentSerializer.toString(cPacket.components));
                bungee=true;
              }
              event.system=new Element(pos == 1);
              event.player=dPlayer.mirrorBukkitPlayer(player.getBukkitEntity());
              event.cancelled=false;
              event.fire();
              if (event.messageModified) {
                if (!bungee) {
                  chat_message.set(cPacket,new ChatComponentText(event.message.asString()));
                }
 else {
                  cPacket.components=new BaseComponent[]{new TextComponent(event.message.asString())};
                }
              }
 else               if (event.rawJsonModified) {
                if (!bungee) {
                  chat_message.set(cPacket,IChatBaseComponent.ChatSerializer.a(event.rawJson.asString()));
                }
 else {
                  cPacket.components=ComponentSerializer.parse(event.rawJson.asString());
                }
              }
              return event.cancelled;
            }
            return false;
          }
        }
);
        if (Bukkit.isPrimaryThread()) {
          futureTask.run();
        }
 else {
          Bukkit.getScheduler().runTask(DenizenAPI.getCurrentInstance(),futureTask);
        }
        return futureTask.get();
      }
    }
 else     if (packet instanceof PacketPlayOutSetSlot) {
      PacketPlayOutSetSlot ssPacket=(PacketPlayOutSetSlot)packet;
      ItemStack itemStack=(ItemStack)set_slot_itemStack.get(ssPacket);
      set_slot_itemStack.set(ssPacket,removeItemScriptLore(itemStack));
    }
 else     if (packet instanceof PacketPlayOutWindowItems) {
      PacketPlayOutWindowItems wiPacket=(PacketPlayOutWindowItems)packet;
      ItemStack[] itemStacks=(ItemStack[])window_items_itemStackArray.get(wiPacket);
      for (int i=0; i < itemStacks.length; i++) {
        itemStacks[i]=removeItemScriptLore(itemStacks[i]);
      }
      window_items_itemStackArray.set(wiPacket,itemStacks);
    }
 else     if (packet instanceof PacketPlayOutNamedEntitySpawn) {
      PacketPlayOutNamedEntitySpawn nesPacket=(PacketPlayOutNamedEntitySpawn)packet;
      int entityId=named_spawn_entityId.getInt(nesPacket);
      if (entityIsHiding(player,entityId)) {
        return true;
      }
      UUID entityUUID=(UUID)named_spawn_entityUUID.get(nesPacket);
      final Entity entity=((WorldServer)player.getWorld()).getEntity(entityUUID);
      if (entity instanceof EntityFakePlayer) {
        player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER,(EntityFakePlayer)entity));
        Bukkit.getScheduler().runTaskLater(DenizenAPI.getCurrentInstance(),new Runnable(){
          @Override public void run(){
            player.playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER,(EntityFakePlayer)entity));
          }
        }
,5);
      }
    }
 else     if (packet instanceof PacketPlayOutSpawnEntity) {
      PacketPlayOutSpawnEntity sePacket=(PacketPlayOutSpawnEntity)packet;
      int entityId=spawn_entityId.getInt(sePacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityLiving) {
      PacketPlayOutSpawnEntityLiving selPacket=(PacketPlayOutSpawnEntityLiving)packet;
      int entityId=spawn_living_entityId.getInt(selPacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityPainting) {
      PacketPlayOutSpawnEntityPainting sepPacket=(PacketPlayOutSpawnEntityPainting)packet;
      int entityId=spawn_painting_entityId.getInt(sepPacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutSpawnEntityExperienceOrb) {
      PacketPlayOutSpawnEntityExperienceOrb seePacket=(PacketPlayOutSpawnEntityExperienceOrb)packet;
      int entityId=spawn_experience_entityId.getInt(seePacket);
      return entityIsHiding(player,entityId);
    }
 else     if (packet instanceof PacketPlayOutEntityMetadata) {
      PacketPlayOutEntityMetadata emPacket=(PacketPlayOutEntityMetadata)packet;
      int eid=metadata_eid.getInt(emPacket);
      HashSet<UUID> players=GlowCommand.glowViewers.get(eid);
      if (players == null) {
        return false;
      }
      List<DataWatcher.Item<?>> items=(List<DataWatcher.Item<?>>)metadata_data.get(emPacket);
      for (      DataWatcher.Item<?> it : items) {
        if (it.a().a() == 0) {
          return !players.contains(player.getUniqueID());
        }
      }
      return false;
    }
 else     if (packet instanceof PacketPlayOutPlayerInfo) {
      PlayerProfileEditor.updatePlayerProfiles((PacketPlayOutPlayerInfo)packet);
    }
 else     if (packet instanceof PacketPlayOutCustomPayload) {
      PacketPlayOutCustomPayload cPacket=(PacketPlayOutCustomPayload)packet;
      String name=(String)custom_name.get(cPacket);
      if (name.equals("String_Node_Str")) {
        PacketDataSerializer serializer=(PacketDataSerializer)custom_serializer.get(cPacket);
        PacketDataSerializer newSerializer=new PacketDataSerializer(Unpooled.buffer());
        newSerializer.writeInt(serializer.readInt());
        byte trades=serializer.readByte();
        newSerializer.writeByte(trades);
        for (int i=0; i < trades; i++) {
          ItemStack buyItem1=serializer.k();
          newSerializer.a(removeItemScriptLore(buyItem1));
          ItemStack buyItem3=serializer.k();
          newSerializer.a(removeItemScriptLore(buyItem3));
          boolean hasItem2=serializer.readBoolean();
          newSerializer.writeBoolean(hasItem2);
          if (hasItem2) {
            ItemStack buyItem2=serializer.k();
            newSerializer.a(removeItemScriptLore(buyItem2));
          }
          boolean usedMax=serializer.readBoolean();
          newSerializer.writeBoolean(usedMax);
          int uses=serializer.readInt();
          newSerializer.writeInt(uses);
          int maxUses=serializer.readInt();
          newSerializer.writeInt(maxUses);
        }
        custom_serializer.set(cPacket,newSerializer);
      }
    }
  }
 catch (  Exception e) {
    dB.echoError(e);
  }
  return false;
}