Package com.comphenix.protocol.wrappers
Class WrappedChatComponent
java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedChatComponent
- All Implemented Interfaces:
ClonableWrapper
Represents a chat component added in Minecraft 1.7.2
-
Field Summary
Fields inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
handle, handleType -
Method Summary
Modifier and TypeMethodDescriptionRetrieve a deep copy of the current chat component.static WrappedChatComponent[]fromChatMessage(String message) Construct an array of chat components from a standard Minecraft message.static WrappedChatComponentfromHandle(Object handle) Construct a new chat component wrapper around the given NMS object.static WrappedChatComponentConstruct a new chat component wrapper from the given JSON string.static WrappedChatComponentfromLegacyText(String message) Construct a single chat component from a standard Minecraft message (with legacy formatting codes), preserving multiple lines.static WrappedChatComponentConstruct a wrapper around a new text chat component with the given text.getJson()Retrieve a copy of this component as a JSON string.voidSet the content of this component using a JSON object.toString()Methods inherited from class com.comphenix.protocol.wrappers.AbstractWrapper
equals, getHandle, getHandleType, hashCode, setHandleMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.comphenix.protocol.wrappers.ClonableWrapper
getHandle
-
Method Details
-
fromHandle
Construct a new chat component wrapper around the given NMS object.- Parameters:
handle- - the NMS object.- Returns:
- The wrapper.
-
fromJson
Construct a new chat component wrapper from the given JSON string.- Parameters:
json- - the json.- Returns:
- The chat component wrapper.
-
fromText
Construct a wrapper around a new text chat component with the given text.Note:
fromLegacyText(String)is preferred for text that contains legacy formatting codes since it will translate them to the JSON equivalent.- Parameters:
text- - the text of the text chat component.- Returns:
- The wrapper around the new chat component.
-
fromChatMessage
Construct an array of chat components from a standard Minecraft message.This uses
ChatColorfor formating.- Parameters:
message- - the message.- Returns:
- The equivalent chat components.
-
fromLegacyText
Construct a single chat component from a standard Minecraft message (with legacy formatting codes), preserving multiple lines.- Parameters:
message- - the message.- Returns:
- The equivalent chat component.
-
getJson
Retrieve a copy of this component as a JSON string.Note that any modifications to this JSON string will not update the current component.
- Returns:
- The JSON representation of this object.
-
setJson
Set the content of this component using a JSON object.- Parameters:
obj- - the JSON that represents the new component.
-
deepClone
Retrieve a deep copy of the current chat component.- Specified by:
deepClonein interfaceClonableWrapper- Returns:
- A copy of the current component.
-
toString
- Overrides:
toStringin classAbstractWrapper
-