Search in sources :

Example 1 with CapesGui

use of cc.hyperium.gui.CapesGui in project Hyperium by HyperiumClient.

the class ShopTab method addComponents.

private void addComponents() {
    CollapsibleTabComponent infoTab = new CollapsibleTabComponent(this, new ArrayList<>(), "Info");
    infoTab.setCollapsed(false);
    infoTab.addChild(new LabelComponent(this, new ArrayList<>(), "Total Credits: " + personData.optInt("total_credits")));
    infoTab.addChild(new LabelComponent(this, new ArrayList<>(), "Remaining Credits: " + personData.optInt("remaining_credits")));
    infoTab.addChild(new ButtonComponent(this, new ArrayList<>(), "Capes", () -> Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new CapesGui())));
    infoTab.addChild(new ButtonComponent(this, new ArrayList<>(), "Particles", () -> new ParticleGui().show()));
    infoTab.addChild(new ButtonComponent(this, new ArrayList<>(), "Open in browser", () -> {
        Desktop desktop = Desktop.getDesktop();
        if (desktop != null) {
            try {
                desktop.browse(new URI("https://hyperium.sk1er.club"));
            } catch (IOException | URISyntaxException e) {
                e.printStackTrace();
            }
        }
    }));
    infoTab.addChild(new ButtonComponent(this, new ArrayList<>(), "Purchase credits", () -> {
        Desktop desktop = Desktop.getDesktop();
        if (desktop != null) {
            try {
                desktop.browse(new URI("https://purchase.sk1er.club/category/1125808"));
            } catch (IOException | URISyntaxException e) {
                e.printStackTrace();
            }
        }
    }));
    infoTab.addChild(new ButtonComponent(this, new ArrayList<>(), "Refresh", this::refreshData));
    CollapsibleTabComponent purchaseTab = new CollapsibleTabComponent(this, Arrays.asList("Purchase", "Shop"), "Purchase");
    cosmeticCallback.getKeys().forEach(key -> {
        JsonHolder cosmetic = cosmeticCallback.optJSONObject(key);
        if (cosmetic.optBoolean("cape") || key.toLowerCase().startsWith("particle") || cosmetic.optString("name").toLowerCase().endsWith("animation")) {
            return;
        }
        CollapsibleTabComponent purchase = new CollapsibleTabComponent(this, new ArrayList<>(), cosmetic.optString("name"));
        purchase.addChild(new LabelComponent(this, new ArrayList<>(), cosmetic.optString("name") + " (" + cosmetic.optInt("cost") + " credits)"));
        purchase.addChild(new LabelComponent(this, new ArrayList<>(), cosmetic.optString("description")));
        purchase.addChild(new ButtonComponent(this, new ArrayList<>(), cosmetic.optBoolean("purchased") ? "PURCHASED" : "PURCHASE", () -> {
            if (cosmetic.optBoolean("purchased")) {
                Hyperium.INSTANCE.getHandlers().getGeneralChatHandler().sendMessage("You have already purchased " + cosmetic.optString("name") + ".");
                return;
            }
            Hyperium.LOGGER.info("Attempting to purchase {}", key);
            NettyClient client = NettyClient.getClient();
            if (client != null) {
                client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("cosmetic_purchase", true).put("value", key)));
            }
        }));
        purchaseTab.addChild(purchase);
    });
    components.addAll(Arrays.asList(infoTab, purchaseTab));
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) NettyClient(cc.hyperium.netty.NettyClient) CapesGui(cc.hyperium.gui.CapesGui) ArrayList(java.util.ArrayList) CollapsibleTabComponent(cc.hyperium.gui.hyperium.components.CollapsibleTabComponent) ParticleGui(cc.hyperium.gui.ParticleGui) URI(java.net.URI) ButtonComponent(cc.hyperium.gui.hyperium.components.ButtonComponent) LabelComponent(cc.hyperium.gui.hyperium.components.LabelComponent)

Aggregations

CapesGui (cc.hyperium.gui.CapesGui)1 ParticleGui (cc.hyperium.gui.ParticleGui)1 ButtonComponent (cc.hyperium.gui.hyperium.components.ButtonComponent)1 CollapsibleTabComponent (cc.hyperium.gui.hyperium.components.CollapsibleTabComponent)1 LabelComponent (cc.hyperium.gui.hyperium.components.LabelComponent)1 NettyClient (cc.hyperium.netty.NettyClient)1 JsonHolder (cc.hyperium.utils.JsonHolder)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1