Fallback to the HANDSHAKING protocol if no packet type is found in the registry (fixes https://github.com/dmulloy2/ProtocolLib/issues/2601)

This commit is contained in:
Nick 2023-12-15 23:16:37 -03:00 committed by Dan Mulloy
parent 0da27515a4
commit 564349c914
No known key found for this signature in database
GPG Key ID: 3C5AD5D866D1539A
1 changed files with 9 additions and 1 deletions

View File

@ -112,7 +112,15 @@ public class NetworkManagerInjector implements ChannelListener {
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