diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ec68197..be5c0e6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] gearyPaper = "0.30.1" -blocky = "0.9.13-dev.13" +blocky = "0.9.13-dev.22" [libraries] geary-papermc = { module = "com.mineinabyss:geary-papermc", version.ref = "gearyPaper" } diff --git a/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt b/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt index 346963e..7887d38 100644 --- a/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt +++ b/src/main/kotlin/com/mineinabyss/bonfire/listeners/DebugListener.kt @@ -29,11 +29,14 @@ import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.phys.Vec3 import org.bukkit.Color +import org.bukkit.GameMode import org.bukkit.craftbukkit.entity.CraftPlayer import org.bukkit.entity.ItemDisplay 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 @@ -42,13 +45,30 @@ class DebugListener : Listener { @EventHandler fun PlayerToggleSneakEvent.onDebugToggle() { - player.toGeary().has() || return - player.getNearbyEntities(10.0,10.0,10.0).filterIsInstance().filter { it.isBonfire }.forEach { + if (!player.toGeary().has()) return + player.getNearbyEntities(16.0, 16.0, 16.0).filterIsInstance().filter { it.isBonfire }.forEach { if (isSneaking) player.sendDebugTextDisplay(it) else removeDebugTextDisplay(player) } } + @EventHandler + fun PlayerGameModeChangeEvent.onDebugToggle() { + if (!player.toGeary().has()) return + player.getNearbyEntities(16.0, 16.0, 16.0).filterIsInstance().filter { it.isBonfire }.forEach { + if (newGameMode == GameMode.SPECTATOR) player.sendDebugTextDisplay(it) + else removeDebugTextDisplay(player) + } + } + + @EventHandler + fun PlayerMoveEvent.onDebugToggle() { + if (player.gameMode != GameMode.SPECTATOR || !player.toGeary().has()) return + player.getNearbyEntities(16.0, 16.0, 16.0).filterIsInstance().filter { it.isBonfire }.forEach { + player.sendDebugTextDisplay(it) + } + } + private val debugIdMap = mutableMapOf>() private fun Player.sendDebugTextDisplay(baseEntity: ItemDisplay) { val entityIds = debugIdMap.computeIfAbsent(uniqueId) { mutableMapOf(baseEntity.uniqueId to Entity.nextEntityId()) }