Skip to content

Commit

Permalink
Write players to PDC immediately on update
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed Dec 27, 2023
1 parent 8529a9b commit 9291b4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gradle/bfLibs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
gearyPaper = "0.28.0"
gearyPaper = "0.28.4"
blocky = "0.8.17"
protocolburrito = "0.8.0"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import com.mineinabyss.bonfire.extensions.removeOldBonfire
import com.mineinabyss.bonfire.extensions.updateBonfireState
import com.mineinabyss.geary.helpers.with
import com.mineinabyss.geary.papermc.datastore.encode
import com.mineinabyss.geary.papermc.datastore.encodeComponentsTo
import com.mineinabyss.geary.papermc.datastore.remove
import com.mineinabyss.geary.papermc.tracking.entities.toGeary
import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull
Expand Down Expand Up @@ -86,7 +87,8 @@ class BonfireListener : Listener {
if (!player.isSneaking || player.toGeary().has<BonfireCooldown>()) return
if (hand != EquipmentSlot.HAND || abs(0 - player.velocity.y) < 0.001) return

baseEntity.toGearyOrNull()?.with { bonfireData: Bonfire ->
val gearyEntity = baseEntity.toGearyOrNull()
gearyEntity?.with { bonfireData: Bonfire ->
when (player.uniqueId) {
!in bonfireData.bonfirePlayers -> {
if (bonfireData.bonfirePlayers.size >= bonfireData.maxPlayerCount) player.error(bonfire.messages.BONFIRE_FULL)
Expand Down Expand Up @@ -116,6 +118,7 @@ class BonfireListener : Listener {
}

baseEntity.updateBonfireState()
gearyEntity.encodeComponentsTo(baseEntity) // Ensure data is saved to PDC

player.toGeary().set(BonfireCooldown(baseEntity.uniqueId))
bonfire.plugin.launch {
Expand Down

0 comments on commit 9291b4d

Please sign in to comment.