Give factories a default parser.

Later registered parsers will always come before the default, ensuring
that the default parser is used when no other parser can match the input,
and that errors may be thrown by it to signify the end of the line.
This commit is contained in:
wizjany
2019-05-27 00:35:26 -04:00
parent 6962b2e7b6
commit ab1e09fdaf
6 changed files with 12 additions and 16 deletions

View File

@ -54,6 +54,8 @@ import java.util.Locale;
import java.util.Map;
import java.util.stream.Stream;
import static org.enginehub.piston.converter.SuggestionHelper.limitByPrefix;
/**
* Parses block input strings.
*/
@ -209,7 +211,7 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (input.contains(",")) {
return Stream.empty();
}
return BlockType.REGISTRY.keySet().stream();
return limitByPrefix(BlockType.REGISTRY.keySet().stream(), input).stream();
}
String blockType = input.substring(0, idx);
BlockType type = BlockTypes.get(blockType.toLowerCase(Locale.ROOT));