use of com.sk89q.worldedit.function.pattern.RandomStatePattern in project FastAsyncWorldEdit by IntellectualSites.
the class RandomStatePatternParser method parseFromInput.
@Override
public Pattern parseFromInput(String input, ParserContext context) throws InputParseException {
if (!input.startsWith("*")) {
return null;
}
boolean wasFuzzy = context.isPreferringWildcard();
context.setPreferringWildcard(true);
BaseBlock block = worldEdit.getBlockFactory().parseFromInput(input.substring(1), context);
context.setPreferringWildcard(wasFuzzy);
if (block.getStates().size() == block.getBlockType().getPropertyMap().size()) {
// they requested random with *, but didn't leave any states empty - simplify
return block;
} else if (block.toImmutableState() instanceof FuzzyBlockState) {
return new RandomStatePattern((FuzzyBlockState) block.toImmutableState());
} else {
// only should happen if parseLogic changes
return null;
}
}
Aggregations