19 |
@Override |
@Override |
20 |
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
public boolean onCommand(final CommandSender sender, Command command, String label, String[] args) { |
21 |
|
|
22 |
if (!(sender instanceof Player)) { |
|
|
sender.sendMessage("Whereis: What are you"); |
|
|
return true; |
|
|
} |
|
23 |
|
|
24 |
if (args.length != 1) { |
if (args.length != 1) { |
25 |
sender.sendMessage("Usage: /whereis <playername>"); |
sender.sendMessage("Usage: /whereis <playername>"); |
26 |
return true; |
return true; |
27 |
} |
} |
28 |
|
|
29 |
|
@SuppressWarnings("deprecation")//user by name is our only option here |
30 |
Player target = server.getPlayer(args[0]); |
Player target = server.getPlayer(args[0]); |
31 |
|
|
32 |
if (target == null) { |
if (target == null) { |
34 |
return true; |
return true; |
35 |
} |
} |
36 |
|
|
37 |
Location targetLoc = target.getLocation(); |
Location targetLoc = target.getLocation(); |
38 |
Player player = (Player) sender; |
Player player = (Player) sender; |
39 |
|
|
40 |
|
if (player.getLocation().getWorld() != targetLoc.getWorld()) { |
41 |
|
sender.sendMessage("Whereis: player " + args[0] + " is in another world: " + targetLoc.getWorld().getName() ); |
42 |
|
return true; |
43 |
|
} |
44 |
|
|
45 |
int dist = calcDistance(player.getLocation(), targetLoc); |
int dist = calcDistance(player.getLocation(), targetLoc); |
46 |
int bearing = calcBearing(player.getLocation(), targetLoc); |
int bearing = calcBearing(player.getLocation(), targetLoc); |
47 |
|
|