Search in sources :

Example 46 with JsonHolder

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);
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 47 with JsonHolder

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;
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) ArrayList(java.util.ArrayList) ExecutionException(java.util.concurrent.ExecutionException)

Example 48 with JsonHolder

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;
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) DisplayLine(cc.hyperium.handlers.handlers.stats.display.DisplayLine) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) ArrayList(java.util.ArrayList)

Example 49 with JsonHolder

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);
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) JsonElement(com.google.gson.JsonElement) JsonObject(com.google.gson.JsonObject) ExecutionException(java.util.concurrent.ExecutionException) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 50 with JsonHolder

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"));
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) UUID(java.util.UUID)

Aggregations

JsonHolder (cc.hyperium.utils.JsonHolder)81 DisplayLine (cc.hyperium.handlers.handlers.stats.display.DisplayLine)42 StatsDisplayItem (cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem)42 ArrayList (java.util.ArrayList)34 NettyClient (cc.hyperium.netty.NettyClient)13 DisplayTable (cc.hyperium.handlers.handlers.stats.display.DisplayTable)10 JsonArray (com.google.gson.JsonArray)9 JsonElement (com.google.gson.JsonElement)8 HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)5 JsonObject (com.google.gson.JsonObject)5 URL (java.net.URL)5 UUID (java.util.UUID)5 HashMap (java.util.HashMap)4 InvokeEvent (cc.hyperium.event.InvokeEvent)3 PurchaseLoadEvent (cc.hyperium.event.network.PurchaseLoadEvent)3 AbstractAnimationHandler (cc.hyperium.handlers.handlers.animation.AbstractAnimationHandler)3 DisplayItem (cc.hyperium.mods.chromahud.api.DisplayItem)3 IOException (java.io.IOException)3 ExecutionException (java.util.concurrent.ExecutionException)3 GuiButton (net.minecraft.client.gui.GuiButton)3