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

Diff of /miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/WhereisCommand.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

miscJava/bukkit-minecraft-plugins/HoerupUtils/src/dk/thoerup/bukkit/hoeruputils/WhereisCommand.java revision 1470 by torben, Wed May 18 19:08:29 2011 UTC miscJava/bukkit-minecraft-plugins/HoerupUtils/src/main/java/dk/thoerup/bukkit/hoeruputils/WhereisCommand.java revision 2432 by torben, Mon Mar 9 13:55:54 2015 UTC
# Line 19  public class WhereisCommand implements C Line 19  public class WhereisCommand implements C
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) {
# Line 36  public class WhereisCommand implements C Line 34  public class WhereisCommand implements C
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    

Legend:
Removed from v.1470  
changed lines
  Added in v.2432

  ViewVC Help
Powered by ViewVC 1.1.20