use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ParticleGui method rebuild.
private void rebuild() {
EnumParticleType[] values = EnumParticleType.values();
int length = values.length;
HyperiumPurchase self = PurchaseApi.getInstance().getSelf();
if (self == null) {
queueBuild = true;
return;
}
JsonHolder purchaseSettings = self.getPurchaseSettings();
if (!purchaseSettings.has("particle"))
purchaseSettings.put("particle", new JsonHolder());
JsonHolder particle = purchaseSettings.optJSONObject("particle");
CarouselItem[] particles = new CarouselItem[length];
for (int i = 0; i < length; i++) {
EnumParticleType value = values[i];
final boolean flag = self.hasPurchased("PARTICLE_" + value.name());
particles[i] = new CarouselItem(value.getName(), flag, false, carouselItem -> {
if (!flag) {
if (credits < 300) {
GeneralChatHandler.instance().sendMessage(I18n.format("message.insufficientcredits"));
return;
}
int i4 = ++purchaseIds;
GuiYesNo gui = new GuiYesNo(this, I18n.format("message.purchase", value.getName()), "", i4);
Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(gui);
ids.put(i4, () -> {
GeneralChatHandler.instance().sendMessage(I18n.format("message.attemptingpurchase", value.getName()));
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("cosmetic_purchase", true).put("value", "PARTICLE_" + value.name())));
}
});
} else {
GeneralChatHandler.instance().sendMessage(I18n.format("message.alreadypurchased", value.getName()));
}
}, carouselItem -> {
if (!flag)
return;
overlay = new HyperiumOverlay("Particles");
String s = particle.optBoolean("rgb") ? "RGB" : particle.optBoolean("chroma") ? "CHROMA" : "DEFAULT";
overlay.getComponents().add(new OverlaySelector<>("Color Type", s, s1 -> {
if (s1.equals("DEFAULT")) {
particle.put("chroma", false);
particle.put("rgb", false);
} else if (s1.equals("CHROMA")) {
particle.put("chroma", true);
particle.put("rgb", false);
} else if (s1.equalsIgnoreCase("RGB")) {
particle.put("rgb", true);
particle.put("chroma", false);
}
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("color_type", s1)));
}
// Rebuild auto called on purchase update
}, () -> new String[] { "DEFAULT", "RGB", "CHROMA" }));
overlay.getComponents().add(new OverlaySlider(I18n.format("gui.cosmetics.red"), 0, 255, particle.optInt("red", 255), aFloat -> {
particle.put("red", aFloat);
EventBus.INSTANCE.post(new PurchaseLoadEvent(Objects.requireNonNull(UUIDUtil.getClientUUID()), self, true));
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("red", aFloat.intValue())));
}
}, true));
overlay.getComponents().add(new OverlaySlider(I18n.format("gui.cosmetics.green"), 0, 255, particle.optInt("green", 255), aFloat -> {
particle.put("green", aFloat);
EventBus.INSTANCE.post(new PurchaseLoadEvent(Objects.requireNonNull(UUIDUtil.getClientUUID()), self, true));
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("green", aFloat.intValue())));
}
}, true));
overlay.getComponents().add(new OverlaySlider(I18n.format("gui.cosmetics.blue"), 0, 255, particle.optInt("blue", 255), aFloat -> {
particle.put("blue", aFloat);
EventBus.INSTANCE.post(new PurchaseLoadEvent(Objects.requireNonNull(UUIDUtil.getClientUUID()), self, true));
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("blue", aFloat.intValue())));
}
}, true));
overlay.getComponents().add(new OverlaySlider(I18n.format("gui.cosmetics.maxage"), 2, 100, particle.optInt("max_age", 10), aFloat -> {
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("max_age", aFloat.intValue())));
}
}, true));
}, carouselItem -> {
particle.put("type", value.name());
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("active_type", value.name())));
}
Arrays.stream(particles).forEach(item -> item.setActive(false));
carouselItem.setActive(true);
});
}
int spot = 0;
try {
spot = EnumParticleType.valueOf(particle.optString("type")).ordinal();
} catch (Exception e) {
e.printStackTrace();
}
if (particles[spot].isPurchased())
particles[spot].setPurchased(true);
particleType = PurchaseCarousel.create(spot, particles);
ParticleAuraHandler particleAuraHandler = Hyperium.INSTANCE.getHandlers().getParticleAuraHandler();
HashMap<String, AbstractAnimation> animations = particleAuraHandler.getAnimations();
String[] keys = { "Double Twirl", "Tornado", "Double Helix", "Triple Twirl", "Quad Twirl", "Static Trail", "Explode", "Vortex of doom" };
CarouselItem[] animationItems = new CarouselItem[animations.size()];
int c = 0;
int g = 0;
for (String s : keys) {
boolean flag = self.hasPurchased("ANIMATION_" + s.replace(" ", "_".toUpperCase()));
boolean flag1 = particle.optString("particle_animation").equalsIgnoreCase(s);
if (flag1)
g = c;
animationItems[c] = new CarouselItem(s, flag, flag1, carouselItem -> {
if (!flag) {
int i4 = ++purchaseIds;
GuiYesNo gui = new GuiYesNo(this, I18n.format("message.purchase", s), "", i4);
Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(gui);
ids.put(i4, () -> {
GeneralChatHandler.instance().sendMessage(I18n.format("message.attemptingpurchase", s));
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("cosmetic_purchase", true).put("value", "ANIMATION_" + s.replace(" ", "_").toUpperCase())));
}
});
} else {
GeneralChatHandler.instance().sendMessage(I18n.format("message.alreadypurchased", s));
}
}, carouselItem -> {
// No settings as of now
}, carouselItem -> {
particle.put("particle_animation", s);
NettyClient client = NettyClient.getClient();
if (client != null) {
client.write(ServerCrossDataPacket.build(new JsonHolder().put("internal", true).put("particle_update", true).put("particle_animation", s)));
}
Arrays.stream(animationItems).forEach(animationItem -> animationItem.setActive(false));
carouselItem.setActive(true);
});
c++;
}
particleAnimation = PurchaseCarousel.create(g, animationItems);
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ParticleGui method mouseClicked.
@Override
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
super.mouseClicked(mouseX, mouseY, mouseButton);
if (previewBlock != null && previewBlock.isMouseOver(mouseX, mouseY) && overlay == null) {
mc.displayGuiScreen(null);
Minecraft.getMinecraft().gameSettings.thirdPersonView = 2;
EnumParticleType type = null;
for (EnumParticleType enumParticleType : EnumParticleType.values()) {
if (enumParticleType.getName().equalsIgnoreCase(particleType.getCurrent().getName())) {
type = enumParticleType;
}
}
if (type == null) {
GeneralChatHandler.instance().sendMessage(I18n.format("message.invalidparticle"));
return;
}
HyperiumPurchase self = PurchaseApi.getInstance().getSelf();
String name = particleAnimation.getCurrent().getName();
if (Hyperium.INSTANCE.getHandlers().getParticleAuraHandler().getAnimations().get(name) == null) {
GeneralChatHandler.instance().sendMessage(I18n.format("message.invalidanimation"));
return;
}
JsonHolder oldsettings = new JsonHolder(self.getPurchaseSettings().getObject().toString());
JsonHolder purchaseSettings = self.getPurchaseSettings();
if (purchaseSettings.has("particle"))
purchaseSettings.put("particle", new JsonHolder());
JsonHolder holder = purchaseSettings.optJSONObject("particle");
holder.put("type", type.name());
holder.put("particle_animation", name);
Multithreading.runAsync(() -> {
try {
Thread.sleep(5000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
self.getPurchaseSettings().merge(oldsettings, true);
self.refreshCachedSettings();
EventBus.INSTANCE.post(new PurchaseLoadEvent(Objects.requireNonNull(UUIDUtil.getClientUUID()), self, true));
new ParticleGui().show();
});
EventBus.INSTANCE.post(new PurchaseLoadEvent(Objects.requireNonNull(UUIDUtil.getClientUUID()), self, true));
return;
}
if (overlay == null) {
particleType.mouseClicked(mouseX, mouseY, width / 5);
particleAnimation.mouseClicked(mouseX, mouseY, width * 4 / 5);
} else {
int x = width / 6 * 2;
int y = height / 4;
if (mouseX >= x && mouseX <= x + 16 && mouseY >= y - 16 && mouseY <= y) {
overlay = null;
} else {
overlay.mouseClicked();
}
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class GuiHyperiumScreenMainMenu method drawScreen.
/**
* Override drawScreen method
*
* @author Cubxity
*/
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
GlStateManager.color(1.0f, 1.0f, 1.0f, 1.0f);
renderBackgroundImage();
ScaledResolution resolution = new ScaledResolution(mc);
fontRendererObj.drawStringWithShadow("Hyperium " + Metadata.getVersion(), 3, resolution.getScaledHeight() - fontRendererObj.FONT_HEIGHT, -1);
String creditsString = I18n.format("menu.right");
drawString(fontRendererObj, creditsString, width - fontRendererObj.getStringWidth(creditsString) - 2, height - 20, -1);
creditsString = createdByTeam;
drawString(fontRendererObj, creditsString, width - fontRendererObj.getStringWidth(creditsString) - 2, height - 10, -1);
if (Settings.HYPERIUM_TIPS && !tipRegistry.getTips().isEmpty()) {
fontRendererObj.drawSplitString(ChatColor.YELLOW + I18n.format(selectedTip), width / 2 - 200 / 2, height / 2 + 72, 200, -1);
}
// yoinked from 1.12
if (mouseX > widthCreditsRest && mouseX < widthCreditsRest + widthCredits && mouseY > height - 10 && mouseY < height && Mouse.isInsideWindow()) {
drawRect(widthCreditsRest, height - 1, widthCreditsRest + widthCredits, height, -1);
}
if (PurchaseApi.getInstance() != null && PurchaseApi.getInstance().getSelf() != null) {
JsonHolder response = PurchaseApi.getInstance().getSelf().getResponse();
int credits = response.optInt("remaining_credits");
fontRendererObj.drawStringWithShadow(mc.getSession().getUsername(), 3, 3, 0xFFFFFF);
fontRendererObj.drawStringWithShadow(I18n.format("menu.profile.credits", credits), 3, 13, 0xFFFF00);
}
fontRenderer.drawCenteredString(Metadata.getModid(), width / 2F, (height >> 1) - 107, new Color(0, 0, 0, 150).getRGB());
fontRenderer.drawCenteredString(Metadata.getModid(), width / 2F, (height >> 1) - 108, -1);
super.drawScreen(mouseX, mouseY, partialTicks);
GuiButton serverButton = this.serverButton;
if (serverButton != null) {
serverButton.displayString = (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT)) ? I18n.format("gui.serverjoin.customizeserver") : Settings.SERVER_BUTTON_NAME;
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class KeystrokesSettings method parseSettings.
private void parseSettings(BetterJsonObject object) {
x = object.optInt("x");
y = object.optInt("y");
red = object.optInt("red", 255);
green = object.optInt("green", 255);
blue = object.optInt("blue", 255);
pressedRed = object.optInt("pressedRed");
pressedGreen = object.optInt("pressedGreen");
pressedBlue = object.optInt("pressedBlue");
setScale(object.optDouble("scale", 1.0D));
setFadeTime(object.optDouble("fadeTime", 1.0D));
enabled = object.optBoolean("enabled", true);
chroma = object.optBoolean("chroma");
leftClick = object.optBoolean("leftClick", true);
mouseButtons = object.optBoolean("mouseButtons");
showCPS = object.optBoolean("showCPS");
showCPSOnButtons = object.optBoolean("showCPSOnButtons");
showSpacebar = object.optBoolean("showSpacebar");
showingSneak = object.optBoolean("showSneak");
showingFPS = object.optBoolean("showFps");
keyBackground = object.optBoolean("keyBackground", true);
showingWASD = object.optBoolean("showingWASD", true);
literalKeys = object.optBoolean("literalKeys");
keyBackgroundOpacity = object.optInt("keyBackgroundOpacity", 120);
keyBackgroundRed = object.optInt("keyBackgroundRed");
keyBackgroundGreen = object.optInt("keyBackgroundGreen");
keyBackgroundBlue = object.optInt("keyBackgroundBlue");
arrowKeys = object.optBoolean("arrowKeys");
JsonObject data = object.getData();
if (data.has("custom")) {
JsonArray custom = data.getAsJsonArray("custom");
for (JsonElement element : custom) {
JsonHolder holder = new JsonHolder(element.getAsJsonObject());
CustomKeyWrapper wrapper = new CustomKeyWrapper(new CustomKey(theMod, holder.optInt("key"), holder.optInt("type")), holder.optInt("xOffset"), holder.optInt("yOffset"));
configWrappers.add(wrapper);
}
}
}
use of cc.hyperium.utils.JsonHolder in project Hyperium by HyperiumClient.
the class ArcadeStats method getDeepStats.
@Override
public List<StatsDisplayItem> getDeepStats(HypixelApiPlayer player) {
List<StatsDisplayItem> items = getPreview(player);
JsonHolder arcade = player.getStats(GameType.ARCADE);
items.add(new DisplayLine(""));
items.add(new DisplayLine("Galaxy Wars", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Kills: ", arcade.optInt("sw_kills"))));
items.add(new DisplayLine(bold("Shots Fired: ", arcade.optInt("sw_shots_fired"))));
items.add(new DisplayLine(bold("Rebel Kills: ", arcade.optInt("sw_rebel_kills"))));
items.add(new DisplayLine(bold("Deaths: ", arcade.optInt("sw_deaths"))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Farm Hunt", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Poop collected: ", arcade.optInt("poop_collected"))));
items.add(new DisplayLine(bold("Farm Hunt Wins: ", arcade.optInt("wins_farm_hunt"))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Bounty Hunters", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Wins: ", arcade.optInt("wins_oneinthequiver"))));
items.add(new DisplayLine(bold("Deaths: ", arcade.optInt("deaths_oneinthequiver"))));
items.add(new DisplayLine(bold("Bounty Kills: ", arcade.optInt("bounty_kills_oneinthequiver"))));
items.add(new DisplayLine(bold("Kills: ", arcade.optInt("kills_oneinthequiver"))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Blocking Dead", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Kills: ", arcade.optInt("kills_dayone"))));
items.add(new DisplayLine(bold("Headshots: ", arcade.optInt("headshots_dayone"))));
items.add(new DisplayLine(bold("Wins: ", arcade.optInt("wins_dayone"))));
items.add(new DisplayLine(bold("Melee Weapon: ", arcade.optString("melee_weapon").toLowerCase().replace("_", " "))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Football", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Wins: ", arcade.optInt("wins_soccer"))));
items.add(new DisplayLine(bold("Goals: ", arcade.optInt("goals_soccer"))));
items.add(new DisplayLine(bold("Power Kicks: ", arcade.optInt("powerkicks_soccer"))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Mini Walls", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Arrows hit: ", arcade.optInt("arrows_hit_mini_walls"))));
items.add(new DisplayLine(bold("Kills: ", arcade.optInt("kills_mini_walls"))));
items.add(new DisplayLine(bold("Final Kills: ", arcade.optInt("final_kills_mini_walls"))));
items.add(new DisplayLine(bold("Wins: ", arcade.optInt("wins_mini_walls"))));
items.add(new DisplayLine(bold("Deaths: ", arcade.optInt("deaths_mini_walls"))));
items.add(new DisplayLine(bold("Wither Damage: ", arcade.optInt("wither_damage_mini_walls"))));
items.add(new DisplayLine(bold("Wither Kills: ", arcade.optInt("wither_kills_mini_walls"))));
items.add(new DisplayLine(""));
items.add(new DisplayLine("Other Games", Color.WHITE.getRGB(), 2));
items.add(new DisplayLine(bold("Hole in the Wall Record : ", arcade.optInt("hitw_record_q"))));
items.add(new DisplayLine(bold("Total Hole in the Walls Rounds: ", arcade.optInt("rounds_hole_in_the_wall"))));
items.add(new DisplayLine(bold("Hypixel Says Rounds: ", arcade.optInt("rounds_simon_says"))));
items.add(new DisplayLine(bold("Hypixel Says Wins: ", arcade.optInt("wins_simon_says"))));
items.add(new DisplayLine(bold("Kills throwout: ", arcade.optInt("kills_throw_out"))));
items.add(new DisplayLine(bold("Death throwout: ", arcade.optInt("deaths_throw_out"))));
items.add(new DisplayLine(bold("Kills dragon wars: ", arcade.optInt("kills_dragonwars2"))));
items.add(new DisplayLine(bold("Wins dragon wars: ", arcade.optInt("wins_dragonwars2"))));
items.add(new DisplayLine(bold("Build Battle wins: ", arcade.optInt("wins_buildbattle"))));
items.add(new DisplayLine(bold("Max Creeper Attack Wave: ", arcade.optInt("max_wave"))));
items.add(new DisplayLine(bold("Party Games 1 wins: ", arcade.optInt("wins_party"))));
items.add(new DisplayLine(bold("Party Games 2 wins: ", arcade.optInt("wins_party_2"))));
items.add(new DisplayLine(bold("Party Games 3 wins: ", arcade.optInt("wins_party_3"))));
return items;
}
Aggregations