Package me.neznamy.tab.api.chat
Class DeserializedChatComponent
java.lang.Object
me.neznamy.tab.api.chat.IChatBaseComponent
me.neznamy.tab.api.chat.DeserializedChatComponent
A class representing a chat component that was serialized before,
but deserialize was requested in PacketPlayOutPlayerInfo packet.
This is used to read and modify the packet and then rewrite it.
However, display name components must be deserialized to properly
forward them in the new packet, but its value is not actually
used anywhere.
To avoid this heavy and completely unnecessary operation, the original string is saved and returned during serialization. If any read/write operation is performed, the string is fully deserialized and this object will act like a normal chat component.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs new instance with given parameter -
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtra(IChatBaseComponent child) Appends provided component as extra componentgetExtra()Returns list of extra components.Returns chat modifier of this componentgetText()Returns text of this componentsetExtra(List<IChatBaseComponent> components) Sets full list of extra components to given list.voidsetModifier(ChatModifier modifier) Sets modifier to provided valuetoString()Converts the component to a string representing the serialized component.toString(ProtocolVersion clientVersion) Serializes this component with colors based on client version.Methods inherited from class me.neznamy.tab.api.chat.IChatBaseComponent
deserialize, fromColoredText, optimizedComponent, setText, toFlatText, toLegacyText, toRawText, toString
-
Constructor Details
-
DeserializedChatComponent
Constructs new instance with given parameter- Parameters:
json- serialized component as string
-
-
Method Details
-
toString
Description copied from class:IChatBaseComponentConverts the component to a string representing the serialized component. This method is only used internally by json library since it's missing protocol version field used by the method.- Overrides:
toStringin classIChatBaseComponent- Returns:
- serialized component in string form
- See Also:
-
toString
Description copied from class:IChatBaseComponentSerializes this component with colors based on client version. If client version is <1.16, HEX colors will be converted to legacy colors.- Overrides:
toStringin classIChatBaseComponent- Parameters:
clientVersion- client version to adapt component for- Returns:
- serialized string
-
getExtra
Description copied from class:IChatBaseComponentReturns list of extra components. If no extra components are defined, returns empty list.- Overrides:
getExtrain classIChatBaseComponent- Returns:
- list of extra components
-
getText
Description copied from class:IChatBaseComponentReturns text of this component- Overrides:
getTextin classIChatBaseComponent- Returns:
- text of this component
-
getModifier
Description copied from class:IChatBaseComponentReturns chat modifier of this component- Overrides:
getModifierin classIChatBaseComponent- Returns:
- chat modifier of this component
-
setExtra
Description copied from class:IChatBaseComponentSets full list of extra components to given list. Does not allow empty list.- Overrides:
setExtrain classIChatBaseComponent- Parameters:
components- components to use as extra- Returns:
- self
-
addExtra
Description copied from class:IChatBaseComponentAppends provided component as extra component- Overrides:
addExtrain classIChatBaseComponent- Parameters:
child- component to append
-
setModifier
Description copied from class:IChatBaseComponentSets modifier to provided value- Overrides:
setModifierin classIChatBaseComponent- Parameters:
modifier- modifier to set value to
-