public abstract class TextComponent extends java.lang.Object implements com.viaversion.viaversion.libs.mcstructs.core.Copyable<TextComponent>
StringComponentTranslationComponentScoreComponentSelectorComponentKeybindComponentBlockNbtSourceEntityNbtSourceStorageNbtSourceObjectComponent| Modifier and Type | Class and Description |
|---|---|
static interface |
TextComponent.ComponentConsumer |
| Constructor and Description |
|---|
TextComponent() |
| Modifier and Type | Method and Description |
|---|---|
TextComponent |
append(java.lang.Iterable<TextComponent> components) |
TextComponent |
append(java.lang.String... strings)
Append multiple strings to this component.
|
TextComponent |
append(TextComponent... components)
Append multiple components to this component.
|
TextComponent |
append(TextComponent component)
Append a component to this component.
|
java.lang.String |
asLegacyFormatString() |
abstract java.lang.String |
asSingleString() |
void |
asSingleString(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter,
TextComponent.ComponentConsumer consumer) |
java.lang.String |
asUnformattedString() |
java.lang.String |
asUnformattedString(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter) |
static ObjectComponent |
atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite) |
static ObjectComponent |
atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier atlas,
com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite) |
static ObjectComponent |
atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier atlas,
com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite,
TextComponent fallback) |
static ObjectComponent |
atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite,
TextComponent fallback) |
static NbtComponent |
blockNbt(java.lang.String rawComponent,
boolean resolve,
java.lang.String pos) |
static NbtComponent |
blockNbt(java.lang.String rawComponent,
boolean resolve,
TextComponent separator,
java.lang.String pos) |
TextComponent |
copy() |
<C extends TextComponent> |
copyMetaTo(C component)
Copy the style and siblings of this component to the given component.
|
static StringComponent |
empty() |
static NbtComponent |
entityNbt(java.lang.String component,
boolean resolve,
java.lang.String selector) |
static NbtComponent |
entityNbt(java.lang.String component,
boolean resolve,
TextComponent separator,
java.lang.String selector) |
TextComponent |
forEach(java.util.function.Consumer<TextComponent> consumer)
Iterate over all components and their siblings.
|
TextComponent |
formatted(TextFormatting formatting)
Set a formatting of the style of this component.
|
java.util.List<TextComponent> |
getSiblings() |
Style |
getStyle() |
static KeybindComponent |
keybind(java.lang.String keybind) |
TextComponent |
mergeSiblingParentStyle()
Set the parent style of all siblings to this style and merge them together.
This removes all parent references from the siblings while maintaining the style. |
static TextComponent |
of(java.lang.Iterable<TextComponent> components) |
static TextComponent |
of(java.lang.String... text) |
static StringComponent |
of(java.lang.String text) |
static TextComponent |
of(TextComponent... components) |
static ScoreComponent |
score(java.lang.String name,
java.lang.String objective) |
static ScoreComponent |
score(java.lang.String name,
java.lang.String objective,
java.lang.String value) |
static SelectorComponent |
selector(java.lang.String selector) |
static SelectorComponent |
selector(java.lang.String selector,
TextComponent separator) |
TextComponent |
setParentStyle(Style style)
Set the parent style of this component.
|
TextComponent |
setSiblingParentStyle()
Set the parent style of all siblings to this style.
|
TextComponent |
setStyle(Style style)
Set the style of this component.
|
abstract TextComponent |
shallowCopy()
Create a shallow copy of this component.
This will only copy the component itself (including style) and not its siblings. |
static NbtComponent |
storageNbt(java.lang.String component,
boolean resolve,
com.viaversion.viaversion.libs.mcstructs.core.Identifier id) |
static NbtComponent |
storageNbt(java.lang.String component,
boolean resolve,
TextComponent separator,
com.viaversion.viaversion.libs.mcstructs.core.Identifier id) |
TextComponent |
styled(java.util.function.Consumer<Style> styleConsumer)
Modify the style of this component.
|
abstract java.lang.String |
toString() |
static TranslationComponent |
translation(java.lang.String key,
java.util.List<java.lang.Object> args) |
static TranslationComponent |
translation(java.lang.String key,
java.lang.Object... args) |
void |
visit(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter,
TextComponent.ComponentConsumer consumer) |
public TextComponent append(java.lang.String... strings)
strings - The strings to appendpublic TextComponent append(TextComponent component)
component - The component to appendpublic TextComponent append(TextComponent... components)
components - The components to appendpublic TextComponent append(java.lang.Iterable<TextComponent> components)
public java.util.List<TextComponent> getSiblings()
public TextComponent forEach(java.util.function.Consumer<TextComponent> consumer)
consumer - The consumer that will be called for every componentTextUtils.iterateAll(TextComponent, Consumer)@Nonnull public Style getStyle()
public TextComponent setStyle(@Nonnull Style style)
style - The new stylepublic TextComponent styled(java.util.function.Consumer<Style> styleConsumer)
styleConsumer - The consumer that will be called with the current stylepublic TextComponent formatted(TextFormatting formatting)
formatting - The formatting to setpublic TextComponent setParentStyle(@Nonnull Style style)
style - The new parent stylepublic TextComponent setSiblingParentStyle()
public TextComponent mergeSiblingParentStyle()
Style.mergeParent()public <C extends TextComponent> C copyMetaTo(C component)
C - The type of the componentcomponent - The component to copy topublic java.lang.String asUnformattedString()
public java.lang.String asUnformattedString(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter)
public void visit(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter,
TextComponent.ComponentConsumer consumer)
public java.lang.String asLegacyFormatString()
StringFormat.vanilla(char, boolean),
StringFormat.toString(TextComponent, ColorHandling, SerializerUnknownHandling)public abstract java.lang.String asSingleString()
public void asSingleString(com.viaversion.viaversion.libs.mcstructs.converter.ConsumerTracking converter,
TextComponent.ComponentConsumer consumer)
public TextComponent copy()
copy in interface com.viaversion.viaversion.libs.mcstructs.core.Copyable<TextComponent>public abstract TextComponent shallowCopy()
public abstract java.lang.String toString()
toString in class java.lang.Objectpublic static StringComponent empty()
public static StringComponent of(java.lang.String text)
public static TextComponent of(java.lang.String... text)
public static TextComponent of(TextComponent... components)
public static TextComponent of(java.lang.Iterable<TextComponent> components)
public static TranslationComponent translation(java.lang.String key, java.util.List<java.lang.Object> args)
public static TranslationComponent translation(java.lang.String key, java.lang.Object... args)
public static ScoreComponent score(java.lang.String name, java.lang.String objective)
public static ScoreComponent score(java.lang.String name, java.lang.String objective, @Nullable java.lang.String value)
public static SelectorComponent selector(java.lang.String selector)
public static SelectorComponent selector(java.lang.String selector, @Nullable TextComponent separator)
public static KeybindComponent keybind(java.lang.String keybind)
public static NbtComponent blockNbt(java.lang.String rawComponent, boolean resolve, java.lang.String pos)
public static NbtComponent blockNbt(java.lang.String rawComponent, boolean resolve, @Nullable TextComponent separator, java.lang.String pos)
public static NbtComponent entityNbt(java.lang.String component, boolean resolve, java.lang.String selector)
public static NbtComponent entityNbt(java.lang.String component, boolean resolve, @Nullable TextComponent separator, java.lang.String selector)
public static NbtComponent storageNbt(java.lang.String component, boolean resolve, com.viaversion.viaversion.libs.mcstructs.core.Identifier id)
public static NbtComponent storageNbt(java.lang.String component, boolean resolve, @Nullable TextComponent separator, com.viaversion.viaversion.libs.mcstructs.core.Identifier id)
public static ObjectComponent atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite)
public static ObjectComponent atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite, @Nullable TextComponent fallback)
public static ObjectComponent atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier atlas, com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite)
public static ObjectComponent atlasSprite(com.viaversion.viaversion.libs.mcstructs.core.Identifier atlas, com.viaversion.viaversion.libs.mcstructs.core.Identifier sprite, @Nullable TextComponent fallback)