Skip to content

Commit

Permalink
Fallback to the HANDSHAKING protocol if no packet type is found in th…
Browse files Browse the repository at this point in the history
…e registry (fixes #2601)
  • Loading branch information
nickuc authored and dmulloy2 committed Dec 16, 2023
1 parent 0da2751 commit 564349c
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,15 @@ public PacketEvent onPacketReceiving(Injector injector, Object packet, NetworkMa
if (marker != null || inboundListeners.contains(packetClass)) {
// wrap the packet and construct the event
PacketType.Protocol currentProtocol = injector.getCurrentProtocol(PacketType.Sender.CLIENT);
PacketContainer container = new PacketContainer(PacketRegistry.getPacketType(currentProtocol, packetClass), packet);
PacketType packetType = PacketRegistry.getPacketType(currentProtocol, packetClass);

// if packet type could not be found, fallback to HANDSHAKING protocol
// temporary workaround for https://github.com/dmulloy2/ProtocolLib/issues/2601
if (packetType == null) {
packetType = PacketRegistry.getPacketType(PacketType.Protocol.HANDSHAKING, packetClass);
}

PacketContainer container = new PacketContainer(packetType, packet);
PacketEvent packetEvent = PacketEvent.fromClient(this, container, marker, injector.getPlayer());

// post to all listeners, then return the packet event we constructed
Expand Down

0 comments on commit 564349c

Please sign in to comment.