mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-08 03:49:32 +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
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user