From a1ebd76e68bb96f323792a667bafee5725519a5c Mon Sep 17 00:00:00 2001 From: My-Name-Is-Jeff <37018278+My-Name-Is-Jeff@users.noreply.github.com> Date: Thu, 12 Dec 2024 11:37:21 -0500 Subject: [PATCH] fix: try to resolve scenarios that incorrectly cancel outboundRoomQueue --- .../skytilsmod/listeners/DungeonListener.kt | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt index d67705ac0..0f96506f5 100644 --- a/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt +++ b/src/main/kotlin/gg/skytils/skytilsmod/listeners/DungeonListener.kt @@ -123,24 +123,28 @@ object DungeonListener { @SubscribeEvent fun onWorldLoad(event: WorldEvent.Unload) { - team.clear() - deads.clear() - disconnected.clear() - missingPuzzles.clear() - completedPuzzles.clear() - teamCached.clear() - printDevMessage("closed room queue world load", "dungeonws") - outboundRoomQueue.cancel() - isSoloDungeon = false + if (event.world == mc.theWorld) { + team.clear() + deads.clear() + disconnected.clear() + missingPuzzles.clear() + completedPuzzles.clear() + teamCached.clear() + printDevMessage("closed room queue world load", "dungeonws") + outboundRoomQueue.cancel() + isSoloDungeon = false + } } @SubscribeEvent fun onLocationUpdate(event: LocationChangeEvent) { if (event.packet.mode.getOrNull() == "dungeon") { printDevMessage("closed room queue", "dungeonws") - outboundRoomQueue.cancel() - outboundRoomQueue = Channel(UNLIMITED) { - printDevMessage("failed to deliver $it", "dungeonws") + outboundRoomQueue.also { + outboundRoomQueue = Channel(UNLIMITED) { + printDevMessage("failed to deliver $it", "dungeonws") + } + it.cancel() } } }