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

public abstract class RichParser<E> extends InputParser<E> implements AliasedParser
A rich parser allows parsing of patterns and masks with extra arguments, e.g. #simplex[scale][pattern].
  • Constructor Details

    • RichParser

      protected RichParser(WorldEdit worldEdit, String... aliases)
      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

      public String getPrefix()
      Gives the default prefix/name of the pattern/mask/transform.
      Returns:
      default prefix
    • getMatchedAliases

      public List<String> getMatchedAliases()
      Return all prefix/name aliases of the pattern/mask/transform
      Specified by:
      getMatchedAliases in interface AliasedParser
      Returns:
      all prefix/name aliases
    • getSuggestions

      public Stream<String> getSuggestions(String input)
      Description copied from class: InputParser
      Gets a stream of suggestions of input to this parser.
      Overrides:
      getSuggestions in class InputParser<E>
      Returns:
      a stream of suggestions
    • parseFromInput

      public E parseFromInput(String input, ParserContext context) throws InputParseException
      Specified by:
      parseFromInput in class InputParser<E>
      Throws:
      InputParseException
    • getSuggestions

      protected abstract Stream<String> getSuggestions(String argumentInput, int index)
      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 containing Hello and World.
      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 - if requireClosing == true and the count of [ != the count of ]