use of net.minecraft.util.com.google.gson.JsonObject in project mc-dev by Bukkit.
the class BanEntrySerializer method a.
public JsonElement a(UserCacheEntry usercacheentry, Type type, JsonSerializationContext jsonserializationcontext) {
JsonObject jsonobject = new JsonObject();
jsonobject.addProperty("name", usercacheentry.a().getName());
UUID uuid = usercacheentry.a().getId();
jsonobject.addProperty("uuid", uuid == null ? "" : uuid.toString());
jsonobject.addProperty("expiresOn", UserCache.a.format(usercacheentry.b()));
return jsonobject;
}
use of net.minecraft.util.com.google.gson.JsonObject in project mc-dev by Bukkit.
the class BanEntrySerializer method a.
public UserCacheEntry a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
if (jsonelement.isJsonObject()) {
JsonObject jsonobject = jsonelement.getAsJsonObject();
JsonElement jsonelement1 = jsonobject.get("name");
JsonElement jsonelement2 = jsonobject.get("uuid");
JsonElement jsonelement3 = jsonobject.get("expiresOn");
if (jsonelement1 != null && jsonelement2 != null) {
String s = jsonelement2.getAsString();
String s1 = jsonelement1.getAsString();
Date date = null;
if (jsonelement3 != null) {
try {
date = UserCache.a.parse(jsonelement3.getAsString());
} catch (ParseException parseexception) {
date = null;
}
}
if (s1 != null && s != null) {
UUID uuid;
try {
uuid = UUID.fromString(s);
} catch (Throwable throwable) {
return null;
}
UserCacheEntry usercacheentry = new UserCacheEntry(this.a, new GameProfile(uuid, s1), date, (GameProfileLookup) null);
return usercacheentry;
} else {
return null;
}
} else {
return null;
}
} else {
return null;
}
}
use of net.minecraft.util.com.google.gson.JsonObject 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.JsonObject in project mc-dev by Bukkit.
the class ServerPingSerializer method a.
public ServerPing a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
JsonObject jsonobject = ChatDeserializer.l(jsonelement, "status");
ServerPing serverping = new ServerPing();
if (jsonobject.has("description")) {
serverping.setMOTD((IChatBaseComponent) jsondeserializationcontext.deserialize(jsonobject.get("description"), IChatBaseComponent.class));
}
if (jsonobject.has("players")) {
serverping.setPlayerSample((ServerPingPlayerSample) jsondeserializationcontext.deserialize(jsonobject.get("players"), ServerPingPlayerSample.class));
}
if (jsonobject.has("version")) {
serverping.setServerInfo((ServerPingServerData) jsondeserializationcontext.deserialize(jsonobject.get("version"), ServerPingServerData.class));
}
if (jsonobject.has("favicon")) {
serverping.setFavicon(ChatDeserializer.h(jsonobject, "favicon"));
}
return serverping;
}
use of net.minecraft.util.com.google.gson.JsonObject in project mc-dev by Bukkit.
the class ChatModifierSerializer method a.
public JsonElement a(ChatModifier chatmodifier, Type type, JsonSerializationContext jsonserializationcontext) {
if (chatmodifier.g()) {
return null;
} else {
JsonObject jsonobject = new JsonObject();
if (ChatModifier.b(chatmodifier) != null) {
jsonobject.addProperty("bold", ChatModifier.b(chatmodifier));
}
if (ChatModifier.c(chatmodifier) != null) {
jsonobject.addProperty("italic", ChatModifier.c(chatmodifier));
}
if (ChatModifier.d(chatmodifier) != null) {
jsonobject.addProperty("underlined", ChatModifier.d(chatmodifier));
}
if (ChatModifier.e(chatmodifier) != null) {
jsonobject.addProperty("strikethrough", ChatModifier.e(chatmodifier));
}
if (ChatModifier.f(chatmodifier) != null) {
jsonobject.addProperty("obfuscated", ChatModifier.f(chatmodifier));
}
if (ChatModifier.g(chatmodifier) != null) {
jsonobject.add("color", jsonserializationcontext.serialize(ChatModifier.g(chatmodifier)));
}
JsonObject jsonobject1;
if (ChatModifier.h(chatmodifier) != null) {
jsonobject1 = new JsonObject();
jsonobject1.addProperty("action", ChatModifier.h(chatmodifier).a().b());
jsonobject1.addProperty("value", ChatModifier.h(chatmodifier).b());
jsonobject.add("clickEvent", jsonobject1);
}
if (ChatModifier.i(chatmodifier) != null) {
jsonobject1 = new JsonObject();
jsonobject1.addProperty("action", ChatModifier.i(chatmodifier).a().b());
jsonobject1.add("value", jsonserializationcontext.serialize(ChatModifier.i(chatmodifier).b()));
jsonobject.add("hoverEvent", jsonobject1);
}
return jsonobject;
}
}
Aggregations