use of cc.hyperium.mods.levelhead.renderer.LevelheadTag in project Hyperium by HyperiumClient.
the class Levelhead method buildTag.
private LevelheadTag buildTag(LevelheadJsonHolder object, UUID uuid, LevelheadDisplay display, boolean allowOverride) {
LevelheadTag value = new LevelheadTag(uuid);
LevelheadJsonHolder headerObj = new LevelheadJsonHolder();
LevelheadJsonHolder footerObj = new LevelheadJsonHolder();
LevelheadJsonHolder construct = new LevelheadJsonHolder();
if (object.has("header_obj") && allowOverride) {
headerObj = object.optJsonObject("header_obj");
headerObj.put("custom", true);
}
if (object.has("footer_obj") && allowOverride) {
footerObj = object.optJsonObject("footer_obj");
footerObj.put("custom", true);
}
if (object.has("header") && allowOverride) {
headerObj.put("header", object.optString("header"));
headerObj.put("custom", true);
}
headerObj.merge(display.getHeaderConfig(), !allowOverride);
footerObj.merge(display.getFooterConfig().put("footer", object.optString("strlevel", format.format(object.getInt("level")))), !allowOverride);
construct.put("exclude", object.optBoolean("exclude"));
construct.put("header", headerObj).put("footer", footerObj);
construct.put("exclude", object.optBoolean("exclude"));
construct.put("custom", object.optJsonObject("custom"));
value.construct(construct);
return value;
}
use of cc.hyperium.mods.levelhead.renderer.LevelheadTag 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);
}
Aggregations