public class ComponentSerializer extends Object implements com.google.gson.JsonDeserializer<BaseComponent>
| Modifier and Type | Field and Description |
|---|---|
static ThreadLocal<Set<BaseComponent>> |
serializedComponents |
| Constructor and Description |
|---|
ComponentSerializer() |
| Modifier and Type | Method and Description |
|---|---|
static BaseComponent |
deserialize(com.google.gson.JsonElement jsonElement)
Deserialize a JSON element as a single component.
|
BaseComponent |
deserialize(com.google.gson.JsonElement json,
Type typeOfT,
com.google.gson.JsonDeserializationContext context) |
static BaseComponent |
deserialize(String json)
Deserialize a JSON-compliant String as a single component.
|
static ComponentStyle |
deserializeStyle(com.google.gson.JsonElement jsonElement)
Deserialize a JSON element as a component style.
|
static ComponentStyle |
deserializeStyle(String json)
Deserialize a JSON-compliant String as a component style.
|
static BaseComponent[] |
parse(String json)
Parse a JSON-compliant String as an array of base components.
|
static com.google.gson.JsonElement |
toJson(BaseComponent component) |
static com.google.gson.JsonElement |
toJson(ComponentStyle style) |
static String |
toString(BaseComponent... components) |
static String |
toString(BaseComponent component) |
static String |
toString(ComponentStyle style) |
static String |
toString(Object object) |
public static final ThreadLocal<Set<BaseComponent>> serializedComponents
public static BaseComponent[] parse(String json)
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.
json - the component json to parsepublic static BaseComponent deserialize(String json)
json - the component json to parseIllegalArgumentException - if anything other than a valid JSON
component string is passed as inputpublic static BaseComponent deserialize(com.google.gson.JsonElement jsonElement)
jsonElement - the component json to parseIllegalArgumentException - if anything other than a valid JSON
component is passed as inputpublic static ComponentStyle deserializeStyle(String json)
json - the component style json to parseIllegalArgumentException - if anything other than a valid JSON
component style string is passed as inputpublic static ComponentStyle deserializeStyle(com.google.gson.JsonElement jsonElement)
jsonElement - the component style json to parseIllegalArgumentException - if anything other than a valid JSON
component style is passed as inputpublic static com.google.gson.JsonElement toJson(BaseComponent component)
public static com.google.gson.JsonElement toJson(ComponentStyle style)
public static String toString(BaseComponent component)
public static String toString(BaseComponent... components)
public static String toString(ComponentStyle style)
public BaseComponent deserialize(com.google.gson.JsonElement json, Type typeOfT, com.google.gson.JsonDeserializationContext context) throws com.google.gson.JsonParseException
deserialize in interface com.google.gson.JsonDeserializer<BaseComponent>com.google.gson.JsonParseExceptionCopyright © 2012–2024 SpigotMC. All rights reserved.