Skip to content

Commit

Permalink
fix: data not being handled correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Sep 12, 2024
1 parent 5218d9f commit 946b5c7
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 36 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=1.11
idofrontVersion=0.24.23
idofrontVersion=0.25.5
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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" }
Expand Down
29 changes: 17 additions & 12 deletions src/main/kotlin/com/mineinabyss/bonfire/BonfireCommands.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -34,16 +35,20 @@ object BonfireCommands {
"bonfire" {
"debug" {
playerExecutes {
when {
player.toGeary().has<BonfireDebug>() -> {
player.persistentDataContainer.remove<BonfireDebug>()
sender.error("Bonfire debug mode disabled")
}
else -> {
player.persistentDataContainer.encode(BonfireDebug())
sender.success("Bonfire debug mode enabled")
with(player.toGeary()) {
when {
has<BonfireDebug>() -> {
remove<BonfireDebug>()
sender.error("Bonfire debug mode disabled")
}
else -> {
setPersisting(BonfireDebug())
sender.success("Bonfire debug mode enabled")
}
}
encodeComponentsTo(player)
}

}
}
"reload" {
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<BonfireRespawn>()
player.persistentDataContainer.remove<BonfireEffectArea>()
gearyPlayer.remove<BonfireRespawn>()
gearyPlayer.remove<BonfireEffectArea>()
with(bonfire.config.respawnUnsetSound) {
baseEntity.world.playSound(baseEntity.location, sound, volume, pitch)
}
Expand All @@ -141,6 +141,7 @@ class BonfireListener : Listener {

baseEntity.updateBonfireState()
gearyBonfire.encodeComponentsTo(baseEntity) // Ensure data is saved to PDC
gearyPlayer.encodeComponentsTo(player)
}
}

Expand Down Expand Up @@ -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<BonfireEffectArea>()
gearyEntity.remove<BonfireRespawn>()
gearyEntity.encodeComponentsTo(onlinePlayer)
if (onlinePlayer != null) with(onlinePlayer.toGeary()) {
remove<BonfireEffectArea>()
remove<BonfireRespawn>()
encodeComponentsTo(onlinePlayer)
} else {
p.editOfflinePDC {
encode(BonfireRemoved())
Expand Down
12 changes: 0 additions & 12 deletions src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 {

Expand Down

0 comments on commit 946b5c7

Please sign in to comment.