ProtocolLib

3M Downloads

[5.0] receiveClientPacket broke API compatibility, and is also broken itself

bergerkiller opened this issue · 5 comments

commented

Describe the bug
ProtocolLib 5.0 removed the old (typo'd) recieveClientPacket and replaced it with receiveClientPacket, which has an extra boolean parameter. While trying to work around this issue I now find that the new method throws an UnsupportedOperationException when called.

Exception: https://paste.traincarts.net/uvafakocaf.php

To Reproduce
Steps to reproduce the behavior:

  1. Install BKCommonLib from here ( https://ci.mg-dev.eu/job/BKCommonLib/1268/ )
  2. Install Traincarts and TC-Coasters
  3. Go near to a TCC node and left-click to select it
  4. TCC cancels the original packets and enqueues a different interaction packet instead (to prevent nodes' invisible entities breaking block breaking nearby)
  5. ProtocolLib throws an exception: https://paste.traincarts.net/uvafakocaf.php

Expected behavior
No exception.

Version Info
https://paste.traincarts.net/nunoderiji.pl

Additional context
In case this was due to calling it while handling the send of another packet, I also tried calling that method in a next-tick task. The same happened, so this isnt the cause here. ( https://paste.traincarts.net/ibaqogeyiz.m )

Code involves at-runtime generated code. But the basics boil down to this small adaptor snippet being called from receivePacket() further down below. https://github.com/bergerhealer/BKCommonLib/blob/master/src/main/java/com/bergerkiller/bukkit/common/internal/network/ProtocolLibPacketHandler.java#L85

Player player = ...
Object packet = ...
PacketContainer toReceive = new PacketContainer(PacketRegistry.getPacketType(packet.getClass()), packet);
ProtocolLibrary.getProtocolManager().receiveClientPacket(player, toReceive, true);
commented

Can you link a jar to test that commit so I can give those changes a test too? :)

commented

Works great, no errors, and looks like the packet is handled correctly when I click at the entity. Of course the async listener issue is still there but I assume one jar only contains the fixes of one PR at a time.

commented

Yes, it only contains the fix for this issue :)

commented

Actually looking at the setCancelled code it's just more legacy code which had no function in v4 anyway... Probably going to remove that as well 🤔

(setCancelled would throw an exception in v4 as well but is based on isCancelled which is always false in that context by default)