// 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; } } }
protected void a(ChannelHandlerContext var1, Packet var2) throws Exception { if (k.isOpen()) { try { var2.handle(m); } catch (class_ko var4) {; } } }
public static RecordedPacket read(DataInputStream datainputstream, boolean flag) throws IOException { RecordedPacket rp = new RecordedPacket(); rp.delta = datainputstream.readLong(); rp.packet = (Packet.a(datainputstream, flag)); return rp; }
@Override public boolean add(Packet packet) { if (packet.k() == 51) { IPacket51 packet51 = InternalAccessor.Instance.newPacket51(); packet51.setPacket(packet); Calculations.Obfuscate(packet51, this.player); } return super.add(packet); }
public static List a(DataInputStream datainputstream) { ArrayList arraylist = null; for (byte b0 = datainputstream.readByte(); b0 != 127; b0 = datainputstream.readByte()) { if (arraylist == null) { arraylist = new ArrayList(); } int i = (b0 & 224) >> 5; int j = b0 & 31; WatchableObject watchableobject = null; switch (i) { case 0: watchableobject = new WatchableObject(i, j, Byte.valueOf(datainputstream.readByte())); break; case 1: watchableobject = new WatchableObject(i, j, Short.valueOf(datainputstream.readShort())); break; case 2: watchableobject = new WatchableObject(i, j, Integer.valueOf(datainputstream.readInt())); break; case 3: watchableobject = new WatchableObject(i, j, Float.valueOf(datainputstream.readFloat())); break; case 4: watchableobject = new WatchableObject(i, j, Packet.a(datainputstream, 64)); break; case 5: short short1 = datainputstream.readShort(); byte b1 = datainputstream.readByte(); short short2 = datainputstream.readShort(); watchableobject = new WatchableObject(i, j, new ItemStack(short1, b1, short2)); break; case 6: int k = datainputstream.readInt(); int l = datainputstream.readInt(); int i1 = datainputstream.readInt(); watchableobject = new WatchableObject(i, j, new ChunkCoordinates(k, l, i1)); } arraylist.add(watchableobject); } return arraylist; }
private Packet getFastPacket51(int cx, int cz) { World world = getPlayer().getWorld(); if (!world.isChunkLoaded(cx, cz)) { world.loadChunk(cx, cz); } Packet packet = new Packet51MapChunk(cx << 4, 0, cz << 4, 16, 128, 16, this.player.world); try { packet.lowPriority = false; Field g = Packet51MapChunk.class.getDeclaredField("buffer"); g.setAccessible(true); byte[] compressedData = (byte[]) g.get(packet); if (compressedData == null) { MCPacket.setPacket(packet, 51); if (!PacketListeners.canSendUncompressedPacket(getPlayer(), MCPacket)) { return null; } AtomicInteger size = new AtomicInteger(0); Field rawData; try { rawData = Packet51MapChunk.class.getDeclaredField("rawData"); } catch (NoSuchFieldException e) { rawData = Packet51MapChunk.class.getDeclaredField("buffer"); } Field h = Packet51MapChunk.class.getDeclaredField("size"); rawData.setAccessible(true); h.setAccessible(true); byte[] rawBytes = (byte[]) rawData.get(packet); if (rawBytes != null) { g.set(packet, compressData(rawBytes, size)); h.set(packet, size.get()); } } } catch (NoSuchFieldException e) { return null; } catch (IllegalAccessException e) { e.printStackTrace(); } return packet; }
private static void a(DataOutputStream dataoutputstream, WatchableObject watchableobject) { int i = (watchableobject.c() << 5 | watchableobject.a() & 31) & 255; dataoutputstream.writeByte(i); switch (watchableobject.c()) { case 0: dataoutputstream.writeByte(((Byte) watchableobject.b()).byteValue()); break; case 1: dataoutputstream.writeShort(((Short) watchableobject.b()).shortValue()); break; case 2: dataoutputstream.writeInt(((Integer) watchableobject.b()).intValue()); break; case 3: dataoutputstream.writeFloat(((Float) watchableobject.b()).floatValue()); break; case 4: Packet.a((String) watchableobject.b(), dataoutputstream); break; case 5: ItemStack itemstack = (ItemStack) watchableobject.b(); dataoutputstream.writeShort(itemstack.getItem().id); dataoutputstream.writeByte(itemstack.count); dataoutputstream.writeShort(itemstack.getData()); break; case 6: ChunkCoordinates chunkcoordinates = (ChunkCoordinates) watchableobject.b(); dataoutputstream.writeInt(chunkcoordinates.x); dataoutputstream.writeInt(chunkcoordinates.y); dataoutputstream.writeInt(chunkcoordinates.z); } }
public void a(Packet packet) { a.warning(this.getClass() + " wasn\'t prepared to deal with a " + packet.getClass()); this.disconnect("Protocol error, unexpected packet"); }
public void write(DataOutputStream dataoutputstream) throws IOException { dataoutputstream.writeLong(delta); Packet.a(packet, dataoutputstream); }