Skip to content

Commit

Permalink
fix: add chunk-ticket during respawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Feb 7, 2025
1 parent 2a40a07 commit bace91d
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bonfire>() ?: 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<Bonfire>()
if (bonfireData == null) {
chunk.removePluginChunkTicket(bonfire.plugin)
return@thenAccept
}

when {
bonfireEntity.isBonfire && player.uniqueId in bonfireData.bonfirePlayers -> {
Expand All @@ -72,6 +80,7 @@ class PlayerListener : Listener {
player.toGeary().remove<BonfireRespawn>()
}
}
chunk.removePluginChunkTicket(bonfire.plugin)
}
}

Expand Down

0 comments on commit bace91d

Please sign in to comment.