use of net.minecraft.util.com.google.gson.JsonParser in project mc-dev by Bukkit.
the class ServerStatisticManager method a.
public Map a(String s) {
JsonElement jsonelement = (new JsonParser()).parse(s);
if (!jsonelement.isJsonObject()) {
return Maps.newHashMap();
} else {
JsonObject jsonobject = jsonelement.getAsJsonObject();
HashMap hashmap = Maps.newHashMap();
Iterator iterator = jsonobject.entrySet().iterator();
while (iterator.hasNext()) {
Entry entry = (Entry) iterator.next();
Statistic statistic = StatisticList.getStatistic((String) entry.getKey());
if (statistic != null) {
StatisticWrapper statisticwrapper = new StatisticWrapper();
if (((JsonElement) entry.getValue()).isJsonPrimitive() && ((JsonElement) entry.getValue()).getAsJsonPrimitive().isNumber()) {
statisticwrapper.a(((JsonElement) entry.getValue()).getAsInt());
} else if (((JsonElement) entry.getValue()).isJsonObject()) {
JsonObject jsonobject1 = ((JsonElement) entry.getValue()).getAsJsonObject();
if (jsonobject1.has("value") && jsonobject1.get("value").isJsonPrimitive() && jsonobject1.get("value").getAsJsonPrimitive().isNumber()) {
statisticwrapper.a(jsonobject1.getAsJsonPrimitive("value").getAsInt());
}
if (jsonobject1.has("progress") && statistic.l() != null) {
try {
Constructor constructor = statistic.l().getConstructor(new Class[0]);
IJsonStatistic ijsonstatistic = (IJsonStatistic) constructor.newInstance(new Object[0]);
ijsonstatistic.a(jsonobject1.get("progress"));
statisticwrapper.a(ijsonstatistic);
} catch (Throwable throwable) {
b.warn("Invalid statistic progress in " + this.d, throwable);
}
}
}
hashmap.put(statistic, statisticwrapper);
} else {
b.warn("Invalid statistic in " + this.d + ": Don\'t know what " + (String) entry.getKey() + " is");
}
}
return hashmap;
}
}
Aggregations