Package net.minestom.server.chat
Class RichMessage
java.lang.Object
net.minestom.server.chat.JsonMessage
net.minestom.server.chat.RichMessage
public class RichMessage extends JsonMessage
Represents multiple
ColoredText
batched together with the possibility to add
click and hover events.
Used when the message can contain both colored text and event (otherwise, use ColoredText
).
You will need to call the static method to initialize the message of(ColoredText)
,
events can be assigned with setClickEvent(ChatClickEvent)
and setHoverEvent(ChatHoverEvent)
and new text element can also be appended append(ColoredText)
.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minestom.server.chat.JsonMessage
JsonMessage.RawJsonMessage
-
Method Summary
Modifier and Type Method Description RichMessage
append(ColoredText coloredText)
Adds a new rich component to the message.com.google.gson.JsonObject
getJsonObject()
Gets the json representation of this message.static RichMessage
of(ColoredText coloredText)
Creates aRichMessage
by adding the first rich component.RichMessage
setClickEvent(ChatClickEvent clickEvent)
Sets the click event of the current rich component.RichMessage
setHoverEvent(ChatHoverEvent hoverEvent)
Sets the hover event of the current rich component.RichMessage
setInsertion(java.lang.String insertion)
Sets the insertion string of the current rich component.
-
Method Details
-
of
Creates aRichMessage
by adding the first rich component.- Parameters:
coloredText
- the text composing the first rich component- Returns:
- the created rich message object
-
append
Adds a new rich component to the message.- Parameters:
coloredText
- the text composing the rich component- Returns:
- the rich message
-
setClickEvent
Sets the click event of the current rich component.- Parameters:
clickEvent
- the click event to set- Returns:
- the rich message
-
setHoverEvent
Sets the hover event of the current rich component.- Parameters:
hoverEvent
- the hover event to set- Returns:
- the rich message
-
setInsertion
Sets the insertion string of the current rich component.- Parameters:
insertion
- the string to insert in the chat box- Returns:
- the rich message
-
getJsonObject
@NotNull public com.google.gson.JsonObject getJsonObject()Description copied from class:JsonMessage
Gets the json representation of this message.Sent directly to the client.
- Specified by:
getJsonObject
in classJsonMessage
- Returns:
- the json representation of the message
- See Also:
JsonMessage.toString()
-