Package net.md_5.bungee.chat
Class VersionedComponentSerializer
java.lang.Object
net.md_5.bungee.chat.VersionedComponentSerializer
- All Implemented Interfaces:
com.google.gson.JsonDeserializer<net.md_5.bungee.api.chat.BaseComponent>
@Experimental
public class VersionedComponentSerializer
extends Object
implements com.google.gson.JsonDeserializer<net.md_5.bungee.api.chat.BaseComponent>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ThreadLocal<Set<net.md_5.bungee.api.chat.BaseComponent>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnet.md_5.bungee.api.chat.BaseComponentdeserialize(com.google.gson.JsonElement jsonElement) Deserialize a JSON element as a single component.net.md_5.bungee.api.chat.BaseComponentdeserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) net.md_5.bungee.api.chat.BaseComponentdeserialize(String json) Deserialize a JSON-compliant String as a single component.net.md_5.bungee.api.chat.ComponentStyledeserializeStyle(com.google.gson.JsonElement jsonElement) Deserialize a JSON element as a component style.net.md_5.bungee.api.chat.ComponentStyledeserializeStyle(String json) Deserialize a JSON-compliant String as a component style.static VersionedComponentSerializerforVersion(ChatVersion version) static VersionedComponentSerializerDeprecated.com.google.gson.GsongetGson()net.md_5.bungee.api.chat.BaseComponent[]Parse a JSON-compliant String as an array of base components.com.google.gson.JsonElementtoJson(net.md_5.bungee.api.chat.BaseComponent component) com.google.gson.JsonElementtoJson(net.md_5.bungee.api.chat.ComponentStyle style) Deprecated.Error-prone, be careful which object you input heretoString(net.md_5.bungee.api.chat.BaseComponent component) toString(net.md_5.bungee.api.chat.BaseComponent... components) toString(net.md_5.bungee.api.chat.ComponentStyle style) toString(net.md_5.bungee.api.chat.hover.content.Content content) Deprecated.for legacy internal use only
-
Field Details
-
serializedComponents
@Internal public static final ThreadLocal<Set<net.md_5.bungee.api.chat.BaseComponent>> serializedComponents
-
-
Constructor Details
-
VersionedComponentSerializer
-
-
Method Details
-
forVersion
-
getDefault
Deprecated. -
parse
Parse a JSON-compliant String as an array of base components. The input can be one of either an array of components, or a single component object. If the input is an array, each component will be parsed individually and returned in the order that they were parsed. If the input is a single component object, a single-valued array with the component will be returned.NOTE:
deserialize(String)is preferred as it will parse only one component as opposed to an array of components which is non- standard behavior. This method is still appropriate for parsing multiple components at once, although such use case is rarely (if at all) exhibited in vanilla Minecraft.- Parameters:
json- the component json to parse- Returns:
- an array of all parsed components
-
deserialize
Deserialize a JSON-compliant String as a single component.- Parameters:
json- the component json to parse- Returns:
- the deserialized component
- Throws:
IllegalArgumentException- if anything other than a valid JSON component string is passed as input
-
deserialize
public net.md_5.bungee.api.chat.BaseComponent deserialize(com.google.gson.JsonElement jsonElement) Deserialize a JSON element as a single component.- Parameters:
jsonElement- the component json to parse- Returns:
- the deserialized component
- Throws:
IllegalArgumentException- if anything other than a valid JSON component is passed as input
-
deserializeStyle
Deserialize a JSON-compliant String as a component style.- Parameters:
json- the component style json to parse- Returns:
- the deserialized component style
- Throws:
IllegalArgumentException- if anything other than a valid JSON component style string is passed as input
-
deserializeStyle
public net.md_5.bungee.api.chat.ComponentStyle deserializeStyle(com.google.gson.JsonElement jsonElement) Deserialize a JSON element as a component style.- Parameters:
jsonElement- the component style json to parse- Returns:
- the deserialized component style
- Throws:
IllegalArgumentException- if anything other than a valid JSON component style is passed as input
-
toJson
public com.google.gson.JsonElement toJson(net.md_5.bungee.api.chat.BaseComponent component) -
toJson
public com.google.gson.JsonElement toJson(net.md_5.bungee.api.chat.ComponentStyle style) -
toString
Deprecated.Error-prone, be careful which object you input here- Parameters:
object- the object to serialize- Returns:
- the JSON string representation of the object
-
toString
Deprecated.for legacy internal use only- Parameters:
content- the content to serialize- Returns:
- the JSON string representation of the object
-
toString
-
toString
-
toString
-
deserialize
public net.md_5.bungee.api.chat.BaseComponent deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException - Specified by:
deserializein interfacecom.google.gson.JsonDeserializer<net.md_5.bungee.api.chat.BaseComponent>- Throws:
com.google.gson.JsonParseException
-
getGson
public com.google.gson.Gson getGson() -
getVersion
-
getDialogSerializer
-