Added /locate.

This commit is contained in:
sk89q 2011-01-20 01:54:47 -08:00
parent 6046f4defc
commit b43881c299
2 changed files with 43 additions and 0 deletions

View File

@ -25,6 +25,9 @@ commands:
description: Adjust protected regions
usage: /<command> <define|claim|flag|delete|info|addowner|removeowner|list|save|load> ...
aliases: rg, regions
locate:
description: Set your compass towards a person
usage: /<command> <target>
reloadwg:
description: Reload WorldGuard's configuration
usage: /<command>

View File

@ -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);