Search in sources :

Example 6 with JsonObject

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;
}
Also used : JsonObject(net.minecraft.util.com.google.gson.JsonObject) UUID(java.util.UUID)

Example 7 with 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;
    }
}
Also used : GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile) JsonElement(net.minecraft.util.com.google.gson.JsonElement) JsonObject(net.minecraft.util.com.google.gson.JsonObject) ParseException(java.text.ParseException) UUID(java.util.UUID) Date(java.util.Date)

Example 8 with JsonObject

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;
}
Also used : JsonArray(net.minecraft.util.com.google.gson.JsonArray) GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile) JsonObject(net.minecraft.util.com.google.gson.JsonObject)

Example 9 with JsonObject

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;
}
Also used : JsonObject(net.minecraft.util.com.google.gson.JsonObject)

Example 10 with JsonObject

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;
    }
}
Also used : JsonObject(net.minecraft.util.com.google.gson.JsonObject)

Aggregations

JsonObject (net.minecraft.util.com.google.gson.JsonObject)14 Iterator (java.util.Iterator)4 Entry (java.util.Map.Entry)3 UUID (java.util.UUID)3 JsonArray (net.minecraft.util.com.google.gson.JsonArray)3 JsonElement (net.minecraft.util.com.google.gson.JsonElement)3 JsonPrimitive (net.minecraft.util.com.google.gson.JsonPrimitive)2 GameProfile (net.minecraft.util.com.mojang.authlib.GameProfile)2 Constructor (java.lang.reflect.Constructor)1 Type (java.lang.reflect.Type)1 ParseException (java.text.ParseException)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 JsonParser (net.minecraft.util.com.google.gson.JsonParser)1