mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 04:26:42 +00:00
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:
@ -46,10 +46,13 @@ public abstract class AbstractFactory<E> {
|
||||
* Create a new factory.
|
||||
*
|
||||
* @param worldEdit the WorldEdit instance
|
||||
* @param defaultParser the parser to fall back to
|
||||
*/
|
||||
protected AbstractFactory(WorldEdit worldEdit) {
|
||||
protected AbstractFactory(WorldEdit worldEdit, InputParser<E> defaultParser) {
|
||||
checkNotNull(worldEdit);
|
||||
checkNotNull(defaultParser);
|
||||
this.worldEdit = worldEdit;
|
||||
this.parsers.add(defaultParser);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -91,6 +94,6 @@ public abstract class AbstractFactory<E> {
|
||||
public void register(InputParser<E> inputParser) {
|
||||
checkNotNull(inputParser);
|
||||
|
||||
parsers.add(inputParser);
|
||||
parsers.add(parsers.size() - 1, inputParser);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user