Class TokenParser

java.lang.Object
net.kyori.adventure.text.minimessage.internal.parser.TokenParser

@Internal public final class TokenParser extends Object
Handles parsing a string into a list of tokens and then into a tree of nodes.
Since:
4.10.0
  • Field Details

  • Method Details

    • parse

      public static RootNode parse(TokenParser.TagProvider tagProvider, Predicate<String> tagNameChecker, String message, String originalMessage, boolean strict) throws ParsingException
      Parse a minimessage string into a tree of nodes.
      Parameters:
      tagProvider - provides tags based on the available information
      tagNameChecker - checker for tag names, performing necessary tag normalization
      message - the minimessage string to parse, after processing for preprocess tags
      originalMessage - the string to parse, before preprocess tags
      strict - whether parsing in strict mode
      Returns:
      the root of the resulting tree
      Throws:
      ParsingException - if invalid input is provided when in strict mode
      Since:
      4.10.0
    • resolvePreProcessTags

      public static String resolvePreProcessTags(String message, TokenParser.TagProvider provider)
      Resolves all pre-process tags in a string.
      Parameters:
      message - the message
      provider - the tag resolver, to gather preprocess tags
      Returns:
      the resulting string
      Since:
      4.10.0
    • tokenize

      public static List<Token> tokenize(String message, boolean lenient)
      Tokenize a minimessage string into a list of tokens.
      Parameters:
      message - the minimessage string to parse
      lenient - whether to allow section symbols (for escaping/stripping/non-actual-parse stuff only)
      Returns:
      the root tokens
      Since:
      4.10.0
    • parseString

      public static void parseString(String message, boolean lenient, MatchedTokenConsumer<?> consumer)
      Parses a string, providing information on matched tokens to the matched token consumer.
      Parameters:
      message - the message
      lenient - whether to allow section symbols
      consumer - the consumer
      Since:
      4.10.0
    • unescape

      public static String unescape(String text, int startIndex, int endIndex, IntPredicate escapes)
      Removes escaping '\` characters from a substring where the subsequent character matches a given predicate.
      Parameters:
      text - the input text
      startIndex - the starting index of the substring
      endIndex - the ending index of the substring
      escapes - the predicate to determine if an escape happened
      Returns:
      the output escaped substring
      Since:
      4.10.0