}
@Override
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
BlockFactory blockRegistry = worldEdit.getBlockFactory();
RandomPattern randomPattern = new RandomPattern();
for (String token : input.split(",")) {
BaseBlock block;
double chance;
// Parse special percentage syntax
if (token.matches("[0-9]+(\\.[0-9]*)?%.*")) {
String[] p = token.split("%");
if (p.length < 2) {
throw new InputParseException("Missing the type after the % symbol for '" + input + "'");
} else {
chance = Double.parseDouble(p[0]);
block = blockRegistry.parseFromInput(p[1], context);
}
} else {
chance = 1;
block = blockRegistry.parseFromInput(token, context);
}
randomPattern.add(new BlockPattern(block), chance);
}
return randomPattern;
}