Search in sources :

Example 26 with StatsDisplayItem

use of cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem in project Hyperium by HyperiumClient.

the class MurderMysteryStats method getDeepStats.

@Override
public List<StatsDisplayItem> getDeepStats(HypixelApiPlayer player) {
    List<StatsDisplayItem> preview = getPreview(player);
    JsonHolder stats = player.getStats(GameType.MURDER_MYSTERY);
    preview.add(new DisplayLine(""));
    preview.add(new DisplayLine("Classic Stats"));
    preview.add(new DisplayLine(bold("Kills: ", stats.optInt("kills_MURDER_CLASSIC"))));
    preview.add(new DisplayLine(bold("Wins: ", stats.optInt("wins_MURDER_CLASSIC"))));
    preview.add(new DisplayLine(bold("Deaths: ", stats.optInt("deaths_MURDER_CLASSIC"))));
    preview.add(new DisplayLine(bold("Bow Kills: ", stats.optInt("bow_kills"))));
    preview.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills_MURDER_CLASSIC"), stats.optInt("deaths_MURDER_CLASSIC")))));
    preview.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(stats.optInt("wins_MURDER_CLASSIC"), stats.optInt("deaths_MURDER_CLASSIC")))));
    preview.add(new DisplayLine(""));
    preview.add(new DisplayLine("Hardcore Stats"));
    preview.add(new DisplayLine(bold("Kills: ", stats.optInt("kills_MURDER_HARDCORE"))));
    preview.add(new DisplayLine(bold("Wins: ", stats.optInt("wins_MURDER_HARDCORE"))));
    preview.add(new DisplayLine(bold("Deaths: ", stats.optInt("deaths_MURDER_HARDCORE"))));
    preview.add(new DisplayLine(bold("Bow Kills: ", stats.optInt("bow_kills"))));
    preview.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills_MURDER_HARDCORE"), stats.optInt("deaths_MURDER_HARDCORE")))));
    preview.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(stats.optInt("wins_MURDER_HARDCORE"), stats.optInt("deaths_MURDER_HARDCORE")))));
    preview.add(new DisplayLine(""));
    preview.add(new DisplayLine("Assassins Stats"));
    preview.add(new DisplayLine(bold("Kills: ", stats.optInt("kills_MURDER_ASSASSINS"))));
    preview.add(new DisplayLine(bold("Wins: ", stats.optInt("wins_MURDER_ASSASSINS"))));
    preview.add(new DisplayLine(bold("Deaths: ", stats.optInt("deaths_MURDER_ASSASSINS"))));
    preview.add(new DisplayLine(bold("Bow Kills: ", stats.optInt("bow_kills"))));
    preview.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills_MURDER_ASSASSINS"), stats.optInt("deaths_MURDER_ASSASSINS")))));
    preview.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(stats.optInt("wins_MURDER_ASSASSINS"), stats.optInt("deaths_MURDER_ASSASSINS")))));
    String[] murderMysteryModes = { "All", "Classic", "Assassins", "Hardcore" };
    String[] murderMysteryNames = { "", "_MURDER_CLASSIC", "_MURDER_ASSASIANS", "_MURDER_HARDCORE" };
    List<String[]> lines = new ArrayList<>();
    preview.add(new DisplayLine(""));
    lines.add(new String[] { "Mode", "Kills", "Wins", "Deaths", "Hero", "Bow Kills" });
    for (int i = 0; i < murderMysteryModes.length; i++) {
        String name = murderMysteryModes[i];
        String seed = murderMysteryNames[i];
        lines.add(new String[] { name, String.valueOf(stats.optInt("kills" + seed)), String.valueOf(stats.optInt("wins" + seed)), String.valueOf(stats.optInt("deaths" + seed)), String.valueOf(stats.optInt("was_hero" + seed)), String.valueOf(stats.optInt("bow_kills" + seed)) });
    }
    preview.add(new DisplayTable(lines));
    return preview;
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) DisplayLine(cc.hyperium.handlers.handlers.stats.display.DisplayLine) DisplayTable(cc.hyperium.handlers.handlers.stats.display.DisplayTable) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) ArrayList(java.util.ArrayList)

Example 27 with StatsDisplayItem

use of cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem 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 28 with StatsDisplayItem

use of cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem 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 29 with StatsDisplayItem

use of cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem in project Hyperium by HyperiumClient.

the class AbstractHypixelStats method getPreview.

public List<StatsDisplayItem> getPreview(HypixelApiPlayer player) {
    ArrayList<StatsDisplayItem> items = new ArrayList<>();
    GameType gameType = GameType.fromRealName(getName());
    if (gameType == null) {
        items.add(new DisplayLine("No default preview for " + getName(), Color.WHITE.getRGB()));
    } else {
        JsonHolder stats = player.getStats(gameType);
        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("Losses: ", stats.optInt("losses")), Color.WHITE.getRGB()));
        items.add(new DisplayLine(bold("K/D: ", WebsiteUtils.buildRatio(stats.optInt("kills"), stats.optInt("deaths"))), Color.WHITE.getRGB()));
        items.add(new DisplayLine(bold("W/L: ", WebsiteUtils.buildRatio(stats.optInt("wins"), stats.optInt("losses"))), 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) GameType(net.hypixel.api.GameType)

Example 30 with StatsDisplayItem

use of cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem in project Hyperium by HyperiumClient.

the class PlayerStatsGui method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    if (!texturesImage.isEmpty()) {
        texturesImage.forEach((s, value) -> {
            if (!logos.containsKey(s))
                logos.put(s, new DynamicTexture(value));
        });
    }
    super.drawScreen(mouseX, mouseY, partialTicks);
    ScaledResolution current = ResolutionUtil.current();
    HypixelApiGuild guild = player.getGuild();
    if (guild == null) {
        GeneralChatHandler.instance().sendMessage("Player not found!");
        mc.displayGuiScreen(null);
        return;
    }
    boolean isInGuild = guild.isLoaded() && guild.isValid();
    drawScaledText(player.getDisplayString() + (isInGuild ? " " + guild.getFormatedTag() : ""), current.getScaledWidth() / 2, 30, 2, -1, true, true);
    if (focused == null) {
        final int blockWidth = 64 + 32;
        int blocksPerLine = (int) (current.getScaledWidth() / (1.2D * blockWidth));
        if (blocksPerLine % 2 == 1) {
            blocksPerLine--;
        }
        final int startX = ResolutionUtil.current().getScaledWidth() / 2 - (blocksPerLine * blockWidth / 2);
        int x = -1;
        int y = 0;
        hovered = null;
        for (AbstractHypixelStats field : fields) {
            DynamicTexture dynamicTexture = logos.get(field);
            x++;
            if (x > blocksPerLine) {
                x = 0;
                y++;
            }
            if (dynamicTexture != null) {
                int y1 = 100 + y * blockWidth - 10 - offset;
                if (y1 < 70)
                    continue;
                GlStateManager.pushMatrix();
                GlStateManager.resetColor();
                GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
                int y2 = 100 + y * blockWidth - offset;
                int x1 = startX + x * blockWidth;
                GuiBlock value = new GuiBlock(x1, x1 + blockWidth / 2, y2, y2 + blockWidth / 2);
                if (value.isMouseOver(mouseX, mouseY)) {
                    hovered = field;
                }
                location.put(field, value);
                GlStateManager.translate(x1, y2, 0);
                GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
                GlStateManager.scale(.2, .2, .2);
                drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
                GlStateManager.popMatrix();
                GlStateManager.pushMatrix();
                GlStateManager.translate(startX + x * blockWidth + 24, y1, 0);
                drawScaledText(field.getName(), 0, 0, 1.0, Color.RED.getRGB(), true, true);
                GlStateManager.popMatrix();
            }
        }
        if (hovered != null) {
            List<StatsDisplayItem> preview = hovered.getPreview(player);
            int width = 0;
            int height = 0;
            for (StatsDisplayItem statsDisplayItem : preview) {
                width = Math.max(width, statsDisplayItem.width);
                height += statsDisplayItem.height;
            }
            GuiBlock block = location.get(hovered);
            int xOffset = 0;
            int yRenderOffset = 16;
            int rightSide = block.getRight() + (width + yRenderOffset) * 2;
            if (rightSide > current.getScaledWidth()) {
                xOffset = rightSide - current.getScaledWidth();
            }
            float scale = 1.0F;
            GlStateManager.scale(scale, scale, scale);
            int left = block.getRight() - xOffset + yRenderOffset - 8;
            int top = block.getTop();
            int printY = 0;
            if (top + height * 2 > current.getScaledHeight()) {
                top = current.getScaledHeight() - height * 2 - 50;
            }
            RenderUtils.drawRect((left - 3) / scale, (top - 3) / scale, (left + (width + 3) * scale) / scale, (top + (height + 3) * scale) / scale, new Color(0, 0, 0, 220).getRGB());
            for (StatsDisplayItem statsDisplayItem : preview) {
                statsDisplayItem.draw((int) (left / scale), (int) ((top) / scale) + printY);
                printY += statsDisplayItem.height;
            }
            GlStateManager.scale(1 / scale, 1 / scale, 1 / scale);
        }
    } else {
        DynamicTexture dynamicTexture = logos.get(focused);
        GlStateManager.resetColor();
        GlStateManager.pushMatrix();
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
        GlStateManager.bindTexture(dynamicTexture.getGlTextureId());
        GlStateManager.translate((current.getScaledWidth() >> 1) - 24, 80, 0);
        GlStateManager.scale(.2, .2, .2);
        drawTexturedModalRect(0, 0, 0, 0, 128 * 2, 128 * 2);
        GlStateManager.popMatrix();
        GlStateManager.pushMatrix();
        drawScaledText(focused.getName(), current.getScaledWidth() / 2, 60, 2.0, Color.RED.getRGB(), true, true);
        Icons.EXTENSION.bind();
        GlStateModifier.INSTANCE.reset();
        Icons.EXIT.bind();
        float scale = 2.0F;
        GlStateManager.scale(scale, scale, scale);
        GlStateManager.translate(current.getScaledWidth() / 2F / scale - 90 / scale, (73) / scale, 0);
        GlStateManager.rotate(180, 0.0F, 0.0F, 1.0F);
        GlStateManager.translate(-16, -16, 0);
        drawScaledCustomSizeModalRect(0, 0, 0, 0, 64, 64, 16, 16, 64, 64);
        GlStateManager.popMatrix();
    }
}
Also used : ScaledResolution(net.minecraft.client.gui.ScaledResolution) HypixelApiGuild(club.sk1er.website.api.requests.HypixelApiGuild) StatsDisplayItem(cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) GuiBlock(cc.hyperium.gui.GuiBlock)

Aggregations

StatsDisplayItem (cc.hyperium.handlers.handlers.stats.display.StatsDisplayItem)45 DisplayLine (cc.hyperium.handlers.handlers.stats.display.DisplayLine)43 JsonHolder (cc.hyperium.utils.JsonHolder)42 ArrayList (java.util.ArrayList)33 DisplayTable (cc.hyperium.handlers.handlers.stats.display.DisplayTable)10 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 GuiBlock (cc.hyperium.gui.GuiBlock)1 Pet (club.sk1er.website.Pet)1 HypixelApiGuild (club.sk1er.website.api.requests.HypixelApiGuild)1 ExecutionException (java.util.concurrent.ExecutionException)1 GameType (net.hypixel.api.GameType)1 ScaledResolution (net.minecraft.client.gui.ScaledResolution)1 DynamicTexture (net.minecraft.client.renderer.texture.DynamicTexture)1