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
public Vector parseInput(WorldGuardPlugin plugin, CommandSender sender,
String input) throws InvalidFlagFormat {
public Vector parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
input = input.trim();
try {
return BukkitUtil.toVector(plugin.checkPlayer(sender).getLocation());
} catch (CommandException e) {
throw new InvalidFlagFormat(e.getMessage());
if ("here".equalsIgnoreCase(input)) {
try {
return BukkitUtil.toVector(plugin.checkPlayer(sender).getLocation());
} 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.");
}
}