Interface TextReplacementConfig.Builder
- All Superinterfaces:
AbstractBuilder<TextReplacementConfig>
- Enclosing interface:
TextReplacementConfig
public static sealed interface TextReplacementConfig.Builder
extends AbstractBuilder<TextReplacementConfig>
A builder for replacement configurations.
- Since:
- 4.2.0
-
Method Summary
Modifier and TypeMethodDescriptioncondition(TextReplacementConfig.Condition condition) Set the function to determine how an individual match should be processed.default TextReplacementConfig.Buildercondition(IntFunction2<PatternReplacementResult> condition) Set the function to determine how an individual match should be processed.default TextReplacementConfig.BuilderCompile the provided input as aPatternand set it as the match to test against.Match the providedPattern.default TextReplacementConfig.BuildermatchLiteral(String literal) Set this builder to match only the literal string provided.default TextReplacementConfig.Builderonce()Only replace the first occurrence of the matched pattern.replaceInsideHoverEvents(boolean replace) Set if the replacement should replace insidehover events.default TextReplacementConfig.Builderreplacement(String replacement) Supply a literal replacement for the matched pattern.replacement(BiFunction<MatchResult, TextComponent.Builder, @Nullable ComponentLike> replacement) Supply a function that provides replacements for each match, with access to group information.default TextReplacementConfig.Builderreplacement(Function<TextComponent.Builder, @Nullable ComponentLike> replacement) Supply a function that provides replacements for each match.default TextReplacementConfig.Builderreplacement(@Nullable ComponentLike replacement) Supply a literal replacement for the matched pattern.default TextReplacementConfig.Buildertimes(int times) Only replace the firsttimesmatches of the pattern.Methods inherited from interface AbstractBuilder
build
-
Method Details
-
matchLiteral
Set this builder to match only 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
Compile the provided input as aPatternand set it as the match to test against.- Parameters:
pattern- the regex pattern to match- Returns:
- this builder
- Since:
- 4.2.0
-
match
Match the providedPattern.- Parameters:
pattern- pattern to find in any searched components- Returns:
- this builder
- Since:
- 4.2.0
-
once
Only replace the first occurrence of the matched pattern.- Returns:
- this builder
- Since:
- 4.2.0
-
times
Only replace the firsttimesmatches of the pattern.- Parameters:
times- maximum amount of matches to process- Returns:
- this builder
- Since:
- 4.2.0
-
condition
@Contract("_ -> this") default TextReplacementConfig.Builder condition(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
-
condition
@Contract("_ -> this") TextReplacementConfig.Builder condition(TextReplacementConfig.Condition condition) Set the function to determine how an individual match should be processed.- Parameters:
condition- a function that determines whether a replacement should occur- Returns:
- this builder
- Since:
- 4.8.0
- See Also:
-
replacement
Supply a literal replacement for the matched pattern.- Parameters:
replacement- the replacement- Returns:
- this builder
- Since:
- 4.2.0
-
replacement
@Contract("_ -> this") default TextReplacementConfig.Builder replacement(@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") default TextReplacementConfig.Builder replacement(Function<TextComponent.Builder, @Nullable ComponentLike> replacement) Supply a function that provides replacements for each match.- Parameters:
replacement- the replacement function- Returns:
- this builder
- Since:
- 4.2.0
-
replacement
@Contract("_ -> this") TextReplacementConfig.Builder replacement(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
-
replaceInsideHoverEvents
Set if the replacement should replace insidehover events.This defaults to
true.- Parameters:
replace- if it should replace inside hover events- Returns:
- this builder
- Since:
- 4.19.0
-