Vector flags can now be set to the current location with the value "here" and to a specific position with x,y,z.

This commit is contained in:
TomyLobo 2012-03-11 18:55:26 +01:00
parent f4f4a47a7f
commit 9d5f349a04

View File

@ -43,14 +43,29 @@ public VectorFlag(String name) {
} }
@Override @Override
public Vector parseInput(WorldGuardPlugin plugin, CommandSender sender, public Vector parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
String input) throws InvalidFlagFormat {
input = input.trim(); input = input.trim();
try { if ("here".equalsIgnoreCase(input)) {
return BukkitUtil.toVector(plugin.checkPlayer(sender).getLocation()); try {
} catch (CommandException e) { return BukkitUtil.toVector(plugin.checkPlayer(sender).getLocation());
throw new InvalidFlagFormat(e.getMessage()); } catch (CommandException e) {
throw new InvalidFlagFormat(e.getMessage());
}
} else {
String[] split = input.split(",");
if (split.length == 3) {
try {
return new Vector(
Double.parseDouble(split[0]),
Double.parseDouble(split[1]),
Double.parseDouble(split[2])
);
} catch (NumberFormatException e) {
}
}
throw new InvalidFlagFormat("Expected 'here' or x,y,z.");
} }
} }