Java 类net.minecraft.util.com.google.gson.JsonObject 实例源码

项目:CraftBukkit    文件:ExpirableListEntry.java   
protected ExpirableListEntry(Object object, JsonObject jsonobject) {
    super(checkExpiry(object, jsonobject), jsonobject); // CraftBukkit - check expiry

    Date date;

    try {
        date = jsonobject.has("created") ? a.parse(jsonobject.get("created").getAsString()) : new Date();
    } catch (ParseException parseexception) {
        date = new Date();
    }

    this.b = date;
    this.c = jsonobject.has("source") ? jsonobject.get("source").getAsString() : "(Unknown)";

    Date date1;

    try {
        date1 = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null;
    } catch (ParseException parseexception1) {
        date1 = null;
    }

    this.d = date1;
    this.e = jsonobject.has("reason") ? jsonobject.get("reason").getAsString() : "Banned by an operator.";
}
项目:Tweakkit-Server    文件:ExpirableListEntry.java   
protected ExpirableListEntry(Object object, JsonObject jsonobject) {
    super(checkExpiry(object, jsonobject), jsonobject); // CraftBukkit - check expiry

    Date date;

    try {
        date = jsonobject.has("created") ? a.parse(jsonobject.get("created").getAsString()) : new Date();
    } catch (ParseException parseexception) {
        date = new Date();
    }

    this.b = date;
    this.c = jsonobject.has("source") ? jsonobject.get("source").getAsString() : "(Unknown)";

    Date date1;

    try {
        date1 = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null;
    } catch (ParseException parseexception1) {
        date1 = null;
    }

    this.d = date1;
    this.e = jsonobject.has("reason") ? jsonobject.get("reason").getAsString() : "Banned by an operator.";
}
项目:Tweakkit-Server    文件:GameProfileBanEntry.java   
private static GameProfile b(JsonObject jsonobject) {
    // Spigot start
    // this whole method has to be reworked to account for the fact Bukkit only accepts UUID bans and gives no way for usernames to be stored!
    UUID uuid = null;
    String name = null;
    if (jsonobject.has("uuid")) {
        String s = jsonobject.get("uuid").getAsString();

        try {
            uuid = UUID.fromString(s);
        } catch (Throwable throwable) {
        }

    }
    if ( jsonobject.has("name"))
    {
        name = jsonobject.get("name").getAsString();
    }
    if ( uuid != null || name != null )
    {
        return new GameProfile( uuid, name );
    } else {
        return null;
    }
    // Spigot End
}
项目:Tweakkit-Server    文件:ServerStatisticManager.java   
public static String a(Map map) {
    JsonObject jsonobject = new JsonObject();
    Iterator iterator = map.entrySet().iterator();

    while (iterator.hasNext()) {
        Entry entry = (Entry) iterator.next();

        if (((StatisticWrapper) entry.getValue()).b() != null) {
            JsonObject jsonobject1 = new JsonObject();

            jsonobject1.addProperty("value", Integer.valueOf(((StatisticWrapper) entry.getValue()).a()));

            try {
                jsonobject1.add("progress", ((StatisticWrapper) entry.getValue()).b().a());
            } catch (Throwable throwable) {
                b.warn("Couldn\'t save statistic " + ((Statistic) entry.getKey()).e() + ": error serializing progress", throwable);
            }

            jsonobject.add(((Statistic) entry.getKey()).name, jsonobject1);
        } else {
            jsonobject.addProperty(((Statistic) entry.getKey()).name, Integer.valueOf(((StatisticWrapper) entry.getValue()).a()));
        }
    }

    return jsonobject.toString();
}
项目:CraftBukkit    文件:ExpirableListEntry.java   
private static Object checkExpiry(Object object, JsonObject jsonobject) {
    Date expires = null;

    try {
        expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null;
    } catch (ParseException ex) {
        // Guess we don't have a date
    }

    if (expires == null || expires.after(new Date())) {
        return object;
    } else {
        return null;
    }
}
项目:CraftBukkit    文件:JsonListEntrySerializer.java   
public JsonListEntry a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
    if (jsonelement.isJsonObject()) {
        JsonObject jsonobject = jsonelement.getAsJsonObject();
        JsonListEntry jsonlistentry = this.a.a(jsonobject);

        return jsonlistentry;
    } else {
        return null;
    }
}
项目:Tweakkit-Server    文件:BanEntrySerializer.java   
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;
}
项目:Tweakkit-Server    文件:ExpirableListEntry.java   
private static Object checkExpiry(Object object, JsonObject jsonobject) {
    Date expires = null;

    try {
        expires = jsonobject.has("expires") ? a.parse(jsonobject.get("expires").getAsString()) : null;
    } catch (ParseException ex) {
        // Guess we don't have a date
    }

    if (expires == null || expires.after(new Date())) {
        return object;
    } else {
        return null;
    }
}
项目:Tweakkit-Server    文件:GameProfileBanEntry.java   
protected void a(JsonObject jsonobject) {
    if (this.getKey() != null) {
        jsonobject.addProperty("uuid", ((GameProfile) this.getKey()).getId() == null ? "" : ((GameProfile) this.getKey()).getId().toString());
        jsonobject.addProperty("name", ((GameProfile) this.getKey()).getName());
        super.a(jsonobject);
    }
}
项目:Tweakkit-Server    文件:JsonListEntrySerializer.java   
public JsonListEntry a(JsonElement jsonelement, Type type, JsonDeserializationContext jsondeserializationcontext) {
    if (jsonelement.isJsonObject()) {
        JsonObject jsonobject = jsonelement.getAsJsonObject();
        JsonListEntry jsonlistentry = this.a.a(jsonobject);

        return jsonlistentry;
    } else {
        return null;
    }
}
项目:CraftBukkit    文件:JsonListEntry.java   
protected JsonListEntry(Object object, JsonObject jsonobject) {
    this.a = object;
}
项目:CraftBukkit    文件:ExpirableListEntry.java   
protected void a(JsonObject jsonobject) {
    jsonobject.addProperty("created", a.format(this.b));
    jsonobject.addProperty("source", this.c);
    jsonobject.addProperty("expires", this.d == null ? "forever" : a.format(this.d));
    jsonobject.addProperty("reason", this.e);
}
项目:CraftBukkit    文件:JsonList.java   
protected JsonListEntry a(JsonObject jsonobject) {
    return new JsonListEntry(null, jsonobject);
}
项目:CraftBukkit    文件:JsonListEntrySerializer.java   
public JsonElement a(JsonListEntry jsonlistentry, Type type, JsonSerializationContext jsonserializationcontext) {
    JsonObject jsonobject = new JsonObject();

    jsonlistentry.a(jsonobject);
    return jsonobject;
}
项目:Tweakkit-Server    文件:BanEntrySerializer.java   
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;
    }
}
项目:Tweakkit-Server    文件:JsonListEntry.java   
protected JsonListEntry(Object object, JsonObject jsonobject) {
    this.a = object;
}
项目:Tweakkit-Server    文件:ExpirableListEntry.java   
protected void a(JsonObject jsonobject) {
    jsonobject.addProperty("created", a.format(this.b));
    jsonobject.addProperty("source", this.c);
    jsonobject.addProperty("expires", this.d == null ? "forever" : a.format(this.d));
    jsonobject.addProperty("reason", this.e);
}
项目:Tweakkit-Server    文件:GameProfileBanEntry.java   
public GameProfileBanEntry(JsonObject jsonobject) {
    super(b(jsonobject), jsonobject);
}
项目:Tweakkit-Server    文件:JsonList.java   
protected JsonListEntry a(JsonObject jsonobject) {
    return new JsonListEntry(null, jsonobject);
}
项目:Tweakkit-Server    文件:JsonListEntrySerializer.java   
public JsonElement a(JsonListEntry jsonlistentry, Type type, JsonSerializationContext jsonserializationcontext) {
    JsonObject jsonobject = new JsonObject();

    jsonlistentry.a(jsonobject);
    return jsonobject;
}
项目:Tweakkit-Server    文件:ServerStatisticManager.java   
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;
    }
}
项目:CraftBukkit    文件:JsonListEntry.java   
protected void a(JsonObject jsonobject) {}
项目:Tweakkit-Server    文件:JsonListEntry.java   
protected void a(JsonObject jsonobject) {}