use of cc.hyperium.gui.hyperium.components.ButtonComponent 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));
}
Aggregations