From 946b5c784335b748990dd835d8dd7a3e2d665473 Mon Sep 17 00:00:00 2001 From: Boy Date: Thu, 12 Sep 2024 21:18:28 +0200 Subject: [PATCH] fix: data not being handled correctly --- gradle.properties | 2 +- gradle/libs.versions.toml | 4 +-- .../mineinabyss/bonfire/BonfireCommands.kt | 29 +++++++++++-------- .../bonfire/listeners/BonfireListener.kt | 18 ++++++------ .../bonfire/listeners/DebugListener.kt | 12 -------- 5 files changed, 29 insertions(+), 36 deletions(-) diff --git a/gradle.properties b/gradle.properties index a867832..150d390 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=1.11 -idofrontVersion=0.24.23 +idofrontVersion=0.25.5 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cf8e17a..62e92c8 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -gearyPaper = "0.30.11" -blocky = "0.10.3" +gearyPaper = "0.30.17" +blocky = "0.10.6" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } diff --git a/src/main/kotlin/com/mineinabyss/bonfire/BonfireCommands.kt b/src/main/kotlin/com/mineinabyss/bonfire/BonfireCommands.kt index 849da03..f9f36ac 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/BonfireCommands.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/BonfireCommands.kt @@ -7,6 +7,7 @@ import com.mineinabyss.bonfire.components.BonfireRespawn import com.mineinabyss.bonfire.extensions.updateBonfireState import com.mineinabyss.geary.papermc.datastore.decode 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 @@ -34,16 +35,20 @@ object BonfireCommands { "bonfire" { "debug" { playerExecutes { - when { - player.toGeary().has() -> { - player.persistentDataContainer.remove() - sender.error("Bonfire debug mode disabled") - } - else -> { - player.persistentDataContainer.encode(BonfireDebug()) - sender.success("Bonfire debug mode enabled") + with(player.toGeary()) { + when { + has() -> { + remove() + sender.error("Bonfire debug mode disabled") + } + else -> { + setPersisting(BonfireDebug()) + sender.success("Bonfire debug mode enabled") + } } + encodeComponentsTo(player) } + } } "reload" { @@ -75,11 +80,11 @@ object BonfireCommands { suggestFiltering("${it.blockX} ${it.blockY} ${it.blockZ}") } } - executes { runPlayersCommand(location()?.resolve(context.source)?.toLocation(context.source.location.world)!!) } + executes { runPlayersCommand(location().toLocation(context.source.location.world)!!) } val world by ArgumentTypes.world().suggests { suggest(Bukkit.getWorlds().map { it.key.asString() }) } - executes { runPlayersCommand(location()?.resolve(context.source)?.toLocation(world()!!)!!) } + executes { runPlayersCommand(location().toLocation(world()!!)) } } "respawn" { val offlinePlayer by StringArgumentType.word() @@ -129,13 +134,13 @@ object BonfireCommands { } } executes { - handleRespawnSet(Bukkit.getOfflinePlayer(offlinePlayer()), location()!!.resolve(context.source).toLocation(context.source.location.world)) + handleRespawnSet(Bukkit.getOfflinePlayer(offlinePlayer()), location().toLocation(context.source.location.world)) } val world by ArgumentTypes.world().suggests { suggest(Bukkit.getWorlds().map { it.key.asString() }) } executes { - handleRespawnSet(Bukkit.getOfflinePlayer(offlinePlayer()), location()!!.resolve(context.source).toLocation(world()!!)) + handleRespawnSet(Bukkit.getOfflinePlayer(offlinePlayer()), location().toLocation(world()!!)) } } "remove" { diff --git a/src/main/kotlin/com/mineinabyss/bonfire/listeners/BonfireListener.kt b/src/main/kotlin/com/mineinabyss/bonfire/listeners/BonfireListener.kt index 641c6cc..85c5849 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/listeners/BonfireListener.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/listeners/BonfireListener.kt @@ -122,16 +122,16 @@ class BonfireListener : Listener { baseEntity.world.playSound(baseEntity.location, sound, volume, pitch) } - player.persistentDataContainer.encode(BonfireRespawn(baseEntity.uniqueId, baseEntity.location)) - player.persistentDataContainer.encode(BonfireEffectArea(baseEntity.uniqueId)) + gearyPlayer.setPersisting(BonfireRespawn(baseEntity.uniqueId, baseEntity.location)) + gearyPlayer.setPersisting(BonfireEffectArea(baseEntity.uniqueId)) player.success("Respawn point set") } } in bonfireData.bonfirePlayers -> { bonfireData.bonfirePlayers -= player.uniqueId - player.persistentDataContainer.remove() - player.persistentDataContainer.remove() + gearyPlayer.remove() + gearyPlayer.remove() with(bonfire.config.respawnUnsetSound) { baseEntity.world.playSound(baseEntity.location, sound, volume, pitch) } @@ -141,6 +141,7 @@ class BonfireListener : Listener { baseEntity.updateBonfireState() gearyBonfire.encodeComponentsTo(baseEntity) // Ensure data is saved to PDC + gearyPlayer.encodeComponentsTo(player) } } @@ -182,11 +183,10 @@ class BonfireListener : Listener { bonfireData.bonfirePlayers.map { it.toOfflinePlayer() }.forEach { p -> val onlinePlayer = p.player - if (onlinePlayer != null) { - val gearyEntity = onlinePlayer.toGeary() - gearyEntity.remove() - gearyEntity.remove() - gearyEntity.encodeComponentsTo(onlinePlayer) + if (onlinePlayer != null) with(onlinePlayer.toGeary()) { + remove() + remove() + encodeComponentsTo(onlinePlayer) } else { p.editOfflinePDC { encode(BonfireRemoved()) diff --git a/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt b/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt index e06aa0f..21a05ea 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt @@ -1,27 +1,17 @@ package com.mineinabyss.bonfire.listeners -import com.github.shynixn.mccoroutine.bukkit.asyncDispatcher -import com.github.shynixn.mccoroutine.bukkit.launch import com.mineinabyss.blocky.helpers.FurnitureUUID import com.mineinabyss.blocky.helpers.GenericHelpers.toBlockCenterLocation import com.mineinabyss.bonfire.bonfire import com.mineinabyss.bonfire.components.Bonfire import com.mineinabyss.bonfire.components.BonfireDebug -import com.mineinabyss.bonfire.extensions.filterIsBonfire import com.mineinabyss.bonfire.extensions.forEachBonfire -import com.mineinabyss.bonfire.extensions.isBonfire import com.mineinabyss.geary.papermc.tracking.entities.toGeary import com.mineinabyss.geary.papermc.tracking.entities.toGearyOrNull import com.mineinabyss.idofront.entities.toOfflinePlayer -import com.mineinabyss.idofront.nms.aliases.toNMS import com.mineinabyss.idofront.textcomponents.miniMsg import io.papermc.paper.adventure.PaperAdventure import it.unimi.dsi.fastutil.ints.IntList -import kotlinx.coroutines.delay -import kotlinx.coroutines.withContext -import net.kyori.adventure.text.minimessage.tag.Tag -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer import net.minecraft.network.chat.Component import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.network.protocol.game.ClientboundBundlePacket @@ -40,10 +30,8 @@ import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.player.PlayerGameModeChangeEvent -import org.bukkit.event.player.PlayerMoveEvent import org.bukkit.event.player.PlayerToggleSneakEvent import java.util.* -import kotlin.time.Duration.Companion.seconds class DebugListener : Listener {