Search in sources :

Example 1 with NullLevelheadTag

use of cc.hyperium.mods.levelhead.renderer.NullLevelheadTag in project Hyperium by HyperiumClient.

the class Levelhead method fetch.

public void fetch(UUID uuid, LevelheadDisplay display, boolean allowOverride) {
    if (updates >= count) {
        waitUntil = System.currentTimeMillis() + 1000 * wait;
        updates = 0;
        return;
    }
    updates++;
    display.getCache().put(uuid, new NullLevelheadTag(null));
    String type = display.getConfig().getType();
    if (purchaseStatus.has(type) && !purchaseStatus.optBoolean(type)) {
        LevelheadJsonHolder fakeValue = new LevelheadJsonHolder();
        fakeValue.put("header", "Error");
        fakeValue.put("strlevel", "Item '" + type + "' not purchased. If you believe this is an error, contact Sk1er");
        fakeValue.put("success", true);
        display.getCache().put(uuid, buildTag(fakeValue, uuid, display, allowOverride));
        return;
    }
    Multithreading.runAsync(() -> {
        String raw = rawWithAgent("https://api.sk1er.club/levelheadv5/" + trimUuid(uuid) + "/" + type + "/" + trimUuid(Minecraft.getMinecraft().getSession().getProfile().getId()) + "/" + VERSION + "/" + auth.getHash() + "/" + display.getPosition().name());
        LevelheadJsonHolder object = new LevelheadJsonHolder(raw);
        if (!object.optBoolean("success")) {
            object.put("strlevel", "Error");
        }
        if (!allowOverride) {
            object.put("strlevel", object.optString("level"));
            object.remove("header_obj");
            object.remove("footer_obj");
        }
        LevelheadTag value = buildTag(object, uuid, display, allowOverride);
        display.getCache().put(uuid, value);
        display.getTrueValueCache().put(uuid, object.optString("strlevel"));
    });
    Multithreading.POOL.submit(this::clearCache);
}
Also used : NullLevelheadTag(cc.hyperium.mods.levelhead.renderer.NullLevelheadTag) LevelheadTag(cc.hyperium.mods.levelhead.renderer.LevelheadTag) NullLevelheadTag(cc.hyperium.mods.levelhead.renderer.NullLevelheadTag) LevelheadJsonHolder(cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)

Aggregations

LevelheadTag (cc.hyperium.mods.levelhead.renderer.LevelheadTag)1 NullLevelheadTag (cc.hyperium.mods.levelhead.renderer.NullLevelheadTag)1 LevelheadJsonHolder (cc.hyperium.mods.levelhead.util.LevelheadJsonHolder)1