Package net.minecraft.text
Interface StringVisitable
- All Known Subinterfaces:
MutableText
,Text
- All Known Implementing Classes:
BaseText
,KeybindText
,LiteralText
,NbtText
,NbtText.BlockNbtText
,NbtText.EntityNbtText
,NbtText.StorageNbtText
,ScoreText
,SelectorText
,TextHandler.StyledString
,TranslatableText
public interface StringVisitable
An object that can supply strings to a visitor,
with or without a style context.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
StringVisitable.StyledVisitor<T>
A visitor for string content and a contextualStyle
.static interface
StringVisitable.Visitor<T>
A visitor for string content. -
Field Summary
Fields Modifier and Type Field Description static StringVisitable
EMPTY
An empty visitable that does not call the visitors.static Optional<Unit>
TERMINATE_VISIT
Convenience object indicating the termination of a string visit. -
Method Summary
Modifier and Type Method Description static StringVisitable
concat(List<StringVisitable> visitables)
Concats multiple string visitables by the order they appear in the list.static StringVisitable
concat(StringVisitable[] visitables)
Concats multiple string visitables by the order they appear in the array.default String
getString()
static StringVisitable
plain(String string)
Creates a visitable from a plain string.static StringVisitable
styled(String string, Style style)
Creates a visitable from a plain string and a root style.<T> Optional<T>
visit(StringVisitable.StyledVisitor<T> styledVisitor, Style style)
Supplies this visitable's literal content and contextual style to the visitor.<T> Optional<T>
visit(StringVisitable.Visitor<T> visitor)
Supplies this visitable's literal content to the visitor.
-
Field Details
-
TERMINATE_VISIT
Convenience object indicating the termination of a string visit. -
EMPTY
An empty visitable that does not call the visitors.
-
-
Method Details
-
visit
Supplies this visitable's literal content to the visitor.- Parameters:
visitor
- the visitor- Returns:
Optional.empty()
if the visit finished, or a terminating result from thevisitor
-
visit
@Environment(CLIENT) <T> Optional<T> visit(StringVisitable.StyledVisitor<T> styledVisitor, Style style)Supplies this visitable's literal content and contextual style to the visitor.- Parameters:
styledVisitor
- the visitorstyle
- the contextual style- Returns:
Optional.empty()
if the visit finished, or a terminating result from thevisitor
-
plain
Creates a visitable from a plain string.- Parameters:
string
- the plain string
-
styled
Creates a visitable from a plain string and a root style.- Parameters:
string
- the plain stringstyle
- the root style
-
concat
Concats multiple string visitables by the order they appear in the array.- Parameters:
visitables
- an array or varargs of visitables
-
concat
Concats multiple string visitables by the order they appear in the list.- Parameters:
visitables
- a list of visitables
-
getString
-