From a19d2e1e1b233dbd0bde9b74516cc4a399772066 Mon Sep 17 00:00:00 2001 From: Linnea Gräf Date: Wed, 24 Jul 2024 15:34:10 +0200 Subject: Fix exception during packet handling --- src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/main/kotlin/moe/nea/firmament') diff --git a/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt b/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt index 447b902..30bbc90 100644 --- a/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt +++ b/src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt @@ -36,8 +36,9 @@ class InGameCodecWrapper( val duplicateBuffer = PacketByteBuf(buf.slice()) val original = wrapped.decode(buf) buf.skipBytes(buf.readableBytes()) - val duplicate = direction.customCodec.decode(duplicateBuffer) - if (duplicate is FirmamentCustomPayload.Unhandled) + val duplicate = runCatching { direction.customCodec.decode(duplicateBuffer) } + .getOrNull() + if (duplicate is FirmamentCustomPayload.Unhandled || duplicate == null) return original return JoinedCustomPayload(original, duplicate) } -- cgit