public class TextComponent extends AbstractBuildableComponent<TextComponent,TextComponent.Builder>
| Modifier and Type | Class and Description |
|---|---|
static class |
TextComponent.Builder
A text component builder.
|
AbstractBuildableComponent.AbstractBuilder<C extends BuildableComponent<C,B>,B extends AbstractBuildableComponent.AbstractBuilder<C,B>>bold, children, clickEvent, color, hoverEvent, insertion, italic, obfuscated, strikethrough, underlinedEMPTY_COMPONENT_LIST| Modifier | Constructor and Description |
|---|---|
protected |
TextComponent(@NonNull java.util.List<Component> children,
@Nullable TextColor color,
TextDecoration.State obfuscated,
TextDecoration.State bold,
TextDecoration.State strikethrough,
TextDecoration.State underlined,
TextDecoration.State italic,
@Nullable ClickEvent clickEvent,
@Nullable HoverEvent hoverEvent,
@Nullable java.lang.String insertion,
@NonNull java.lang.String content) |
protected |
TextComponent(@NonNull TextComponent.Builder builder) |
| Modifier and Type | Method and Description |
|---|---|
@NonNull TextComponent |
append(@NonNull Component component)
Appends a component to this component.
|
static TextComponent.Builder |
builder()
Creates a text component builder.
|
static TextComponent.Builder |
builder(@NonNull java.lang.String content)
Creates a text component builder with content.
|
@NonNull TextComponent |
clickEvent(@Nullable ClickEvent event)
Sets the click event of this component.
|
@NonNull TextComponent |
color(@Nullable TextColor color)
Sets the color of this component.
|
@NonNull java.lang.String |
content()
Gets the plain text content.
|
@NonNull TextComponent |
content(@NonNull java.lang.String content)
Sets the plain text content.
|
@NonNull TextComponent |
copy()
Creates a component.
|
@NonNull TextComponent |
decoration(@NonNull TextDecoration decoration,
boolean flag)
Sets the state of a decoration on this component.
|
@NonNull TextComponent |
decoration(@NonNull TextDecoration decoration,
TextDecoration.State state)
Sets the value of a decoration on this component.
|
boolean |
equals(@Nullable java.lang.Object other) |
int |
hashCode() |
@NonNull TextComponent |
hoverEvent(@Nullable HoverEvent event)
Sets the hover event of this component.
|
@NonNull TextComponent |
insertion(@Nullable java.lang.String insertion)
Sets the string to be inserted when this component is shift-clicked.
|
static TextComponent |
make(@NonNull java.util.function.Consumer<TextComponent.Builder> consumer)
Creates a text component by applying configuration from
consumer. |
static TextComponent |
make(@NonNull java.lang.String content,
@NonNull java.util.function.Consumer<TextComponent.Builder> consumer)
Creates a text component by applying configuration from
consumer. |
@NonNull TextComponent |
mergeColor(@NonNull Component that)
Merges the color from another component into this component.
|
@NonNull TextComponent |
mergeDecorations(@NonNull Component that)
Merges the decorations from another component into this component.
|
@NonNull TextComponent |
mergeEvents(@NonNull Component that)
Merges the events from another component into this component.
|
@NonNull TextComponent |
mergeStyle(@NonNull Component that)
Merges styling from another component into this component.
|
static TextComponent |
of(@NonNull java.lang.String content)
Creates a text component with content.
|
static TextComponent |
of(@NonNull java.lang.String content,
@Nullable TextColor color)
Creates a text component with content, and optional color.
|
static TextComponent |
of(@NonNull java.lang.String content,
@Nullable TextColor color,
@NonNull java.util.Set<TextDecoration> decorations)
Creates a text component with content, and optional color and decorations.
|
protected void |
populateToString(com.google.common.base.MoreObjects.ToStringHelper builder) |
@NonNull TextComponent |
resetStyle()
Resets all styling on this component.
|
@NonNull TextComponent.Builder |
toBuilder()
Create a builder from this component.
|
children, clickEvent, color, decoration, equals, hasStyling, hoverEvent, insertion, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitchildren, clickEvent, color, contains, decoration, decorations, decorations, detectCycle, hasDecoration, hasStyling, hoverEvent, insertion, of, of, of, of, of, ofprotected TextComponent(@NonNull TextComponent.Builder builder)
protected TextComponent(@NonNull java.util.List<Component> children, @Nullable TextColor color, TextDecoration.State obfuscated, TextDecoration.State bold, TextDecoration.State strikethrough, TextDecoration.State underlined, TextDecoration.State italic, @Nullable ClickEvent clickEvent, @Nullable HoverEvent hoverEvent, @Nullable java.lang.String insertion, @NonNull java.lang.String content)
public static TextComponent.Builder builder()
public static TextComponent.Builder builder(@NonNull java.lang.String content)
content - the plain text contentpublic static TextComponent of(@NonNull java.lang.String content)
content - the plain text contentpublic static TextComponent of(@NonNull java.lang.String content, @Nullable TextColor color)
content - the plain text contentcolor - the colorpublic static TextComponent of(@NonNull java.lang.String content, @Nullable TextColor color, @NonNull java.util.Set<TextDecoration> decorations)
content - the plain text contentcolor - the colordecorations - the decorationspublic static TextComponent make(@NonNull java.util.function.Consumer<TextComponent.Builder> consumer)
consumer.consumer - the builder configuratorpublic static TextComponent make(@NonNull java.lang.String content, @NonNull java.util.function.Consumer<TextComponent.Builder> consumer)
consumer.content - the plain text contentconsumer - the builder configuratorpublic @NonNull java.lang.String content()
public @NonNull TextComponent content(@NonNull java.lang.String content)
content - the plain text contentpublic @NonNull TextComponent append(@NonNull Component component)
Componentcomponent - the component to appendpublic @NonNull TextComponent color(@Nullable TextColor color)
Componentcolor - the colorpublic @NonNull TextComponent decoration(@NonNull TextDecoration decoration, boolean flag)
Componentdecoration - the decorationflag - true if this component should have the decoration, false if
this component should not have the decorationpublic @NonNull TextComponent decoration(@NonNull TextDecoration decoration, TextDecoration.State state)
Componentdecoration - the decorationstate - TextDecoration.State#TRUE if this component should have the
decoration, TextDecoration.State#FALSE if this component should not
have the decoration, and TextDecoration.State#NOT_SET if the decoration
should not have a set valuepublic @NonNull TextComponent clickEvent(@Nullable ClickEvent event)
Componentevent - the click eventpublic @NonNull TextComponent hoverEvent(@Nullable HoverEvent event)
Componentevent - the hover eventpublic @NonNull TextComponent insertion(@Nullable java.lang.String insertion)
Componentinsertion - the insertion stringpublic @NonNull TextComponent mergeStyle(@NonNull Component that)
Componentthat - the other componentpublic @NonNull TextComponent mergeColor(@NonNull Component that)
Componentthat - the other componentpublic @NonNull TextComponent mergeDecorations(@NonNull Component that)
Componentthat - the other componentpublic @NonNull TextComponent mergeEvents(@NonNull Component that)
Componentthat - the other componentpublic @NonNull TextComponent resetStyle()
Componentpublic @NonNull TextComponent copy()
Componentpublic boolean equals(@Nullable java.lang.Object other)
equals in class AbstractComponentpublic int hashCode()
hashCode in class AbstractComponentprotected void populateToString(com.google.common.base.MoreObjects.ToStringHelper builder)
populateToString in class AbstractComponentpublic @NonNull TextComponent.Builder toBuilder()
BuildableComponent