Class TextMessage

java.lang.Object
net.glowstone.util.TextMessage

public final class TextMessage extends Object
Simple container for chat message structures until more advanced chat formatting is implemented.
  • Constructor Details

    • TextMessage

      public TextMessage(String text)
      Construct a new chat message from a simple text string. Handles style and colors in the original string, converting them to the new format.
      Parameters:
      text - The text of the message.
    • TextMessage

      public TextMessage(org.json.simple.JSONObject object)
      Construct a chat message from a JSON structure. No validation occurs.
      Parameters:
      object - The JSON structure of the message.
  • Method Details

    • flatten

      public String flatten()
      Flatten this message to an approximate old-style string representation.
      Returns:
      The best old-style string representation for this message.
    • decode

      public static TextMessage decode(String json)
      Decode a chat message from its textual JSON representation if possible.
      Parameters:
      json - The encoded representation.
      Returns:
      The decoded TextMessage.
    • encode

      public String encode()
      Encode this chat message to its textual JSON representation.
      Returns:
      The encoded representation.
    • asPlaintext

      public String asPlaintext()
      Attempt to convert the message to its plaintext representation.
      Returns:
      The plain text, or the empty string on failure.
    • toString

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

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object