public abstract class TextualComponent
extends java.lang.Object
implements java.lang.Cloneable
Different instances of this class can be created with static constructor methods.
Constructor and Description |
---|
TextualComponent() |
Modifier and Type | Method and Description |
---|---|
abstract TextualComponent |
clone()
Clones a textual component instance.
|
abstract java.lang.String |
getKey() |
abstract java.lang.String |
getReadableString() |
static TextualComponent |
localizedText(java.lang.String translateKey)
Create a textual component representing a localized string.
|
static TextualComponent |
objectiveScore(java.lang.String scoreboardObjective)
Create a textual component representing a scoreboard value.
|
static TextualComponent |
objectiveScore(java.lang.String playerName,
java.lang.String scoreboardObjective)
Create a textual component representing a scoreboard value.
|
static TextualComponent |
rawText(java.lang.String textValue)
Create a textual component representing a string literal.
|
static TextualComponent |
selector(java.lang.String selector)
Create a textual component representing a player name, retrievable by using a standard minecraft selector.
|
java.lang.String |
toString() |
abstract void |
writeJson(JsonWriter writer)
Writes the text data represented by this textual component to the specified JSON writer object.
|
public java.lang.String toString()
toString
in class java.lang.Object
public abstract java.lang.String getKey()
public abstract java.lang.String getReadableString()
public abstract TextualComponent clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public abstract void writeJson(JsonWriter writer) throws java.io.IOException
writer
- The object to which to write the JSON data.java.io.IOException
- If an error occurs while writing to the stream.public static TextualComponent rawText(java.lang.String textValue)
textValue
- The text which will be represented.public static TextualComponent localizedText(java.lang.String translateKey)
If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to the client.
translateKey
- The string key which maps to localized text.public static TextualComponent objectiveScore(java.lang.String scoreboardObjective)
This method is currently guaranteed to throw an UnsupportedOperationException
as it is only supported on snapshot clients.
scoreboardObjective
- The name of the objective for which to display the score.null
if an error occurs during JSON serialization.public static TextualComponent objectiveScore(java.lang.String playerName, java.lang.String scoreboardObjective)
This method is currently guaranteed to throw an UnsupportedOperationException
as it is only supported on snapshot clients.
playerName
- The name of the player whos score will be shown. If this string represents the single-character sequence "*", the viewing player's score will be displayed.
Standard minecraft selectors (@a, @p, etc) are not supported.scoreboardObjective
- The name of the objective for which to display the score.null
if an error occurs during JSON serialization.public static TextualComponent selector(java.lang.String selector)
This method is currently guaranteed to throw an UnsupportedOperationException
as it is only supported on snapshot clients.
selector
- The minecraft player or entity selector which will capture the entities whose string representations will be displayed in the place of this text component.