1 |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
3 |
import org.bukkit.Location; |
4 |
import org.bukkit.command.Command; |
5 |
import org.bukkit.command.CommandExecutor; |
6 |
import org.bukkit.command.CommandSender; |
7 |
import org.bukkit.entity.Player; |
8 |
|
9 |
public class SpawnCommand implements CommandExecutor { |
10 |
|
11 |
@Override |
12 |
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
13 |
|
14 |
if (!(sender instanceof Player)) { // it's not a console command |
15 |
return false; |
16 |
} |
17 |
|
18 |
Player p = (Player) sender; |
19 |
Location spawn = p.getLocation().getWorld().getSpawnLocation(); |
20 |
int clearY = spawn.getWorld().getHighestBlockYAt( spawn ); |
21 |
spawn.setY( clearY ); |
22 |
|
23 |
|
24 |
p.teleport( spawn ); |
25 |
|
26 |
return true; |
27 |
} |
28 |
} |