aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2024-07-24 15:34:10 +0200
committerLinnea Gräf <nea@nea.moe>2024-07-24 15:34:10 +0200
commita19d2e1e1b233dbd0bde9b74516cc4a399772066 (patch)
tree3e3f7741114c1a0c2465d420f1c377d744f7cd00 /src/main/kotlin/moe
parent0ea10aac312ce446a958ca654811a64ed82f09ac (diff)
downloadfirmament-a19d2e1e1b233dbd0bde9b74516cc4a399772066.tar.gz
firmament-a19d2e1e1b233dbd0bde9b74516cc4a399772066.tar.bz2
firmament-a19d2e1e1b233dbd0bde9b74516cc4a399772066.zip
Fix exception during packet handling
Diffstat (limited to 'src/main/kotlin/moe')
-rw-r--r--src/main/kotlin/moe/nea/firmament/apis/ingame/InGameCodecWrapper.kt5
1 files changed, 3 insertions, 2 deletions
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)
}