Class RichParser<E>
java.lang.Object
com.sk89q.worldedit.internal.registry.InputParser<E>
com.fastasyncworldedit.core.extension.factory.parser.RichParser<E>
- Type Parameters:
E
- the parse result.
- All Implemented Interfaces:
AliasedParser
- Direct Known Subclasses:
AdjacentMaskParser
,AngleColorPatternParser
,AngleMaskParser
,AverageColorPatternParser
,BesideMaskParser
,BiomePatternParser
,BufferedPattern2DParser
,BufferedPatternParser
,ColorPatternParser
,DesaturatePatternParser
,ExtremaMaskParser
,Linear2DPatternParser
,Linear3DPatternParser
,Linear3DTransformParser
,LinearPatternParser
,LinearTransformParser
,MaskedPatternParser
,NoisePatternParser
,NoXPatternParser
,NoYPatternParser
,NoZPatternParser
,OffsetPatternParser
,OffsetTransformParser
,PatternTransformParser
,RadiusMaskParser
,RandomFullClipboardPatternParser
,RandomOffsetPatternParser
,RelativePatternParser
,RichOffsetMaskParser
,ROCAngleMaskParser
,RotateTransformParser
,SaturatePatternParser
,ScaleTransformParser
,SimplexMaskParser
,SolidRandomOffsetPatternParser
,SpreadTransformParser
,SurfaceAngleMaskParser
,SurfaceRandomOffsetPatternParser
A rich parser allows parsing of patterns and masks with extra arguments,
e.g. #simplex[scale][pattern].
-
Field Summary
Fields inherited from class com.sk89q.worldedit.internal.registry.InputParser
worldEdit
-
Constructor Summary
ModifierConstructorDescriptionprotected
RichParser
(WorldEdit worldEdit, String... aliases) Create a new rich parser with a defined prefix for the result, e.g. -
Method Summary
Modifier and TypeMethodDescriptionprotected String[]
extractArguments
(String input, boolean requireClosing) Extracts arguments enclosed by[]
into an array.Return all prefix/name aliases of the pattern/mask/transformGives the default prefix/name of the pattern/mask/transform.getSuggestions
(String input) Gets a stream of suggestions of input to this parser.getSuggestions
(String argumentInput, int index) Returns a stream of suggestions for the argument at the given index.protected abstract E
parseFromInput
(String[] arguments, ParserContext context) Parses the already split arguments.parseFromInput
(String input, ParserContext context)
-
Constructor Details
-
RichParser
Create a new rich parser with a defined prefix for the result, e.g.#simplex
.- Parameters:
worldEdit
- the worldedit instance.aliases
- the prefix of this parser result.
-
-
Method Details
-
getPrefix
Gives the default prefix/name of the pattern/mask/transform.- Returns:
- default prefix
-
getMatchedAliases
Return all prefix/name aliases of the pattern/mask/transform- Specified by:
getMatchedAliases
in interfaceAliasedParser
- Returns:
- all prefix/name aliases
-
getSuggestions
Description copied from class:InputParser
Gets a stream of suggestions of input to this parser.- Overrides:
getSuggestions
in classInputParser<E>
- Returns:
- a stream of suggestions
-
parseFromInput
- Specified by:
parseFromInput
in classInputParser<E>
- Throws:
InputParseException
-
getSuggestions
Returns a stream of suggestions for the argument at the given index.- Parameters:
argumentInput
- the already provided input for the argument at the given index.index
- the index of the argument to get suggestions for.- Returns:
- a stream of suggestions matching the given input for the argument at the given index.
-
parseFromInput
protected abstract E parseFromInput(@Nonnull String[] arguments, ParserContext context) throws InputParseException Parses the already split arguments.- Parameters:
arguments
- the array of arguments that were split (can be empty).context
- the context of this parsing process.- Returns:
- the resulting parsed type.
- Throws:
InputParseException
- if the input couldn't be parsed correctly.
-
extractArguments
protected String[] extractArguments(String input, boolean requireClosing) throws InputParseException Extracts arguments enclosed by[]
into an array. Example:[Hello][World]
results in a list containingHello
andWorld
.- Parameters:
input
- the input to extract arguments from.requireClosing
- whether or not the extraction requires valid bracketing.- Returns:
- an array of extracted arguments.
- Throws:
InputParseException
- ifrequireClosing == true
and the count of [ != the count of ]
-