Class RegexMatcher.Standard

java.lang.Object
com.samsthenerd.inline.api.matching.RegexMatcher.Standard
All Implemented Interfaces:
ContinuousMatcher, InlineMatcher, RegexMatcher
Direct Known Subclasses:
RegexMatcher.ChatStandard
Enclosing interface:
RegexMatcher

public static class RegexMatcher.Standard extends Object implements RegexMatcher
A helper class for regex matchers of the form [namespace:input]. Most built-in matchers use this.
  • Field Details

    • IDENTIFIER_REGEX

      public static String IDENTIFIER_REGEX
    • IDENTIFIER_REGEX_INSENSITIVE

      public static String IDENTIFIER_REGEX_INSENSITIVE
    • SEPARATORS_REGEX

      public static String SEPARATORS_REGEX
    • SEPARATOR_STYLES

      public static Map<String,UnaryOperator<net.minecraft.text.Style>> SEPARATOR_STYLES
  • Constructor Details

    • Standard

      public Standard(String namespace, String innerRegex, net.minecraft.util.Identifier id, Function<String,InlineMatch> matcher, MatcherInfo info)
      Constructs a simple regex matcher of the form [namespace:(inner)].
      Parameters:
      namespace - ideally follow Identifier/ResLoc rules for this
      innerRegex - regex pattern for the inner portion, generally input-like
      id - identifier for this matcher. mostly for config
      matcher - takes in whatever was matched by the innerRegex and returns an InlineMatch to attach to the entire match.
      info -
  • Method Details

    • getRegex

      public Pattern getRegex()
      Specified by:
      getRegex in interface RegexMatcher
    • getMatch

      public InlineMatch getMatch(MatchResult regexMatch, MatchContext matchContext)
      Description copied from interface: RegexMatcher
      Parses an InlineMatch out of the regexMatch.
      Specified by:
      getMatch in interface RegexMatcher
      Parameters:
      regexMatch - a single match from the provided regex.
      matchContext - a match context provided in-case it's needed. It generally won't be.
      Returns:
      InlineMatch that gets attached to the entire regex match or null for no match
    • getMatchAndGroup

      @NotNull public @NotNull net.minecraft.util.Pair<InlineMatch,Integer> getMatchAndGroup(MatchResult regexMatch, MatchContext matchContext)
      Description copied from interface: RegexMatcher
      Parses an InlineMatch out of the regexMatch and provides a group from the regexMatch for this match to be attached to. By default this will delegate to RegexMatcher.getMatch(java.util.regex.MatchResult, com.samsthenerd.inline.api.matching.MatchContext) and cover the entire regex match.
      Specified by:
      getMatchAndGroup in interface RegexMatcher
      Parameters:
      regexMatch - a single match from the provided regex
      matchContext - a match context provided in-case it's needed. It generally won't be.
      Returns:
      Pair of InlineMatch and the regex match group to attach it to. The match may be null, but the pair should not be.
    • getInfo

      public MatcherInfo getInfo()
      Description copied from interface: InlineMatcher
      Get info about this matcher.
      Specified by:
      getInfo in interface InlineMatcher
      Returns:
      matcher's info.
    • getId

      public net.minecraft.util.Identifier getId()
      Description copied from interface: InlineMatcher
      Get the ID for this matcher
      Specified by:
      getId in interface InlineMatcher
      Returns:
      matcher's ID