Class WrappedChatComponent

java.lang.Object
com.comphenix.protocol.wrappers.AbstractWrapper
com.comphenix.protocol.wrappers.WrappedChatComponent
All Implemented Interfaces:
ClonableWrapper

public class WrappedChatComponent extends AbstractWrapper implements ClonableWrapper
Represents a chat component added in Minecraft 1.7.2
  • Method Details

    • fromHandle

      public static WrappedChatComponent fromHandle(Object handle)
      Construct a new chat component wrapper around the given NMS object.
      Parameters:
      handle - - the NMS object.
      Returns:
      The wrapper.
    • fromJson

      public static WrappedChatComponent fromJson(String json)
      Construct a new chat component wrapper from the given JSON string.
      Parameters:
      json - - the json.
      Returns:
      The chat component wrapper.
    • fromText

      public static WrappedChatComponent fromText(String text)
      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

      public static WrappedChatComponent[] fromChatMessage(String message)
      Construct an array of chat components from a standard Minecraft message.

      This uses ChatColor for formating.

      Parameters:
      message - - the message.
      Returns:
      The equivalent chat components.
    • fromLegacyText

      public static WrappedChatComponent fromLegacyText(String message)
      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

      public String 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

      public void setJson(String obj)
      Set the content of this component using a JSON object.
      Parameters:
      obj - - the JSON that represents the new component.
    • deepClone

      public WrappedChatComponent deepClone()
      Retrieve a deep copy of the current chat component.
      Specified by:
      deepClone in interface ClonableWrapper
      Returns:
      A copy of the current component.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractWrapper