public IChatBaseComponent a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
if (jsonelement.isJsonPrimitive()) {
return new ChatComponentText(jsonelement.getAsString());
} else if (!jsonelement.isJsonObject()) {
if (jsonelement.isJsonArray()) {
JsonArray jsonarray = jsonelement.getAsJsonArray();
IChatBaseComponent ichatbasecomponent = null;
Iterator iterator = jsonarray.iterator();
while (iterator.hasNext()) {
JsonElement jsonelement1 = (JsonElement) iterator.next();
IChatBaseComponent ichatbasecomponent1 = this.a(jsonelement1, (Type) jsonelement1.getClass(), jsondeserializationcontext);
if (ichatbasecomponent == null) {
ichatbasecomponent = ichatbasecomponent1;
} else {
ichatbasecomponent.addSibling(ichatbasecomponent1);
}
}
return ichatbasecomponent;
} else {
throw new JsonParseException("Don\'t know how to turn " + jsonelement.toString() + " into a Component");
}
} else {
JsonObject jsonobject = jsonelement.getAsJsonObject();
Object object;
if (jsonobject.has("text")) {
object = new ChatComponentText(jsonobject.get("text").getAsString());
} else {
if (!jsonobject.has("translate")) {
throw new JsonParseException("Don\'t know how to turn " + jsonelement.toString() + " into a Component");
}
String s = jsonobject.get("translate").getAsString();
if (jsonobject.has("with")) {
JsonArray jsonarray1 = jsonobject.getAsJsonArray("with");
Object[] aobject = new Object[jsonarray1.size()];
for (int i = 0; i < aobject.length; ++i) {
aobject[i] = this.a(jsonarray1.get(i), type, jsondeserializationcontext);
if (aobject[i] instanceof ChatComponentText) {
ChatComponentText chatcomponenttext = (ChatComponentText) aobject[i];
if (chatcomponenttext.getChatModifier().g() && chatcomponenttext.a().isEmpty()) {
aobject[i] = chatcomponenttext.g();
}
}
}
object = new ChatMessage(s, aobject);
} else {
object = new ChatMessage(s, new Object[0]);
}
}
if (jsonobject.has("extra")) {
JsonArray jsonarray2 = jsonobject.getAsJsonArray("extra");
if (jsonarray2.size() <= 0) {
throw new JsonParseException("Unexpected empty array of components");
}
for (int j = 0; j < jsonarray2.size(); ++j) {
((IChatBaseComponent) object).addSibling(this.a(jsonarray2.get(j), type, jsondeserializationcontext));
}
}
((IChatBaseComponent) object).setChatModifier((ChatModifier) jsondeserializationcontext.deserialize(jsonelement, ChatModifier.class));
return (IChatBaseComponent) object;