public class TextUtils
extends java.lang.Object
| Constructor | Description |
|---|---|
TextUtils() |
| Modifier and Type | Method | Description |
|---|---|---|
static void |
iterateAll(TextComponent component,
java.util.function.Consumer<TextComponent> consumer) |
Iterate over all siblings of the given component.
|
static TextComponent |
join(TextComponent separator,
TextComponent... components) |
Join the given components with the given separator.
|
static TextComponent |
makeURLsClickable(TextComponent component) |
Make URLs in the given text component clickable.
|
static TextComponent |
replace(TextComponent component,
java.util.function.Function<TextComponent,TextComponent> replaceFunction) |
Replace components in the given component and all siblings with the given function.
|
static TextComponent |
replace(TextComponent component,
java.lang.String searchRegex,
java.util.function.Function<TextComponent,TextComponent> replaceFunction) |
Replace all matches of the given pattern in this component and all siblings.
|
static TextComponent |
replaceRGBColors(TextComponent component) |
Replace all rgb color codes with the nearest formatting color.
|
static void |
setTranslator(TextComponent component,
Translator translator) |
Recursively set the translator for all translation and keybind components in the given component.
|
static void |
setTranslator(TextComponent component,
Translator textTranslator,
Translator keyTranslator) |
Recursively set the translators for all translation and keybind components in the given component.
|
static TextComponent[] |
split(TextComponent component,
java.lang.String split,
boolean resolveTranslations) |
Split the given component by the given split string.
|
public static TextComponent makeURLsClickable(TextComponent component)
component - The component to make clickablepublic static TextComponent replace(TextComponent component, java.util.function.Function<TextComponent,TextComponent> replaceFunction)
component - The component to replace inreplaceFunction - The function that will be called for every componentpublic static TextComponent replace(TextComponent component, java.lang.String searchRegex, java.util.function.Function<TextComponent,TextComponent> replaceFunction)
StringComponent components.component - The component to replace insearchRegex - The regex to search forreplaceFunction - The function that will be called for every matchpublic static TextComponent replaceRGBColors(TextComponent component)
component - The component to replace inpublic static TextComponent join(TextComponent separator, TextComponent... components)
StringComponent will be returned.separator - The separatorcomponents - The componentspublic static void iterateAll(TextComponent component, java.util.function.Consumer<TextComponent> consumer)
component - The component to iterate overconsumer - The consumer that will be called for every componentTextComponent.forEach(Consumer)public static void setTranslator(TextComponent component, @Nullable Translator translator)
component - The component to set the translator fortranslator - The translator functionpublic static void setTranslator(TextComponent component, @Nullable Translator textTranslator, @Nullable Translator keyTranslator)
component - The component to set the translators fortextTranslator - The translator function for text componentskeyTranslator - The translator function for keybind componentspublic static TextComponent[] split(TextComponent component, java.lang.String split, boolean resolveTranslations)
string.split(split, -1) without regex.component - The component to splitsplit - The split stringresolveTranslations - If translations should be resolved before splitting