Package net.glowstone.util
Class TextMessage
java.lang.Object
net.glowstone.util.TextMessage
Simple container for chat message structures until more advanced chat formatting is implemented.
-
Constructor Summary
ConstructorsConstructorDescriptionTextMessage
(String text) Construct a new chat message from a simple text string.TextMessage
(org.json.simple.JSONObject object) Construct a chat message from a JSON structure. -
Method Summary
Modifier and TypeMethodDescriptionAttempt to convert the message to its plaintext representation.static TextMessage
Decode a chat message from its textual JSON representation if possible.encode()
Encode this chat message to its textual JSON representation.boolean
flatten()
Flatten this message to an approximate old-style string representation.int
hashCode()
toString()
-
Constructor Details
-
TextMessage
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
Flatten this message to an approximate old-style string representation.- Returns:
- The best old-style string representation for this message.
-
decode
Decode a chat message from its textual JSON representation if possible.- Parameters:
json
- The encoded representation.- Returns:
- The decoded TextMessage.
-
encode
Encode this chat message to its textual JSON representation.- Returns:
- The encoded representation.
-
asPlaintext
Attempt to convert the message to its plaintext representation.- Returns:
- The plain text, or the empty string on failure.
-
toString
-
equals
-
hashCode
public int hashCode()
-