Class Message

java.lang.Object
com.hypixel.hytale.server.core.Message

public class Message extends Object
A message that can be sent to a IMessageReceiver. Can contain raw text, formatted text, links, an image, an icon...
  • Field Details

  • Constructor Details

    • Message

      public Message(@Nonnull FormattedMessage message)
      A constructor for a Message instance, which takes in an existing message contents
      Parameters:
      message - The FormattedMessage contents of the message
  • Method Details

    • param

      @Nonnull public Message param(@Nonnull String key, @Nonnull String value)
      Assigns the given String value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, boolean value)
      Assigns the given boolean value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, double value)
      Assigns the given double value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, int value)
      Assigns the given int value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, long value)
      Assigns the given long value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, float value)
      Assigns the given float value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      value - The value to be set
      Returns:
      the initial Message instance
    • param

      @Nonnull public Message param(@Nonnull String key, @Nonnull Message formattedMessage)
      Assigns the given Message value as a parameter for the given key
      Parameters:
      key - The key that the value should represent
      formattedMessage - The message to be set
      Returns:
      the initial Message instance
    • bold

      @Nonnull public Message bold(boolean bold)
      Called to set the message as being bold
      Parameters:
      bold - Whether the message should be bold
      Returns:
      the initial Message instance
    • italic

      @Nonnull public Message italic(boolean italic)
      Called to set the message as being italic
      Parameters:
      italic - Whether the message should be italic
      Returns:
      the initial Message instance
    • monospace

      @Nonnull public Message monospace(boolean monospace)
      Called to set the message as being monospace
      Parameters:
      monospace - Whether the message should use a monospace font
      Returns:
      the initial Message instance
    • strikethrough

      @Nonnull public Message strikethrough(boolean strikethrough)
      Called to set the message as having a strikethrough
      Parameters:
      strikethrough - Whether the message should have a strikethrough
      Returns:
      the initial Message instance
    • color

      @Nonnull public Message color(@Nonnull String color)
      Called to set the message color from the given String hex value
      Parameters:
      color - The color, as a String, representing a hex value
      Returns:
      the initial Message instance
    • color

      @Nonnull public Message color(@Nonnull Color color)
      Called to set the message color from the given Color value
      Parameters:
      color - The color, as a Color instance
      Returns:
      the initial Message instance
    • link

      @Nonnull public Message link(@Nonnull String url)
      Called to set a URL on the message, from the given URL value
      Parameters:
      url - The URL value to be set
      Returns:
      the initial Message instance
    • insert

      @Nonnull public Message insert(@Nonnull Message formattedMessage)
      Called to insert the given Message as a child of this message
      Parameters:
      formattedMessage - The message to be inserted
      Returns:
      the initial Message instance
    • insert

      @Nonnull public Message insert(@Nonnull String message)
      Called to insert the given String value as a child of this message
      Parameters:
      message - The string value to be inserted
      Returns:
      the initial Message instance
    • insertAll

      @Nonnull public Message insertAll(@Nonnull Message... formattedMessages)
      Called to insert the given array of messages as children of this message
      Parameters:
      formattedMessages - The array of Message instances to insert
      Returns:
      the initial Message instance
    • insertAll

      @Nonnull public Message insertAll(@Nonnull List<Message> formattedMessages)
      Called to insert the given collection of messages as children of this message
      Parameters:
      formattedMessages - The collection of Message instances to insert
      Returns:
      the initial Message instance
    • getRawText

      @Nullable public String getRawText()
      Returns:
      the raw text of this message
    • getMessageId

      @Nullable public String getMessageId()
      Returns:
      the message ID of this message
    • getColor

      @Nullable public String getColor()
      Returns:
      the color of this message, as a HEX value
    • getChildren

      @Nonnull public List<Message> getChildren()
      Returns:
      a collection of Message instances, which are children of this message
    • getAnsiMessage

      @Nonnull public String getAnsiMessage()
      Returns:
      the contents of the message into a formatted string
    • getFormattedMessage

      public FormattedMessage getFormattedMessage()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • empty

      @Nonnull public static Message empty()
      Creates a new Message instance without any message in the root node
      Returns:
      the Message instance
    • translation

      @Nonnull public static Message translation(@Nonnull String messageId)
      Creates a new Message instance with a message from the i18n translation files
      Parameters:
      messageId - the id of the translation string
      Returns:
      the Message instance
    • raw

      @Nonnull public static Message raw(@Nonnull String message)
      Creates a new Message instance with a raw string message The usage of Message#build should be always preferred
      Parameters:
      message - the raw message
      Returns:
      the Message instance
    • parse

      @Nonnull public static Message parse(@Nonnull String message)
      Creates a new Message instance by parsing the provided message as a BsonDocument
      Parameters:
      message - The string value to be parsed
      Returns:
      the newly parsed Message instance
    • join

      @Nonnull public static Message join(@Nonnull Message... messages)
      Join together messages into a single message. Any null values in the messages array are skipped.
      Parameters:
      messages - The messages to join.
      Returns:
      The joined Message instance.