1 |
torben |
1472 |
package dk.thoerup.bukkit.hoeruputils; |
2 |
|
|
|
3 |
|
|
import org.bukkit.Location; |
4 |
torben |
2093 |
import org.bukkit.World; |
5 |
torben |
1472 |
import org.bukkit.command.Command; |
6 |
|
|
import org.bukkit.command.CommandExecutor; |
7 |
|
|
import org.bukkit.command.CommandSender; |
8 |
|
|
import org.bukkit.entity.Player; |
9 |
|
|
|
10 |
|
|
public class GetposCommand implements CommandExecutor { |
11 |
|
|
|
12 |
|
|
@Override |
13 |
|
|
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
14 |
|
|
if (! (sender instanceof Player) ) { |
15 |
|
|
return false; |
16 |
|
|
} |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
Player p = (Player) sender; |
20 |
|
|
Location l = p.getLocation(); |
21 |
torben |
2093 |
|
22 |
|
|
World world = l.getWorld(); |
23 |
torben |
1472 |
|
24 |
torben |
2093 |
String worldMsg = "You are currently in world: " + world.getName(); |
25 |
|
|
p.sendMessage( worldMsg ); |
26 |
torben |
1476 |
|
27 |
torben |
2093 |
|
28 |
torben |
1474 |
String message = String.format("Your current location is %d,%d,%d", (int)l.getX(), (int)l.getY(), (int)l.getZ() ); |
29 |
torben |
1472 |
p.sendMessage(message); |
30 |
|
|
|
31 |
torben |
1476 |
//pitch is how much user is looking up/down |
32 |
|
|
//yaw is left,right looking direction, 0=straight west |
33 |
|
|
|
34 |
|
|
int compass = ( (int)l.getYaw() + 270) % 360; |
35 |
|
|
String compStr = WhereisCommand.getBearingStr(compass); |
36 |
|
|
p.sendMessage( String.format("Facing direction %d (%s)", compass, compStr ) ); |
37 |
|
|
// |
38 |
|
|
|
39 |
torben |
1472 |
// TODO Auto-generated method stub |
40 |
|
|
return true; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
} |