public interface Text extends com.mojang.brigadier.Message, StringRenderable
Each text has a tree structure, embodying all its siblings. To iterate contents in the text and all
its siblings, call visit methods.
This interface does not expose mutation operations. For mutation,
refer to MutableText.
MutableText| Modifier and Type | Interface and Description |
|---|---|
static class |
Text.Serializer
A JSON serializer for
Text. |
StringRenderable.StyledVisitor<T>, StringRenderable.Visitor<T>EMPTY, TERMINATE_VISIT| Modifier and Type | Method and Description |
|---|---|
String |
asString()
Returns the string representation of this text itself, excluding siblings.
|
default String |
asTruncatedString(int length)
Returns the full string representation of this text, truncated beyond
the supplied
length. |
MutableText |
copy()
Copies the text itself, excluding the styles or siblings.
|
List<Text> |
getSiblings()
Returns the siblings of this text.
|
default String |
getString() |
Style |
getStyle()
Returns the style of this text.
|
static Text |
method_30163(String string) |
MutableText |
shallowCopy()
Copies the text itself, the style, and the siblings.
|
default <T> Optional<T> |
visit(StringRenderable.StyledVisitor<T> styledVisitor,
Style style)
Supplies this renderable's literal content and contextual style to
the visitor.
|
default <T> Optional<T> |
visit(StringRenderable.Visitor<T> visitor)
Supplies this renderable's literal content to the visitor.
|
default <T> Optional<T> |
visitSelf(StringRenderable.StyledVisitor<T> visitor,
Style style)
Visits the text itself.
|
default <T> Optional<T> |
visitSelf(StringRenderable.Visitor<T> visitor)
Visits the text itself.
|
concat, concat, plain, styledStyle getStyle()
String asString()
default String getString()
getString in interface com.mojang.brigadier.MessagegetString in interface StringRenderabledefault String asTruncatedString(int length)
length.length - the max length allowed for the string representation of the textMutableText copy()
MutableText shallowCopy()
A shallow copy is made for the siblings.
@Environment(value=CLIENT) default <T> Optional<T> visit(StringRenderable.StyledVisitor<T> styledVisitor, Style style)
visit in interface StringRenderablestyledVisitor - the visitorstyle - the contextual styleOptional.empty() if the visit finished, or a terminating
result from the visitordefault <T> Optional<T> visit(StringRenderable.Visitor<T> visitor)
visit in interface StringRenderablevisitor - the visitorOptional.empty() if the visit finished, or a terminating
result from the visitor@Environment(value=CLIENT) default <T> Optional<T> visitSelf(StringRenderable.StyledVisitor<T> visitor, Style style)
visitor - the visitorstyle - the current styleStringRenderable.visit(StyledVisitor, Style)default <T> Optional<T> visitSelf(StringRenderable.Visitor<T> visitor)
visitor - the visitorStringRenderable.visit(Visitor)