use of net.minecraft.util.com.google.gson.JsonArray in project mc-dev by Bukkit.
the class ServerPingPlayerSampleSerializer method a.
public JsonElement a(ServerPingPlayerSample serverpingplayersample, Type type, JsonSerializationContext jsonserializationcontext) {
JsonObject jsonobject = new JsonObject();
jsonobject.addProperty("max", Integer.valueOf(serverpingplayersample.a()));
jsonobject.addProperty("online", Integer.valueOf(serverpingplayersample.b()));
if (serverpingplayersample.c() != null && serverpingplayersample.c().length > 0) {
JsonArray jsonarray = new JsonArray();
for (int i = 0; i < serverpingplayersample.c().length; ++i) {
JsonObject jsonobject1 = new JsonObject();
UUID uuid = serverpingplayersample.c()[i].getId();
jsonobject1.addProperty("id", uuid == null ? "" : uuid.toString());
jsonobject1.addProperty("name", serverpingplayersample.c()[i].getName());
jsonarray.add(jsonobject1);
}
jsonobject.add("sample", jsonarray);
}
return jsonobject;
}
use of net.minecraft.util.com.google.gson.JsonArray in project mc-dev by Bukkit.
the class AchievementSet method a.
public JsonElement a() {
JsonArray jsonarray = new JsonArray();
Iterator iterator = this.iterator();
while (iterator.hasNext()) {
String s = (String) iterator.next();
jsonarray.add(new JsonPrimitive(s));
}
return jsonarray;
}
use of net.minecraft.util.com.google.gson.JsonArray in project mc-dev by Bukkit.
the class ServerPingPlayerSampleSerializer method a.
public ServerPingPlayerSample a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
JsonObject jsonobject = ChatDeserializer.l(jsonelement, "players");
ServerPingPlayerSample serverpingplayersample = new ServerPingPlayerSample(ChatDeserializer.m(jsonobject, "max"), ChatDeserializer.m(jsonobject, "online"));
if (ChatDeserializer.d(jsonobject, "sample")) {
JsonArray jsonarray = ChatDeserializer.t(jsonobject, "sample");
if (jsonarray.size() > 0) {
GameProfile[] agameprofile = new GameProfile[jsonarray.size()];
for (int i = 0; i < agameprofile.length; ++i) {
JsonObject jsonobject1 = ChatDeserializer.l(jsonarray.get(i), "player[" + i + "]");
String s = ChatDeserializer.h(jsonobject1, "id");
agameprofile[i] = new GameProfile(UUID.fromString(s), ChatDeserializer.h(jsonobject1, "name"));
}
serverpingplayersample.a(agameprofile);
}
}
return serverpingplayersample;
}
use of net.minecraft.util.com.google.gson.JsonArray in project mc-dev by Bukkit.
the class ChatSerializer method a.
public JsonElement a(IChatBaseComponent ichatbasecomponent, Type type, JsonSerializationContext jsonserializationcontext) {
if (ichatbasecomponent instanceof ChatComponentText && ichatbasecomponent.getChatModifier().g() && ichatbasecomponent.a().isEmpty()) {
return new JsonPrimitive(((ChatComponentText) ichatbasecomponent).g());
} else {
JsonObject jsonobject = new JsonObject();
if (!ichatbasecomponent.getChatModifier().g()) {
this.a(ichatbasecomponent.getChatModifier(), jsonobject, jsonserializationcontext);
}
if (!ichatbasecomponent.a().isEmpty()) {
JsonArray jsonarray = new JsonArray();
Iterator iterator = ichatbasecomponent.a().iterator();
while (iterator.hasNext()) {
IChatBaseComponent ichatbasecomponent1 = (IChatBaseComponent) iterator.next();
jsonarray.add(this.a(ichatbasecomponent1, (Type) ichatbasecomponent1.getClass(), jsonserializationcontext));
}
jsonobject.add("extra", jsonarray);
}
if (ichatbasecomponent instanceof ChatComponentText) {
jsonobject.addProperty("text", ((ChatComponentText) ichatbasecomponent).g());
} else {
if (!(ichatbasecomponent instanceof ChatMessage)) {
throw new IllegalArgumentException("Don\'t know how to serialize " + ichatbasecomponent + " as a Component");
}
ChatMessage chatmessage = (ChatMessage) ichatbasecomponent;
jsonobject.addProperty("translate", chatmessage.i());
if (chatmessage.j() != null && chatmessage.j().length > 0) {
JsonArray jsonarray1 = new JsonArray();
Object[] aobject = chatmessage.j();
int i = aobject.length;
for (int j = 0; j < i; ++j) {
Object object = aobject[j];
if (object instanceof IChatBaseComponent) {
jsonarray1.add(this.a((IChatBaseComponent) object, (Type) object.getClass(), jsonserializationcontext));
} else {
jsonarray1.add(new JsonPrimitive(String.valueOf(object)));
}
}
jsonobject.add("with", jsonarray1);
}
}
return jsonobject;
}
}
Aggregations