Ejemplo n.º 1
0
  // Called from the main thread only
  private void syncedSendPacket(Packet packet, MCCraftPacket[] packetWrappers) {
    int packetId = -1;
    try {
      packetId = packet.b();
    } catch (Exception e) {
      return;
    }

    try {
      if (!PacketListeners.canSend(getPlayer(), packet, packetWrappers, packetId)) {
        return;
      } else {
        if (packet instanceof Packet51MapChunk) {
          Packet51MapChunk chunk = (Packet51MapChunk) packet;
          if (chunk.buffer == null) {
            ChunkCompressionThread.sendPacket(player, packet);
            return;
          }
        }
        super.sendPacket(packet);
      }
    } catch (NullPointerException npe) {
      if (packet != null) {
        throw new RuntimeException(
            "Null pointer exception thrown when trying to process packet of type "
                + packet.getClass().getName(),
            npe);
      } else {
        throw npe;
      }
    }
  }