use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ParticleAuraHandler method loadPurchaseEvent.
@InvokeEvent
public void loadPurchaseEvent(PurchaseLoadEvent purchaseLoadEvent) {
HyperiumPurchase purchase = purchaseLoadEvent.getPurchase();
auras.remove(purchase.getPlayerUUID());
JsonHolder purchaseSettings = purchase.getPurchaseSettings();
if (!purchaseSettings.has("particle"))
return;
JsonHolder data = purchaseSettings.optJSONObject("particle");
String particle_animation1 = data.optString("particle_animation");
AbstractAnimation particle_animation = animations.get(particle_animation1);
EnumParticleType type = EnumParticleType.parse(data.optString("type"));
if (particle_animation == null || type == null)
return;
if (!purchase.hasPurchased("PARTICLE_" + type.name()) || !purchase.hasPurchased("ANIMATION_" + (particle_animation1.toUpperCase().replace(" ", "_")))) {
return;
}
boolean rgb = data.optBoolean("rgb");
boolean chroma = data.optBoolean("chroma");
ParticleAura max_age = new ParticleAura(renderEngines.get(type), particle_animation, data.optInt("max_age", 2), chroma, rgb);
max_age.setRgb(data.optInt("red"), data.optInt("green"), data.optInt("blue"));
auras.put(purchase.getPlayerUUID(), max_age);
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class AbstractHypixelStats method getQuests.
public List<StatsDisplayItem> getQuests(HypixelApiPlayer player) {
JsonHolder quests = null;
try {
quests = Hyperium.INSTANCE.getHandlers().getDataHandler().getQuests().get();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
ArrayList<StatsDisplayItem> statsDisplayItems = new ArrayList<>();
totalDaily = 0;
totalWeekly = 0;
completedDaily = 0;
completedWeekly = 0;
process(player, statsDisplayItems, quests.optJSONObject("quests").optJSONArray(getGameType().getQuestName()));
return statsDisplayItems;
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class BlitzStats method getPreview.
@Override
public List<StatsDisplayItem> getPreview(HypixelApiPlayer player) {
ArrayList<StatsDisplayItem> items = new ArrayList<>();
JsonHolder stats = player.getStats(GameType.SURVIVAL_GAMES);
items.add(new DisplayLine(bold("Coins: ", stats.optInt("coins")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Kills: ", stats.optInt("kills")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Deaths: ", stats.optInt("deaths")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("Wins: ", stats.optInt("wins")), Color.WHITE.getRGB()));
items.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills"), stats.optInt("deaths"))), Color.WHITE.getRGB()));
return items;
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class HypixelFriendsGui method onRemove.
@InvokeEvent
public void onRemove(FriendRemoveEvent event) {
JsonHolder friends = null;
try {
friends = Hyperium.INSTANCE.getHandlers().getDataHandler().getFriendsForCurrentUser().get().getData();
} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
}
String key = null;
for (Map.Entry<String, JsonElement> stringJsonElementEntry : friends.getObject().entrySet()) {
if (!(stringJsonElementEntry.getValue() instanceof JsonObject))
continue;
String display = stringJsonElementEntry.getValue().getAsJsonObject().get("display").getAsString();
if (EnumChatFormatting.getTextWithoutFormattingCodes(display).contains(event.getFullName()))
key = stringJsonElementEntry.getKey();
}
if (key != null) {
friends.remove(key);
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class MojangAuth method auth.
public void auth() {
UUID uuid = Minecraft.getMinecraft().getSession().getProfile().getId();
JsonHolder jsonHolder = new JsonHolder(Sk1erMod.getInstance().rawWithAgent("https://api.sk1er.club/auth/begin?uuid=" + uuid + "&mod=LEVEL_HEAD&ver=" + Levelhead.VERSION));
if (!jsonHolder.optBoolean("success")) {
fail("Error during init: " + jsonHolder);
return;
}
hash = jsonHolder.optString("hash");
String session = Minecraft.getMinecraft().getSession().getToken();
Hyperium.LOGGER.debug("Logging in with details: Server-Hash: {}, Session: {}, UUID: {}", hash, session, uuid);
int statusCode = LoginUtil.joinServer(session, uuid.toString().replace("-", ""), hash);
if (statusCode / 100 != 2) {
fail("Error during Mojang Auth (1) " + statusCode);
return;
}
JsonHolder finalResponse = new JsonHolder(Sk1erMod.getInstance().rawWithAgent("https://api.sk1er.club/auth/final?hash=" + hash + "&name=" + Minecraft.getMinecraft().getSession().getProfile().getName()));
Hyperium.LOGGER.debug("FINAL RESPONSE: " + finalResponse);
if (finalResponse.optBoolean("success")) {
accessKey = finalResponse.optString("access_key");
success = true;
Hyperium.LOGGER.info("Successfully authenticated with Sk1er.club Levelhead");
} else {
fail("Error during final auth. Reason: " + finalResponse.optString("cause"));
}
}
Aggregations