Class Text
- All Implemented Interfaces:
CharSequence
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappend(char ch) Appends some unstyled character to the current text.Appends some unstyled text to the current text.final Textappend(String text, @Nullable TextComponent component, Function<TextArgumentFactory, TextArgument>... argumentRetrievers) Appends some styled text to the current text with some optional argument.append(String text, @Nullable TextComponent component, TextArgument... arguments) Appends some styled text to the current text with some optional argument.Appends some styled text to the current text.final Textappend(String text, @Nullable TextType type, Function<TextArgumentFactory, TextArgument>... argumentRetrievers) Appends some styled text to the current text.append(String text, @Nullable TextType type, TextArgument... arguments) Appends some styled text to the current text.append(String text, TextArgument... arguments) Appends some unstyled text to the current text.Appends anotherTextobject to this one.appendClickableText(String text, @Nullable TextType type, String command, @Nullable String info) Attempts to add clickable text.charcharAt(int index) booleanintGets the length of the raw text without any styles applied to it.The factory forTextArguments.The factory for theTextComponentinstance used by this Text.inthashCode()intlength()newClickableTextArgument(Object argument, @Nullable TextType type, String command, @Nullable String info) Creates a new text argument for clickable texts.newTextArgument(Object argument, TextType type) Creates a newTextArgumentwith a given input String and text type.Prepends anotherTextobject to this object, so the other text is placed before the current one.<T> Trender(ITextRenderer<T> renderer) Renders this text using the provided text renderer.subsection(int start, int end) Gets a subsection from thisText.subSequence(int start, int end) toString()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
Text
-
Text
-
-
Method Details
-
getLength
public int getLength()Gets the length of the raw text without any styles applied to it.- Returns:
- The length of the raw text without any styles applied to it.
-
subsection
Gets a subsection from thisText.See
StringBuilder.substring(int, int).Any styles/decorators that have at least 1 character inside this range will be copied.
- Parameters:
start- The beginning index, inclusive.end- The ending index, exclusive.- Returns:
- The
Textin the given range.
-
append
Appends some unstyled text to the current text.- Parameters:
text- The unstyled text to add.- Returns:
- The current
Textinstance.
-
append
Appends some unstyled text to the current text.- Parameters:
text- The unstyled text to add.- Returns:
- The current
Textinstance.
-
append
Appends some unstyled character to the current text.- Parameters:
ch- The unstyled character to add.- Returns:
- The current
Textinstance.
-
append
Appends some styled text to the current text. -
append
@Contract("_, _, _ -> this") public Text append(String text, @Nullable @Nullable TextType type, TextArgument... arguments) Appends some styled text to the current text. -
append
@Contract("_, _, _ -> this") @SafeVarargs public final Text append(String text, @Nullable @Nullable TextType type, Function<TextArgumentFactory, TextArgument>... argumentRetrievers) Appends some styled text to the current text. -
append
@Contract("_, _, _ -> this") public Text append(String text, @Nullable @Nullable TextComponent component, TextArgument... arguments) Appends some styled text to the current text with some optional argument.For example "Hello, {0}".
See
MessageFormat.- Parameters:
text- The text to add.component- TheTextComponentto use for the text that is being added.arguments- The arguments to use to format the text.- Returns:
- The current
Textinstance.
-
append
@Contract("_, _, _ -> this") @SafeVarargs public final Text append(String text, @Nullable @Nullable TextComponent component, Function<TextArgumentFactory, TextArgument>... argumentRetrievers) Appends some styled text to the current text with some optional argument.For example "Hello, {0}".
See
MessageFormat.- Parameters:
text- The text to add.component- TheTextComponentto use for the text that is being added.argumentRetrievers- Retrievers for text arguments to use for variable substitution into the input text.- Returns:
- The current
Textinstance.
-
newTextArgument
Creates a newTextArgumentwith a given input String and text type.This method is a shortcut for creating a new text argument using the input String and
ITextComponentFactory.newComponent(TextType).- Parameters:
argument- The argument to use for the TextArgument.type- The text type to use for theTextComponent.- Returns:
- The new text argument.
-
newClickableTextArgument
public TextArgument newClickableTextArgument(Object argument, @Nullable @Nullable TextType type, String command, @Nullable @Nullable String info) Creates a new text argument for clickable texts.This method is a shortcut for creating a new argument using the input text and
ITextComponentFactory.newClickableTextComponent(TextType, String, String).- Parameters:
argument- The argument to use for the TextArgument.type- TheTextTypeof the text to add. This is used by any potential decorators to add styling and such to the text.command- The command to execute when this text is clicked.info- The optional information String explaining what clicking the text will do.- Returns:
- The new text component if one was created or null if no specific decoration should be applied to the text.
-
appendClickableText
@Contract("_, _, _, _ -> this") public Text appendClickableText(String text, @Nullable @Nullable TextType type, String command, @Nullable @Nullable String info) Attempts to add clickable text.The clickable text will execute a command when clicked.
The result depends on the capabilities of both the registered
ITextComponentFactoryand theITextRenderer.- Parameters:
text- The text to add.type- TheTextTypeof the text to add. This is used by any potential decorators to add styling and such to the text.command- The command to execute when this text is clicked.info- The optional information String explaining what clicking the text will do.- Returns:
- The current
Textinstance.
-
prepend
-
append
-
render
Renders this text using the provided text renderer.All sections of this Text object are processed by the renderer.
- Type Parameters:
T- The output type of the renderer.- Parameters:
renderer- The renderer to use.- Returns:
- The output of the renderer after processing this Text object.
-
length
public int length()- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index) - Specified by:
charAtin interfaceCharSequence
-
subSequence
- Specified by:
subSequencein interfaceCharSequence
-
toString
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
equals
-
hashCode
public int hashCode() -
getTextComponentFactory
The factory for theTextComponentinstance used by this Text. -
getTextArgumentFactory
The factory forTextArguments.
-