Fixes for respawn system

This commit is contained in:
mathias 2019-06-16 03:55:08 +03:00
parent 75b12abe0b
commit be2cc420a2
2 changed files with 12 additions and 10 deletions

View file

@ -258,12 +258,13 @@ class CommandSpawn implements CommandExecutor {
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");
Location spawnLoc = world.getSpawnLocation(); Location spawnLoc = world.getSpawnLocation();
for (double y = spawnLoc.getY(); y <= 257; y++) { for (double y = spawnLoc.getY(); y <= 256; y++) {
Block coordBlock = world.getBlockAt(new Location(world, spawnLoc.getX(), y, spawnLoc.getZ())); Location yLoc = new Location(world, spawnLoc.getX(), y, spawnLoc.getZ());
Block coordBlock = world.getBlockAt(yLoc);
if (coordBlock.getType() == Material.AIR && if (coordBlock.getType().isTransparent() &&
coordBlock.getRelative(BlockFace.UP).getType() == Material.AIR) { coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
player.teleport(spawnLoc.add(0, y - spawnLoc.getY(), 0)); player.teleport(yLoc);
break; break;
} }
} }

View file

@ -619,12 +619,13 @@ class Events implements Listener {
World world = Bukkit.getWorld("world"); World world = Bukkit.getWorld("world");
Location spawnLoc = world.getSpawnLocation(); Location spawnLoc = world.getSpawnLocation();
for (double y = spawnLoc.getY(); y <= 257; y++) { for (double y = spawnLoc.getY(); y <= 256; y++) {
Block coordBlock = world.getBlockAt(new Location(world, spawnLoc.getX(), y, spawnLoc.getZ())); Location yLoc = new Location(world, spawnLoc.getX(), y, spawnLoc.getZ());
Block coordBlock = world.getBlockAt(yLoc);
if (coordBlock.getType() == Material.AIR && if (coordBlock.getType().isTransparent() &&
coordBlock.getRelative(BlockFace.UP).getType() == Material.AIR) { coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
player.teleport(spawnLoc.add(0, y - spawnLoc.getY(), 0)); player.teleport(yLoc);
break; break;
} }
} }