Search in sources :

Example 1 with BiomeMask

use of com.sk89q.worldedit.function.mask.BiomeMask in project FastAsyncWorldEdit by IntellectualSites.

the class BiomeMaskParser method parseFromInput.

@Override
public Mask parseFromInput(String input, ParserContext context) throws InputParseException {
    if (!input.startsWith("$")) {
        return null;
    }
    // FAWE start - richer parsing
    if (input.charAt(1) == '[') {
        int end = input.lastIndexOf(']');
        if (end == -1) {
            return null;
        }
        input = input.substring(2, end);
    } else {
        input = input.substring(1);
    }
    // FAWE end
    Set<BiomeType> biomes = new HashSet<>();
    // FAWE start - richer parsing
    for (String biomeName : Splitter.on(",").split(input)) {
        // FAWE end
        BiomeType biome = BiomeType.REGISTRY.get(biomeName);
        if (biome == null) {
            throw new NoMatchException(Caption.of("worldedit.error.unknown-biome", TextComponent.of(biomeName)));
        }
        biomes.add(biome);
    }
    return new BiomeMask(context.requireExtent(), biomes);
}
Also used : BiomeType(com.sk89q.worldedit.world.biome.BiomeType) BiomeMask(com.sk89q.worldedit.function.mask.BiomeMask) NoMatchException(com.sk89q.worldedit.extension.input.NoMatchException) HashSet(java.util.HashSet)

Aggregations

NoMatchException (com.sk89q.worldedit.extension.input.NoMatchException)1 BiomeMask (com.sk89q.worldedit.function.mask.BiomeMask)1 BiomeType (com.sk89q.worldedit.world.biome.BiomeType)1 HashSet (java.util.HashSet)1