Search in sources :

Example 6 with HyperiumPurchase

use of cc.hyperium.purchases.HyperiumPurchase 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);
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) OverlaySelector(cc.hyperium.gui.main.components.OverlaySelector) Arrays(java.util.Arrays) GuiYesNo(net.minecraft.client.gui.GuiYesNo) HashMap(java.util.HashMap) Keyboard(org.lwjgl.input.Keyboard) OverlaySlider(cc.hyperium.gui.main.components.OverlaySlider) I18n(net.minecraft.client.resources.I18n) AbstractAnimation(cc.hyperium.handlers.handlers.particle.AbstractAnimation) Minecraft(net.minecraft.client.Minecraft) Multithreading(cc.hyperium.mods.sk1ercommon.Multithreading) GuiYesNoCallback(net.minecraft.client.gui.GuiYesNoCallback) Hyperium(cc.hyperium.Hyperium) PurchaseCarousel(cc.hyperium.gui.carousel.PurchaseCarousel) ServerCrossDataPacket(cc.hyperium.netty.packet.packets.serverbound.ServerCrossDataPacket) JsonHolder(cc.hyperium.utils.JsonHolder) InvokeEvent(cc.hyperium.event.InvokeEvent) CarouselItem(cc.hyperium.gui.carousel.CarouselItem) GeneralChatHandler(cc.hyperium.handlers.handlers.chat.GeneralChatHandler) ResolutionUtil(cc.hyperium.mods.sk1ercommon.ResolutionUtil) GuiButton(net.minecraft.client.gui.GuiButton) ScaledResolution(net.minecraft.client.gui.ScaledResolution) EventBus(cc.hyperium.event.EventBus) GlStateManager(net.minecraft.client.renderer.GlStateManager) UUIDUtil(cc.hyperium.utils.UUIDUtil) PurchaseLoadEvent(cc.hyperium.event.network.PurchaseLoadEvent) IOException(java.io.IOException) NettyClient(cc.hyperium.netty.NettyClient) java.awt(java.awt) Objects(java.util.Objects) HyperiumOverlay(cc.hyperium.gui.main.HyperiumOverlay) EnumParticleType(cc.hyperium.handlers.handlers.particle.EnumParticleType) ParticleAuraHandler(cc.hyperium.handlers.handlers.particle.ParticleAuraHandler) PurchaseApi(cc.hyperium.purchases.PurchaseApi) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) PurchaseLoadEvent(cc.hyperium.event.network.PurchaseLoadEvent) GuiYesNo(net.minecraft.client.gui.GuiYesNo) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) AbstractAnimation(cc.hyperium.handlers.handlers.particle.AbstractAnimation) HyperiumOverlay(cc.hyperium.gui.main.HyperiumOverlay) EnumParticleType(cc.hyperium.handlers.handlers.particle.EnumParticleType) OverlaySelector(cc.hyperium.gui.main.components.OverlaySelector) IOException(java.io.IOException) NettyClient(cc.hyperium.netty.NettyClient) ParticleAuraHandler(cc.hyperium.handlers.handlers.particle.ParticleAuraHandler) CarouselItem(cc.hyperium.gui.carousel.CarouselItem) OverlaySlider(cc.hyperium.gui.main.components.OverlaySlider)

Example 7 with HyperiumPurchase

use of cc.hyperium.purchases.HyperiumPurchase 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();
        }
    }
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) PurchaseLoadEvent(cc.hyperium.event.network.PurchaseLoadEvent) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) EnumParticleType(cc.hyperium.handlers.handlers.particle.EnumParticleType)

Example 8 with HyperiumPurchase

use of cc.hyperium.purchases.HyperiumPurchase in project Hyperium by HyperiumClient.

the class AboveHeadRenderer method render.

@InvokeEvent
public void render(RenderPlayerEvent event) {
    if (levelhead == null || levelhead.getDisplayManager() == null || levelhead.getDisplayManager().getMasterConfig() == null || !levelhead.getDisplayManager().getMasterConfig().isEnabled()) {
        return;
    }
    EntityPlayer player = event.getEntity();
    int o = 0;
    for (AboveHeadDisplay display : levelhead.getDisplayManager().getAboveHead()) {
        int index = display.getIndex();
        int extraHead = levelhead.getLevelheadPurchaseStates().getExtraHead();
        if (index > extraHead || !display.getConfig().isEnabled())
            continue;
        LevelheadTag levelheadTag = display.getCache().get(player.getUniqueID());
        if (display.loadOrRender(player) && levelheadTag != null && !(levelheadTag instanceof NullLevelheadTag)) {
            if ((event.getEntity().getUniqueID().equals(Levelhead.getInstance().userUuid) && !display.getConfig().isShowSelf() || !Hyperium.INSTANCE.getHandlers().getHypixelDetector().isHypixel())) {
                continue;
            }
            if (player.getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 64 * 64) {
                double offset = 0.3;
                Scoreboard scoreboard = player.getWorldScoreboard();
                ScoreObjective objective = scoreboard.getObjectiveInDisplaySlot(2);
                if (objective != null && event.getEntity().getDistanceSqToEntity(Minecraft.getMinecraft().thePlayer) < 10 * 10) {
                    offset *= 2;
                }
                if (player.getUniqueID().equals(levelhead.userUuid) && !Settings.SHOW_OWN_NAME)
                    offset -= .3;
                if (Hyperium.INSTANCE.getCosmetics().getDeadmau5Cosmetic().isPurchasedBy(event.getEntity().getUniqueID())) {
                    HyperiumPurchase packageIfReady = PurchaseApi.getInstance().getPackageIfReady(event.getEntity().getUniqueID());
                    if (packageIfReady != null) {
                        AbstractHyperiumPurchase purchase = packageIfReady.getPurchase(EnumPurchaseType.DEADMAU5_COSMETIC);
                        if (purchase != null) {
                            if (event.getEntity().getUniqueID() != Minecraft.getMinecraft().thePlayer.getUniqueID()) {
                                if (((EarsCosmetic) purchase).isEnabled()) {
                                    offset += .3;
                                }
                            } else if (Settings.EARS_STATE.equalsIgnoreCase("on")) {
                                offset += .2;
                            }
                        }
                    }
                }
                offset += levelhead.getDisplayManager().getMasterConfig().getOffset();
                renderName(event, levelheadTag, player, event.getX(), event.getY() + offset + o * .3D, event.getZ());
            }
        }
        o++;
    }
}
Also used : ScoreObjective(net.minecraft.scoreboard.ScoreObjective) AbstractHyperiumPurchase(cc.hyperium.purchases.AbstractHyperiumPurchase) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) Scoreboard(net.minecraft.scoreboard.Scoreboard) AbstractHyperiumPurchase(cc.hyperium.purchases.AbstractHyperiumPurchase) EarsCosmetic(cc.hyperium.purchases.packages.EarsCosmetic) EntityPlayer(net.minecraft.entity.player.EntityPlayer) AboveHeadDisplay(cc.hyperium.mods.levelhead.display.AboveHeadDisplay) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 9 with HyperiumPurchase

use of cc.hyperium.purchases.HyperiumPurchase in project Hyperium by HyperiumClient.

the class ParticleAuraHandler method loadPurchaseEvent.

@InvokeEvent
public void loadPurchaseEvent(PurchaseLoadEvent purchaseLoadEvent) {
    HyperiumPurchase purchase = purchaseLoadEvent.getPurchase();
    auras.remove(purchase.getPlayerUUID());
    JsonHolder purchaseSettings = purchase.getPurchaseSettings();
    if (!purchaseSettings.has("particle"))
        return;
    JsonHolder data = purchaseSettings.optJSONObject("particle");
    String particle_animation1 = data.optString("particle_animation");
    AbstractAnimation particle_animation = animations.get(particle_animation1);
    EnumParticleType type = EnumParticleType.parse(data.optString("type"));
    if (particle_animation == null || type == null)
        return;
    if (!purchase.hasPurchased("PARTICLE_" + type.name()) || !purchase.hasPurchased("ANIMATION_" + (particle_animation1.toUpperCase().replace(" ", "_")))) {
        return;
    }
    boolean rgb = data.optBoolean("rgb");
    boolean chroma = data.optBoolean("chroma");
    ParticleAura max_age = new ParticleAura(renderEngines.get(type), particle_animation, data.optInt("max_age", 2), chroma, rgb);
    max_age.setRgb(data.optInt("red"), data.optInt("green"), data.optInt("blue"));
    auras.put(purchase.getPlayerUUID(), max_age);
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) InvokeEvent(cc.hyperium.event.InvokeEvent)

Example 10 with HyperiumPurchase

use of cc.hyperium.purchases.HyperiumPurchase in project Hyperium by HyperiumClient.

the class CommandDebug method get.

public static String get() {
    StringBuilder builder = new StringBuilder();
    PurchaseApi api = PurchaseApi.getInstance();
    if (api == null)
        return "";
    builder.append("\n\n");
    Multithreading.runAsync(CommandDebug::checkUUID);
    if (isPremium) {
        builder.append("Premium: True, ").append("UUID is ").append(Minecraft.getMinecraft().thePlayer.getGameProfile().getId());
    } else {
        builder.append("Premium: False, user doesn't have a UUID");
    }
    builder.append("\n\n");
    HyperiumPurchase self = PurchaseApi.getInstance().getSelf();
    builder.append("Purchase callback: ");
    if (self != null) {
        JsonHolder response = self.getResponse();
        if (response != null)
            builder.append(printer.toJson(response.getObject()));
    }
    builder.append("\n\n");
    HypixelDetector instance = HypixelDetector.getInstance();
    if (instance != null)
        builder.append("Hypixel: ").append(instance.isHypixel());
    builder.append("\n\n\n\n");
    NetworkHandler networkHandler = Hyperium.INSTANCE.getNetworkHandler();
    if (networkHandler != null) {
        List<String> verboseLogs = networkHandler.getVerboseLogs();
        verboseLogs.forEach(verboseLog -> {
            builder.append(verboseLog);
            builder.append("\n");
        });
        builder.append(verboseLogs);
        builder.append("\n");
    }
    tryConfig(builder);
    builder.append("\n\n");
    tryChromaHUD(builder);
    builder.append("\n\n");
    tryKeybinds(builder);
    builder.append("\n\n");
    tryLevelhead(builder);
    builder.append("\n\n");
    builder.append("Levelhead");
    builder.append("\n");
    return builder.toString();
}
Also used : JsonHolder(cc.hyperium.utils.JsonHolder) HypixelDetector(cc.hyperium.handlers.handlers.HypixelDetector) HyperiumPurchase(cc.hyperium.purchases.HyperiumPurchase) NetworkHandler(cc.hyperium.network.NetworkHandler) PurchaseApi(cc.hyperium.purchases.PurchaseApi)

Aggregations

HyperiumPurchase (cc.hyperium.purchases.HyperiumPurchase)15 InvokeEvent (cc.hyperium.event.InvokeEvent)8 JsonHolder (cc.hyperium.utils.JsonHolder)5 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 PurchaseLoadEvent (cc.hyperium.event.network.PurchaseLoadEvent)2 EnumParticleType (cc.hyperium.handlers.handlers.particle.EnumParticleType)2 NettyClient (cc.hyperium.netty.NettyClient)2 AbstractHyperiumPurchase (cc.hyperium.purchases.AbstractHyperiumPurchase)2 PurchaseApi (cc.hyperium.purchases.PurchaseApi)2 IOException (java.io.IOException)2 Minecraft (net.minecraft.client.Minecraft)2 AbstractClientPlayer (net.minecraft.client.entity.AbstractClientPlayer)2 GuiButton (net.minecraft.client.gui.GuiButton)2 ScaledResolution (net.minecraft.client.gui.ScaledResolution)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 Hyperium (cc.hyperium.Hyperium)1 EventBus (cc.hyperium.event.EventBus)1 CarouselItem (cc.hyperium.gui.carousel.CarouselItem)1 PurchaseCarousel (cc.hyperium.gui.carousel.PurchaseCarousel)1 HyperiumOverlay (cc.hyperium.gui.main.HyperiumOverlay)1