mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2025-02-09 17:02:20 +01:00
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:
parent
f4f4a47a7f
commit
9d5f349a04
@ -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.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user