From bace91dc8e142687ca52347334ed2a665e3899a1 Mon Sep 17 00:00:00 2001 From: Boy Date: Fri, 7 Feb 2025 15:49:43 +0100 Subject: [PATCH] fix: add chunk-ticket during respawn --- .../bonfire/listeners/PlayerListener.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main/kotlin/com/mineinabyss/bonfire/listeners/PlayerListener.kt b/src/main/kotlin/com/mineinabyss/bonfire/listeners/PlayerListener.kt index 0cf54cb..737a4bb 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/listeners/PlayerListener.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/listeners/PlayerListener.kt @@ -49,9 +49,17 @@ class PlayerListener : Listener { val loc = bonfireRespawn.bonfireLocation loc.world.getChunkAtAsyncUrgently(loc).thenAccept { chunk -> - val bonfireEntity = - chunk.entities.filterIsBonfire().find { it.uniqueId == bonfireRespawn.bonfireUuid } ?: return@thenAccept - val bonfireData = bonfireEntity.toGeary().get() ?: return@thenAccept + chunk.addPluginChunkTicket(bonfire.plugin) + val bonfireEntity = chunk.entities.filterIsBonfire().find { it.uniqueId == bonfireRespawn.bonfireUuid } + if (bonfireEntity == null) { + chunk.removePluginChunkTicket(bonfire.plugin) + return@thenAccept + } + val bonfireData = bonfireEntity.toGeary().get() + if (bonfireData == null) { + chunk.removePluginChunkTicket(bonfire.plugin) + return@thenAccept + } when { bonfireEntity.isBonfire && player.uniqueId in bonfireData.bonfirePlayers -> { @@ -72,6 +80,7 @@ class PlayerListener : Listener { player.toGeary().remove() } } + chunk.removePluginChunkTicket(bonfire.plugin) } }