From be2cc420a21eadb42b734bfed07ccf6b06752f1e Mon Sep 17 00:00:00 2001 From: mathias Date: Sun, 16 Jun 2019 03:55:08 +0300 Subject: [PATCH] Fixes for respawn system --- src/main/java/pw/kaboom/extras/Commands.java | 11 ++++++----- src/main/java/pw/kaboom/extras/Events.java | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) 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; } }