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 |
|
|
} |