Open liorsl opened 3 months ago
public class LocationParser extends CompoundParser<Location> {
public LocationParser(int priority) {
super("location", Location.class, priority);
}
@ParserVariant("<world> <double> <double> <double>")
public Location serialize(World world, double x, double y, double z) {
return new Location(world, x, y, z);
}
@ParserVariant("<world> <double> <double> <double> <float> <float>")
public Location serialize(World world, double x, double y, double z, float yaw, float pitch) {
return new Location(world, x, y, z, yaw, pitch);
}
@SourceParser(keyword = "world", clazz = World.class)
public Map<String, World> getWorlds() {
return Bukkit.getWorlds().stream()
.collect(Collectors.toMap(
world -> world.getName(),
world -> world
));
}
}
Should be happen when we have the new argument mapper #190
So we can pass those values
Allow parsers to attempt to delegate parsing to another parser, for example:
Doing so will allow to reduce code duplication and making parsers more readable