use of cc.hyperium.handlers.handlers.particle.EnumParticleType 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.handlers.handlers.particle.EnumParticleType 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();
}
}
}
Aggregations