diff --git a/src/main/kotlin/net/hareworks/on_join_spawn/App.kt b/src/main/kotlin/net/hareworks/on_join_spawn/App.kt index 9f0874d..9560c8b 100644 --- a/src/main/kotlin/net/hareworks/on_join_spawn/App.kt +++ b/src/main/kotlin/net/hareworks/on_join_spawn/App.kt @@ -26,7 +26,19 @@ class App : JavaPlugin(), Listener { } // Get the world's spawn location - val spawnLocation = player.world.spawnLocation + val spawnLocation = player.world.spawnLocation.clone() + + // Add 0.5 to X and Z coordinates if they are whole numbers + // This centers the player on the block + val x = spawnLocation.x + val z = spawnLocation.z + + if (x == x.toInt().toDouble()) { + spawnLocation.x = x + 0.5 + } + if (z == z.toInt().toDouble()) { + spawnLocation.z = z + 0.5 + } // Teleport player to spawn immediately // This happens before the player is fully loaded into the world