Interface TextReplacementConfig.Builder

    • Method Detail

      • matchLiteral

        @Contract("_ -> this")
        default TextReplacementConfig.Builder matchLiteral​(String literal)
        Match against the literal string provided.

        This will NOT be parsed as a regular expression.

        Parameters:
        literal - the literal string to match
        Returns:
        this builder
        Since:
        4.2.0
      • match

        @Contract("_ -> this")
        @NotNull
        default @NotNull TextReplacementConfig.Builder match​(@NotNull
                                                             @NotNull String pattern)
        Compile the provided input as a Pattern and match against it.
        Parameters:
        pattern - the regex pattern to match
        Returns:
        this builder
        Since:
        4.2.0
      • match

        @Contract("_ -> this")
        @NotNull
        @NotNull TextReplacementConfig.Builder match​(@NotNull
                                                     @NotNull Pattern pattern)
        Match the provided Pattern.
        Parameters:
        pattern - pattern to find in any searched components
        Returns:
        this builder
        Since:
        4.2.0
      • once

        @NotNull
        default @NotNull TextReplacementConfig.Builder once()
        Only replace the first occurrence of the matched pattern.
        Returns:
        this builder
        Since:
        4.2.0
      • times

        @Contract("_ -> this")
        @NotNull
        default @NotNull TextReplacementConfig.Builder times​(int times)
        Only replace the first times matches of the pattern.
        Parameters:
        times - maximum amount of matches to process
        Returns:
        this builder
        Since:
        4.2.0
      • condition

        @Contract("_ -> this")
        @NotNull
        default @NotNull TextReplacementConfig.Builder condition​(@NotNull
                                                                 @NotNull IntFunction2<PatternReplacementResult> condition)
        Set the function to determine how an individual match should be processed.
        Parameters:
        condition - a function of (matchCount, replaced) used to determine if matches should be replaced, where "matchCount" is the number of matches that have been found, including the current one, and "replaced" is the number of successful replacements.
        Returns:
        this builder
        Since:
        4.2.0
      • replacement

        @Contract("_ -> this")
        @NotNull
        default @NotNull TextReplacementConfig.Builder replacement​(@NotNull
                                                                   @NotNull String replacement)
        Supply a literal replacement for the matched pattern.
        Parameters:
        replacement - the replacement
        Returns:
        this builder
        Since:
        4.2.0
      • replacement

        @Contract("_ -> this")
        @NotNull
        default @NotNull TextReplacementConfig.Builder replacement​(@Nullable
                                                                   @Nullable ComponentLike replacement)
        Supply a literal replacement for the matched pattern.
        Parameters:
        replacement - the replacement
        Returns:
        this builder
        Since:
        4.2.0
      • replacement

        @Contract("_ -> this")
        @NotNull
        @NotNull TextReplacementConfig.Builder replacement​(@NotNull
                                                           @NotNull BiFunction<MatchResult,​TextComponent.Builder,​@Nullable ComponentLike> replacement)
        Supply a function that provides replacements for each match, with access to group information.
        Parameters:
        replacement - the replacement function, taking a match result and a text component pre-populated with
        Returns:
        this builder
        Since:
        4.2.0