public abstract class TextBuilder extends Object implements TextRepresentable
Text
instances.Text
Modifier and Type | Class and Description |
---|---|
static class |
TextBuilder.Literal
Represents a
TextBuilder creating immutable Text.Literal
instances. |
static class |
TextBuilder.Placeholder
Represents a
TextBuilder creating immutable
Text.Placeholder instances. |
static class |
TextBuilder.Score
Represents a
TextBuilder creating immutable Text.Score
instances. |
static class |
TextBuilder.Selector
Represents a
TextBuilder creating immutable Text.Selector
instances. |
static class |
TextBuilder.Translatable
Represents a
TextBuilder creating immutable
Text.Translatable instances. |
Modifier and Type | Field and Description |
---|---|
protected List<Text> |
children |
protected ClickAction<?> |
clickAction |
protected TextFormat |
format |
protected HoverAction<?> |
hoverAction |
protected ShiftClickAction<?> |
shiftClickAction |
Modifier | Constructor and Description |
---|---|
protected |
TextBuilder()
Constructs a new empty
TextBuilder . |
Modifier and Type | Method and Description |
---|---|
TextBuilder |
append(Iterable<? extends Text> children)
Appends the specified
Text to the end of this text. |
TextBuilder |
append(Text... children)
Appends the specified
Text to the end of this text. |
abstract Text |
build()
Builds an immutable instance of the current state of this text builder.
|
TextBuilder |
color(TextColor color)
Sets the
TextColor of this text. |
boolean |
equals(Object o) |
TextBuilder |
format(TextFormat format)
Sets the
TextFormat of this text. |
List<Text> |
getChildren()
Returns a view of the current children of this builder.
|
Optional<ClickAction<?>> |
getClickAction()
Returns the current
ClickAction of this builder. |
TextColor |
getColor()
Returns the current color of the
Text in this builder. |
TextFormat |
getFormat()
Returns the current format of the
Text in this builder. |
Optional<HoverAction<?>> |
getHoverAction()
Returns the current
HoverAction of this builder. |
Optional<ShiftClickAction<?>> |
getShiftClickAction()
Returns the current
ShiftClickAction of this builder. |
TextStyle |
getStyle()
Returns the current style of the
Text in this builder. |
int |
hashCode() |
TextBuilder |
insert(int pos,
Iterable<? extends Text> children)
Inserts the specified
Text at the given position of this builder. |
TextBuilder |
insert(int pos,
Text... children)
Inserts the specified
Text at the given position of this builder. |
TextBuilder |
onClick(ClickAction<?> clickAction)
Sets the
ClickAction that will be executed if the text is clicked
in the chat. |
TextBuilder |
onHover(HoverAction<?> hoverAction)
Sets the
HoverAction that will be executed if the text is hovered
in the chat. |
TextBuilder |
onShiftClick(ShiftClickAction<?> shiftClickAction)
Sets the
ShiftClickAction that will be executed if the text is
shift-clicked in the chat. |
TextBuilder |
remove(Iterable<? extends Text> children)
Removes the specified
Text from this builder. |
TextBuilder |
remove(Text... children)
Removes the specified
Text from this builder. |
TextBuilder |
removeAll()
Removes all children from this builder.
|
TextBuilder |
style(TextStyle... styles)
Sets the text styles of this text.
|
String |
toString() |
Text |
toText()
Gets the textual representation of this instance for its usage in other
Text objects. |
protected TextFormat format
@Nullable protected ClickAction<?> clickAction
@Nullable protected HoverAction<?> hoverAction
@Nullable protected ShiftClickAction<?> shiftClickAction
protected TextBuilder()
TextBuilder
.public final TextFormat getFormat()
Text
in this builder.Text.getFormat()
public TextBuilder format(TextFormat format)
TextFormat
of this text.format
- The new text format for this textText.getFormat()
public final TextColor getColor()
Text
in this builder.Text.getColor()
public TextBuilder color(TextColor color)
TextColor
of this text.color
- The new text color for this textText.getColor()
public final TextStyle getStyle()
Text
in this builder.Text.getStyle()
public TextBuilder style(TextStyle... styles)
TextStyle
of the current style and the specified styles first and
set it to the text.styles
- The text styles to applyText.getStyle()
public final Optional<ClickAction<?>> getClickAction()
ClickAction
of this builder.Optional.empty()
if noneText.getClickAction()
public TextBuilder onClick(@Nullable ClickAction<?> clickAction)
ClickAction
that will be executed if the text is clicked
in the chat.clickAction
- The new click action for the textText.getClickAction()
public final Optional<HoverAction<?>> getHoverAction()
HoverAction
of this builder.Optional.empty()
if noneText.getHoverAction()
public TextBuilder onHover(@Nullable HoverAction<?> hoverAction)
HoverAction
that will be executed if the text is hovered
in the chat.hoverAction
- The new hover action for the textText.getHoverAction()
public final Optional<ShiftClickAction<?>> getShiftClickAction()
ShiftClickAction
of this builder.Optional.empty()
if
noneText.getShiftClickAction()
public TextBuilder onShiftClick(@Nullable ShiftClickAction<?> shiftClickAction)
ShiftClickAction
that will be executed if the text is
shift-clicked in the chat.shiftClickAction
- The new shift click action for the textText.getShiftClickAction()
public final List<Text> getChildren()
The returned list is unmodifiable, but not immutable. It will change if new children get added through this builder.
Text.getChildren()
public TextBuilder append(Text... children)
Text
to the end of this text.children
- The texts to appendText.getChildren()
public TextBuilder append(Iterable<? extends Text> children)
Text
to the end of this text.children
- The texts to appendText.getChildren()
public TextBuilder insert(int pos, Text... children)
Text
at the given position of this builder.pos
- The position to insert the texts tochildren
- The texts to insertIndexOutOfBoundsException
- If the position is out of boundsText.getChildren()
public TextBuilder insert(int pos, Iterable<? extends Text> children)
Text
at the given position of this builder.pos
- The position to insert the texts tochildren
- The texts to insertIndexOutOfBoundsException
- If the position is out of rangeText.getChildren()
public TextBuilder remove(Text... children)
Text
from this builder.children
- The texts to removeText.getChildren()
public TextBuilder remove(Iterable<? extends Text> children)
Text
from this builder.children
- The texts to removeText.getChildren()
public TextBuilder removeAll()
Text.getChildren()
public abstract Text build()
Text
with the current properties of this
builderpublic final Text toText()
TextRepresentable
Text
objects. This may but does not need to include
hover texts
or other actions
. This
method is basically the toString()
equivalent
for Text
s.toText
in interface TextRepresentable