mirror of
https://github.com/ViaVersion/ViaFabricPlus.git
synced 2024-12-22 16:48:25 +01:00
Handle errors properly in <=1.20 custom payload handling
This commit is contained in:
parent
d1ad86c8d4
commit
6b8f979b8f
@ -67,11 +67,15 @@ public abstract class MixinCustomPayloadS2CPacket {
|
||||
return null;
|
||||
}
|
||||
if (ProtocolTranslator.getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_20)) {
|
||||
// Skip remaining bytes after reading the payload
|
||||
// Skip remaining bytes after reading the payload and return null if the payload fails to read
|
||||
return (PacketByteBuf.PacketReader<? extends CustomPayload>) packetByteBuf -> {
|
||||
final CustomPayload result = reader.apply(packetByteBuf);
|
||||
packetByteBuf.skipBytes(packetByteBuf.readableBytes());
|
||||
return result;
|
||||
try {
|
||||
final CustomPayload result = reader.apply(packetByteBuf);
|
||||
packetByteBuf.skipBytes(packetByteBuf.readableBytes());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return reader;
|
||||
|
Loading…
Reference in New Issue
Block a user