diff --git a/plugin.yml b/plugin.yml index 7a22fa62..283ddec2 100644 --- a/plugin.yml +++ b/plugin.yml @@ -25,6 +25,9 @@ commands: description: Adjust protected regions usage: / ... aliases: rg, regions + locate: + description: Set your compass towards a person + usage: / reloadwg: description: Reload WorldGuard's configuration usage: / \ No newline at end of file diff --git a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java index 4ba080e2..5b25bf32 100644 --- a/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java +++ b/src/com/sk89q/worldguard/bukkit/WorldGuardPlugin.java @@ -36,6 +36,7 @@ import org.bukkit.command.Command; import org.bukkit.entity.Player; import org.bukkit.ChatColor; +import org.bukkit.Location; import org.bukkit.Server; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event; @@ -638,6 +639,45 @@ private boolean handleCommand(Player player, String cmd, String[] args) return true; } + if (cmd.equalsIgnoreCase("locate")) { + checkPermission(player, "locate"); + checkArgs(args, 0, 3); + + if (args.length == 2) { + String name = args[1]; + Player target = BukkitUtil.matchSinglePlayer(getServer(), name); + if (target != null) { + player.setCompassTarget(target.getLocation()); + player.sendMessage(ChatColor.YELLOW + "Compass target set to " + player.getName() + "."); + } else { + player.sendMessage(ChatColor.RED + "Could not find player."); + } + } else if (args.length == 4) { + try { + Location loc = new Location( + player.getWorld(), + Integer.parseInt(args[1]), + Integer.parseInt(args[2]), + Integer.parseInt(args[3]) + ); + player.setCompassTarget(loc); + player.sendMessage(ChatColor.YELLOW + "Compass target set to " + + loc.getBlockX() + "," + + loc.getBlockY() + "," + + loc.getBlockZ() + "."); + } catch (NumberFormatException e) { + player.sendMessage(ChatColor.RED + "Invalid number specified"); + } + } else if (args.length == 1) { + player.setCompassTarget(player.getWorld().getSpawnLocation()); + player.sendMessage(ChatColor.YELLOW + "Compass reset to the spawn location."); + } else { + return false; + } + + return true; + } + if (cmd.equalsIgnoreCase("region")) { checkArgs(args, 1, -1);