Class TokenParser
java.lang.Object
net.kyori.adventure.text.minimessage.internal.parser.TokenParser
Handles parsing a string into a list of tokens and then into a tree of nodes.
- Since:
- 4.10.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceNormalizing provider for tag information. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic RootNodeparse(TokenParser.TagProvider tagProvider, Predicate<String> tagNameChecker, String message, String originalMessage, boolean strict) Parse a minimessage string into a tree of nodes.static voidparseString(String message, boolean lenient, MatchedTokenConsumer<?> consumer) Parses a string, providing information on matched tokens to the matched token consumer.static StringresolvePreProcessTags(String message, TokenParser.TagProvider provider) Resolves all pre-process tags in a string.Tokenize a minimessage string into a list of tokens.static Stringunescape(String text, int startIndex, int endIndex, IntPredicate escapes) Removes escaping'\`characters from a substring where the subsequent character matches a given predicate.
-
Field Details
-
TAG_START
public static final char TAG_START- See Also:
-
TAG_END
public static final char TAG_END- See Also:
-
CLOSE_TAG
public static final char CLOSE_TAG- See Also:
-
SEPARATOR
public static final char SEPARATOR- See Also:
-
ESCAPE
public static final char ESCAPE- See Also:
-
-
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 informationtagNameChecker- checker for tag names, performing necessary tag normalizationmessage- the minimessage string to parse, after processing for preprocess tagsoriginalMessage- the string to parse, before preprocess tagsstrict- 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
Resolves all pre-process tags in a string.- Parameters:
message- the messageprovider- the tag resolver, to gather preprocess tags- Returns:
- the resulting string
- Since:
- 4.10.0
-
tokenize
Tokenize a minimessage string into a list of tokens.- Parameters:
message- the minimessage string to parselenient- whether to allow section symbols (for escaping/stripping/non-actual-parse stuff only)- Returns:
- the root tokens
- Since:
- 4.10.0
-
parseString
Parses a string, providing information on matched tokens to the matched token consumer.- Parameters:
message- the messagelenient- whether to allow section symbolsconsumer- the consumer- Since:
- 4.10.0
-
unescape
Removes escaping'\`characters from a substring where the subsequent character matches a given predicate.- Parameters:
text- the input textstartIndex- the starting index of the substringendIndex- the ending index of the substringescapes- the predicate to determine if an escape happened- Returns:
- the output escaped substring
- Since:
- 4.10.0
-