Skip to content

Commit bace91d

Browse files
committed
fix: add chunk-ticket during respawn
1 parent 2a40a07 commit bace91d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/main/kotlin/com/mineinabyss/bonfire/listeners/PlayerListener.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,17 @@ class PlayerListener : Listener {
4949
val loc = bonfireRespawn.bonfireLocation
5050

5151
loc.world.getChunkAtAsyncUrgently(loc).thenAccept { chunk ->
52-
val bonfireEntity =
53-
chunk.entities.filterIsBonfire().find { it.uniqueId == bonfireRespawn.bonfireUuid } ?: return@thenAccept
54-
val bonfireData = bonfireEntity.toGeary().get<Bonfire>() ?: return@thenAccept
52+
chunk.addPluginChunkTicket(bonfire.plugin)
53+
val bonfireEntity = chunk.entities.filterIsBonfire().find { it.uniqueId == bonfireRespawn.bonfireUuid }
54+
if (bonfireEntity == null) {
55+
chunk.removePluginChunkTicket(bonfire.plugin)
56+
return@thenAccept
57+
}
58+
val bonfireData = bonfireEntity.toGeary().get<Bonfire>()
59+
if (bonfireData == null) {
60+
chunk.removePluginChunkTicket(bonfire.plugin)
61+
return@thenAccept
62+
}
5563

5664
when {
5765
bonfireEntity.isBonfire && player.uniqueId in bonfireData.bonfirePlayers -> {
@@ -72,6 +80,7 @@ class PlayerListener : Listener {
7280
player.toGeary().remove<BonfireRespawn>()
7381
}
7482
}
83+
chunk.removePluginChunkTicket(bonfire.plugin)
7584
}
7685
}
7786

0 commit comments

Comments
 (0)