diff --git a/src/main/java/pw/kaboom/extras/Commands.java b/src/main/java/pw/kaboom/extras/Commands.java index bfc4830..36745cb 100644 --- a/src/main/java/pw/kaboom/extras/Commands.java +++ b/src/main/java/pw/kaboom/extras/Commands.java @@ -258,12 +258,13 @@ class CommandSpawn implements CommandExecutor { World world = Bukkit.getWorld("world"); Location spawnLoc = world.getSpawnLocation(); - for (double y = spawnLoc.getY(); y <= 257; y++) { - Block coordBlock = world.getBlockAt(new Location(world, spawnLoc.getX(), y, spawnLoc.getZ())); + for (double y = spawnLoc.getY(); y <= 256; y++) { + Location yLoc = new Location(world, spawnLoc.getX(), y, spawnLoc.getZ()); + Block coordBlock = world.getBlockAt(yLoc); - if (coordBlock.getType() == Material.AIR && - coordBlock.getRelative(BlockFace.UP).getType() == Material.AIR) { - player.teleport(spawnLoc.add(0, y - spawnLoc.getY(), 0)); + if (coordBlock.getType().isTransparent() && + coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) { + player.teleport(yLoc); break; } } diff --git a/src/main/java/pw/kaboom/extras/Events.java b/src/main/java/pw/kaboom/extras/Events.java index 272a151..43cd4db 100644 --- a/src/main/java/pw/kaboom/extras/Events.java +++ b/src/main/java/pw/kaboom/extras/Events.java @@ -619,12 +619,13 @@ class Events implements Listener { World world = Bukkit.getWorld("world"); Location spawnLoc = world.getSpawnLocation(); - for (double y = spawnLoc.getY(); y <= 257; y++) { - Block coordBlock = world.getBlockAt(new Location(world, spawnLoc.getX(), y, spawnLoc.getZ())); + for (double y = spawnLoc.getY(); y <= 256; y++) { + Location yLoc = new Location(world, spawnLoc.getX(), y, spawnLoc.getZ()); + Block coordBlock = world.getBlockAt(yLoc); - if (coordBlock.getType() == Material.AIR && - coordBlock.getRelative(BlockFace.UP).getType() == Material.AIR) { - player.teleport(spawnLoc.add(0, y - spawnLoc.getY(), 0)); + if (coordBlock.getType().isTransparent() && + coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) { + player.teleport(yLoc); break; } }