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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1476 - (hide annotations) (download)
Mon May 23 15:22:19 2011 UTC (13 years ago) by torben
File size: 1029 byte(s)
add facing direction
1 torben 1472 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 GetposCommand implements CommandExecutor {
10    
11     @Override
12     public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) {
13     if (! (sender instanceof Player) ) {
14     return false;
15     }
16    
17    
18     Player p = (Player) sender;
19     Location l = p.getLocation();
20    
21 torben 1476
22 torben 1474 String message = String.format("Your current location is %d,%d,%d", (int)l.getX(), (int)l.getY(), (int)l.getZ() );
23 torben 1472 p.sendMessage(message);
24    
25 torben 1476 //pitch is how much user is looking up/down
26     //yaw is left,right looking direction, 0=straight west
27    
28     int compass = ( (int)l.getYaw() + 270) % 360;
29     String compStr = WhereisCommand.getBearingStr(compass);
30     p.sendMessage( String.format("Facing direction %d (%s)", compass, compStr ) );
31     //
32    
33 torben 1472 // TODO Auto-generated method stub
34     return true;
35     }
36    
37     }

  ViewVC Help
Powered by ViewVC 1.1.20