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