ProtocolLib 2.5.0
Details
-
FilenameProtocolLib-2.5.0.jar
-
Uploaded by
-
UploadedJul 22, 2013
-
Size946.85 KB
-
Downloads12,514
-
MD55babd0f14baa86cbb966fb508de3f36d
Supported Bukkit Versions
- 1.6.2
- 1.5.2
- 1.2.5
Changelog
Build: #111
This update contains a number of new exciting features for plugin developers, including a PacketAdapter builder and the ability to read and write a raw packet data to the connected client. I've described them in more detailed here, but I'll attach a few code examples nevertheless.
First, the new PacketAdapter builder allows packet listeners to be constructed without having to deal with the tens of different PacketAdapter constructor (which seems to often fail in Eclipse):
ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(PacketAdapter.params(this, Packets.Client.CHAT). clientSide()) { @Override public void onPacketReceiving(PacketEvent event) { System.out.println( "Intercepted message: " + event.getPacket().getStrings().read(0)); } });
Next, I've added the ability to read the raw incoming packet data as a DataInputStream or ByteBuffer:
ProtocolLibrary.getProtocolManager().addPacketListener( new PacketAdapter(PacketAdapter.params(this, Packets.Client.SET_CREATIVE_SLOT).clientSide().optionIntercept()) { @Override public void onPacketReceiving(PacketEvent event) { DataInputStream input = event.getNetworkMarker().getInputStream(); // Can occur if the packet is "sent" by a plugin using // recieveClientPacket if (input == null) return; try { // Read slot int slot = input.readShort(); ItemStack stack = event.getNetworkMarker().getSerializer(). deserializeItemStack(input); // Do something } catch (IOException e) { e.printStackTrace(); } } });
This should come in handy if CraftBukkit removes or alters the packet while its being read, before ProtocolLib has a chance to invoke the packet events. In fact, this is already necessary if you need unfettered access to an ItemStack sent by the client, as CraftBukkit will scrub it for any unknown NBT tags and unimplemented features (attributes).
You can also alter how the packet should be written and sent to the network stream.
Change log
Features
- Add the ability to intercept the write method of packets. (with adapter)
- Added the ability to intercept serialized input packets on CraftBukkit. (and Spigot)
- Added the ability to retrieve the input buffer as a stream.
API
- Use a builder pattern in PacketAdapter instead of a constructor with 8 parameters.
- Added more utility methods to the stream serializer class.
- Added the ability to serialize and deserialize NbtCompounds.
- Add the ability to store an NBT compound in a given ItemStack.
Compatibility
- Minecraft 1.6.2 seems to work fine.
- Adding the two new packets for 1.6.1.
- Added support for Spigot when Netty is disabled.
- Properly handle reloads on Spigot.
- Update the stream serializer for Minecraft 1.6.2
- Update packet container serialization for Minecraft 1.6.2.
Bug fixes
- Correct the fallback method for retrieving WatchableObjects.
- Use serialization to clone certain packets (44 - update attributes).
- Handle NULL results from the deserialization methods.
- Don't pass our CaptureInputStream to the "get player identity" function