mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-23 16:08:18 -05:00
Check if bed respawn location exists
This commit is contained in:
parent
be2cc420a2
commit
6a7efad7b6
1 changed files with 13 additions and 9 deletions
|
@ -616,17 +616,21 @@ class Events implements Listener {
|
|||
player.getLastDamageCause().getCause() != DamageCause.SUICIDE) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
|
||||
public void run() {
|
||||
World world = Bukkit.getWorld("world");
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (player.getBedSpawnLocation() != null) {
|
||||
player.teleport(player.getBedSpawnLocation());
|
||||
} else {
|
||||
World world = Bukkit.getWorld("world");
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
|
||||
for (double y = spawnLoc.getY(); y <= 256; y++) {
|
||||
Location yLoc = new Location(world, spawnLoc.getX(), y, spawnLoc.getZ());
|
||||
Block coordBlock = world.getBlockAt(yLoc);
|
||||
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().isTransparent() &&
|
||||
coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
|
||||
player.teleport(yLoc);
|
||||
break;
|
||||
if (coordBlock.getType().isTransparent() &&
|
||||
coordBlock.getRelative(BlockFace.UP).getType().isTransparent()) {
|
||||
player.teleport(yLoc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue