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).

  • Method Details

    • of

      public static RichMessage of​(@NotNull ColoredText coloredText)
      Creates a RichMessage by adding the first rich component.
      Parameters:
      coloredText - the text composing the first rich component
      Returns:
      the created rich message object
    • append

      public RichMessage append​(@NotNull ColoredText coloredText)
      Adds a new rich component to the message.
      Parameters:
      coloredText - the text composing the rich component
      Returns:
      the rich message
    • setClickEvent

      public RichMessage setClickEvent​(@Nullable ChatClickEvent clickEvent)
      Sets the click event of the current rich component.
      Parameters:
      clickEvent - the click event to set
      Returns:
      the rich message
    • setHoverEvent

      public RichMessage setHoverEvent​(@Nullable ChatHoverEvent hoverEvent)
      Sets the hover event of the current rich component.
      Parameters:
      hoverEvent - the hover event to set
      Returns:
      the rich message
    • setInsertion

      public RichMessage setInsertion​(@Nullable java.lang.String insertion)
      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 class JsonMessage
      Returns:
      the json representation of the message
      See Also:
      JsonMessage.toString()