/[projects]/miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SpawnCommand.java
ViewVC logotype

Annotation of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/SpawnCommand.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1849 - (hide annotations) (download)
Sun Sep 23 12:09:50 2012 UTC (11 years, 8 months ago) by torben
File size: 766 byte(s)
/spawn shoud place user at highest free block
1 torben 1848 package dk.thoerup.bukkit.hoeruputils;
2    
3     import org.bukkit.ChatColor;
4     import org.bukkit.Location;
5     import org.bukkit.World;
6     import org.bukkit.command.Command;
7     import org.bukkit.command.CommandExecutor;
8     import org.bukkit.command.CommandSender;
9     import org.bukkit.entity.Player;
10    
11     public class SpawnCommand implements CommandExecutor {
12    
13     @Override
14     public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
15    
16     if (!(sender instanceof Player)) { // it's not a console command
17     return false;
18     }
19    
20     Player p = (Player) sender;
21     Location spawn = p.getLocation().getWorld().getSpawnLocation();
22 torben 1849 int clearY = spawn.getWorld().getHighestBlockYAt( spawn );
23     spawn.setY( clearY );
24 torben 1848
25    
26     p.teleport( spawn );
27    
28     return true;
29     }
30     }

  ViewVC Help
Powered by ViewVC 1.1.20