Modifier and Type | Method and Description |
---|---|
static TextBuilder |
builder()
Creates a
TextBuilder with empty text. |
static TextBuilder.Score |
builder(Score score)
Creates a new unformatted
TextBuilder.Score with the given score. |
static TextBuilder.Selector |
builder(Selector selector)
Creates a new unformatted
TextBuilder.Selector with the given
selector. |
static TextBuilder.Literal |
builder(String content)
Creates a new unformatted
TextBuilder.Literal with the specified
content. |
static TextBuilder.Score |
builder(Text text,
Score score)
Creates a new
TextBuilder.Score with the formatting and actions
of the specified Text and the given score. |
static TextBuilder.Selector |
builder(Text text,
Selector selector)
Creates a new
TextBuilder.Selector with the formatting and
actions of the specified Text and the given selector. |
static TextBuilder.Literal |
builder(Text text,
String content)
Creates a new
TextBuilder.Literal with the formatting and actions
of the specified Text and the given content. |
static TextBuilder.Translatable |
builder(Text text,
Translatable translatable,
Object... args)
Creates a new
TextBuilder.Translatable with the formatting and
actions of the specified Text and the given Translatable . |
static TextBuilder.Translatable |
builder(Text text,
Translation translation,
Object... args)
Creates a new
TextBuilder.Translatable with the formatting and
actions of the specified Text and the given Translation
and arguments. |
static TextBuilder.Translatable |
builder(Translatable translatable,
Object... args)
Creates a new unformatted
TextBuilder.Translatable from the given
Translatable . |
static TextBuilder.Translatable |
builder(Translation translation,
Object... args)
Creates a new unformatted
TextBuilder.Translatable with the given
Translation and arguments. |
static Text |
format(Text template,
Map<String,?> replacements)
Creates a new Text instance with all
Text.Placeholder s replaced. |
static Text |
format(Text template,
Object... replacements)
Creates a new Text instance with all
Text.Placeholder s replaced. |
static char |
getLegacyChar()
Deprecated.
Legacy formatting codes are being phased out of Minecraft
|
static Text |
join(Iterable<? extends Text> texts)
Joins a sequence of text objects together.
|
static Text |
join(Text... texts)
Joins a sequence of text objects together.
|
static Text |
join(Text separator,
Text... texts)
Joins a sequence of text objects together along with a separator.
|
static TextRepresentation |
json()
Get a
TextRepresentation for the Mojangson representation of a
Text object. |
static TextRepresentation |
legacy()
Deprecated.
|
static TextRepresentation |
legacy(char legacyChar)
Deprecated.
|
static Text |
of()
Returns an empty, unformatted
Text instance. |
static Text |
of(Object... objects)
Builds a
Text from a given array of objects. |
static Text.Score |
of(Score score)
Creates a new unformatted
Text.Score with the given score. |
static Text.Selector |
of(Selector selector)
Creates a new unformatted
Text.Selector with the given selector. |
static Text.Literal |
of(String content)
Creates a
Text with the specified plain text. |
static Text.Translatable |
of(Translatable translatable,
Object... args)
Creates a new unformatted
Text.Translatable from the given
Translatable . |
static Text.Translatable |
of(Translation translation,
Object... args)
Creates a new unformatted
Text.Translatable with the given
Translation and arguments. |
static Text.Placeholder |
placeholder(String key)
Creates a placeholder
Text with the specified key. |
static Text.Placeholder |
placeholder(String key,
Text fallback)
Creates a placeholder
Text with the specified key and fallback. |
static TextBuilder.Placeholder |
placeholderBuilder(String key)
Creates a new unformatted
TextBuilder.Placeholder with the
specified key. |
static String |
replaceCodes(String text,
char from)
Deprecated.
Legacy formatting codes are being phased out of Minecraft
|
static String |
replaceCodes(String text,
char from,
char to)
Deprecated.
Legacy formatting codes are being phased out of Minecraft
|
static String |
stripCodes(String text)
Deprecated.
Legacy formatting codes are being phased out of Minecraft
|
static String |
stripCodes(String text,
char color)
Deprecated.
Legacy formatting codes are being phased out of Minecraft
|
static String |
toPlain(Text text)
Returns a plain text representation of the
Text without any
formatting. |
static String |
toPlain(Text text,
Locale locale)
Returns a plain text representation of the
Text without any
formatting. |
static TextRepresentation |
xml()
Get a
TextRepresentation for the TextXML representation of a
Text object. |
public static Text.Literal of(String content)
Text
with the specified plain text. The created message
won't have any formatting or events configured.content
- The content of the textText.Literal
public static Text.Placeholder placeholder(String key)
Text
with the specified key. The created
message won't have any formatting or events configured.key
- The key of the placeholderText.Placeholder
public static Text.Placeholder placeholder(String key, Text fallback)
Text
with the specified key and fallback.
The created message won't have any formatting or events configured.key
- The key of the placeholderfallback
- The fallback of the text if it is not replacedText.Placeholder
public static Text.Translatable of(Translation translation, Object... args)
Text.Translatable
with the given
Translation
and arguments.translation
- The translation for the textargs
- The arguments for the translationText.Translatable
public static Text.Translatable of(Translatable translatable, Object... args)
Text.Translatable
from the given
Translatable
.translatable
- The translatable for the textargs
- The arguments for the translationText.Translatable
public static Text.Selector of(Selector selector)
Text.Selector
with the given selector.selector
- The selector for the textText.Selector
public static Text.Score of(Score score)
Text.Score
with the given score.score
- The score for the textText.Score
public static Text of(Object... objects)
Text
from a given array of objects.
For instance, you can use this like
Texts.of(TextColors.DARK_AQUA, "Hi", TextColors.AQUA, "Bye")
This will create the correct Text
instance if the input object
is the input for one of the Text
types or convert the object to a
string otherwise.
objects
- The object arraypublic static Text format(Text template, Map<String,?> replacements)
Text.Placeholder
s replaced. All
placeholders without a non-null replacement are ignored. All replacements
will be wrapped in a Text
using of(Object...)
the
color and the style from the placeholder are transfered to that method as
well.template
- The template text in which all Text.Placeholder
s
should be replacedreplacements
- The values available to replace the placeholderspublic static Text format(Text template, Object... replacements)
Text.Placeholder
s replaced. All
placeholders without a non-null replacement are ignored. All replacements
will be wrapped in a Text
using of(Object...)
the
color and the style from the placeholder are transfered to that method as
well.template
- The template text in which all Text.Placeholder
s
should be replacedreplacements
- The values available to replace the placeholders. May
contain null values to skip the placeholderpublic static TextBuilder builder()
TextBuilder
with empty text.public static TextBuilder.Literal builder(String content)
TextBuilder.Literal
with the specified
content.content
- The content of the textText.Literal
,
TextBuilder.Literal
public static TextBuilder.Literal builder(Text text, String content)
TextBuilder.Literal
with the formatting and actions
of the specified Text
and the given content.text
- The text to apply the properties fromcontent
- The content for the text builderText.Literal
,
TextBuilder.Literal
public static TextBuilder.Placeholder placeholderBuilder(String key)
TextBuilder.Placeholder
with the
specified key.key
- The key of the placeholderText.Placeholder
,
TextBuilder.Placeholder
public static TextBuilder.Translatable builder(Translation translation, Object... args)
TextBuilder.Translatable
with the given
Translation
and arguments.translation
- The translation for the builderargs
- The arguments for the translationText.Translatable
,
TextBuilder.Translatable
public static TextBuilder.Translatable builder(Translatable translatable, Object... args)
TextBuilder.Translatable
from the given
Translatable
.translatable
- The translatable for the builderargs
- The arguments for the translationText.Translatable
,
TextBuilder.Translatable
public static TextBuilder.Translatable builder(Text text, Translation translation, Object... args)
TextBuilder.Translatable
with the formatting and
actions of the specified Text
and the given Translation
and arguments.text
- The text to apply the properties fromtranslation
- The translation for the builderargs
- The arguments for the translationText.Translatable
,
TextBuilder.Translatable
public static TextBuilder.Translatable builder(Text text, Translatable translatable, Object... args)
TextBuilder.Translatable
with the formatting and
actions of the specified Text
and the given Translatable
.text
- The text to apply the properties fromtranslatable
- The translatable for the builderargs
- The arguments for the translationText.Translatable
,
TextBuilder.Translatable
public static TextBuilder.Selector builder(Selector selector)
TextBuilder.Selector
with the given
selector.selector
- The selector for the builderText.Selector
,
TextBuilder.Selector
public static TextBuilder.Selector builder(Text text, Selector selector)
TextBuilder.Selector
with the formatting and
actions of the specified Text
and the given selector.text
- The text to apply the properties fromselector
- The selector for the builderText.Selector
,
TextBuilder.Selector
public static TextBuilder.Score builder(Score score)
TextBuilder.Score
with the given score.score
- The score for the text builderText.Score
,
TextBuilder.Score
public static TextBuilder.Score builder(Text text, Score score)
TextBuilder.Score
with the formatting and actions
of the specified Text
and the given score.text
- The text to apply the properties fromscore
- The score for the text builderText.Score
,
TextBuilder.Score
public static Text join(Text... texts)
texts
- The texts to joinpublic static Text join(Iterable<? extends Text> texts)
texts
- The texts to joinpublic static Text join(Text separator, Text... texts)
separator
- The separatortexts
- The text to joinpublic static String toPlain(Text text)
Text
without any
formatting.text
- The text to convertpublic static String toPlain(Text text, Locale locale)
Text
without any
formatting.text
- The text to convertlocale
- The locale to translatepublic static TextRepresentation json()
TextRepresentation
for the Mojangson representation of a
Text
object.public static TextRepresentation xml()
TextRepresentation
for the TextXML representation of a
Text
object.@Deprecated public static char getLegacyChar()
@Deprecated public static TextRepresentation legacy()
getLegacyChar()
.@Deprecated public static TextRepresentation legacy(char legacyChar)
legacyChar
- The legacy character to parse and output using@Deprecated public static String stripCodes(String text)
text
- The legacy text as a String@Deprecated public static String stripCodes(String text, char color)
text
- The legacy text as a Stringcolor
- The color character to be replaced@Deprecated public static String replaceCodes(String text, char from)
text
- The legacy text as a Stringfrom
- The color character to be replaced@Deprecated public static String replaceCodes(String text, char from, char to)
text
- The legacy text as a Stringfrom
- The color character to be replacedto
- The color character to replace with