Search in sources :

Example 1 with AddonManifest

use of cc.hyperium.internal.addons.AddonManifest in project Hyperium by HyperiumClient.

the class MixinNetHandlerPlayClient method handleCustomPayload.

@Inject(method = "handleCustomPayload", at = @At("RETURN"))
private void handleCustomPayload(S3FPacketCustomPayload packetIn, CallbackInfo ci) {
    PacketBuffer packetBuffer = packetIn.getBufferData();
    try {
        int readableBytes = packetBuffer.readableBytes();
        if (readableBytes > 0) {
            byte[] payload = new byte[readableBytes - 1];
            packetBuffer.readBytes(payload);
            String message = new String(payload, Charsets.UTF_8);
            if (LoginReplyHandler.SHOW_MESSAGES) {
                GeneralChatHandler.instance().sendMessage("Packet message on channel " + packetIn.getChannelName() + " -> " + message);
            }
            if ("REGISTER".equalsIgnoreCase(packetIn.getChannelName())) {
                if (message.contains("Hyperium")) {
                    PacketBuffer buffer = new PacketBuffer(Unpooled.buffer());
                    buffer.writeString("Hyperium;" + Metadata.getVersion() + ";" + Metadata.getVersionID());
                    addToSendQueue(new C17PacketCustomPayload("REGISTER", buffer));
                    PacketBuffer addonbuffer = new PacketBuffer(Unpooled.buffer());
                    List<AddonManifest> addons = AddonBootstrap.INSTANCE.getAddonManifests();
                    addonbuffer.writeInt(addons.size());
                    for (AddonManifest addonmanifest : addons) {
                        String addonName = addonmanifest.getName();
                        String version = addonmanifest.getVersion();
                        if (addonName == null)
                            addonName = addonmanifest.getMainClass();
                        if (version == null)
                            version = "unknown";
                        addonbuffer.writeString(addonName);
                        addonbuffer.writeString(version);
                    }
                    addToSendQueue(new C17PacketCustomPayload("hyperium|Addons", addonbuffer));
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : C17PacketCustomPayload(net.minecraft.network.play.client.C17PacketCustomPayload) AddonManifest(cc.hyperium.internal.addons.AddonManifest) PacketBuffer(net.minecraft.network.PacketBuffer) URISyntaxException(java.net.URISyntaxException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with AddonManifest

use of cc.hyperium.internal.addons.AddonManifest in project Hyperium by HyperiumClient.

the class GuiAddonError method drawScreen.

@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
    drawDefaultBackground();
    int textY = 20;
    drawCenteredString(fontRendererObj, ChatColor.RED.toString() + ChatColor.BOLD + "ERROR LOADING ADDONS", width / 2, textY, Color.WHITE.getRGB());
    textY += 10;
    drawCenteredString(fontRendererObj, ChatColor.RED.toString() + ChatColor.BOLD + "THE FOLLOWING ADDONS WON'T LOAD", width / 2, textY, Color.WHITE.getRGB());
    textY += 10;
    if (!AddonMinecraftBootstrap.getMissingDependenciesMap().isEmpty()) {
        for (Map.Entry<AddonManifest, ArrayList<String>> entry : AddonMinecraftBootstrap.getMissingDependenciesMap().entrySet()) {
            textY += 10;
            drawCenteredString(fontRendererObj, ChatColor.RED + entry.getKey().getName() + " needs " + StringUtils.join(entry.getValue(), ", ") + " to load.", width / 2, textY, Color.WHITE.getRGB());
        }
    }
    textY += 10;
    if (!AddonMinecraftBootstrap.getDependenciesLoopMap().isEmpty()) {
        for (Map.Entry<AddonManifest, ArrayList<AddonManifest>> entry : AddonMinecraftBootstrap.getDependenciesLoopMap().entrySet()) {
            textY += 10;
            drawCenteredString(fontRendererObj, ChatColor.RED + entry.getKey().getName() + " can't load together with " + StringUtils.join(entry.getValue().stream().map(AddonManifest::getName).collect(Collectors.toList()), ", " + "."), width / 2, textY, Color.WHITE.getRGB());
        }
    }
    int hoverColor = new Color(0, 0, 0, 60).getRGB();
    int color = new Color(0, 0, 0, 50).getRGB();
    GuiBlock block1 = new GuiBlock(width / 2 - 100, width / 2 + 100, 200, 220);
    Gui.drawRect(block1.getLeft(), block1.getTop(), block1.getRight(), block1.getBottom(), block1.isMouseOver(mouseX, mouseY) ? hoverColor : color);
    drawCenteredString(fontRendererObj, "Continue", width / 2, 205, Color.WHITE.getRGB());
    if (block1.isMouseOver(mouseX, mouseY) && Mouse.isButtonDown(0)) {
        // Clear the maps so this screen goes away.
        AddonMinecraftBootstrap.getDependenciesLoopMap().clear();
        AddonMinecraftBootstrap.getMissingDependenciesMap().clear();
        Hyperium.INSTANCE.getHandlers().getGuiDisplayHandler().setDisplayNextTick(new GuiHyperiumScreenMainMenu());
    }
}
Also used : Color(java.awt.Color) ChatColor(cc.hyperium.utils.ChatColor) ArrayList(java.util.ArrayList) Map(java.util.Map) AddonManifest(cc.hyperium.internal.addons.AddonManifest)

Aggregations

AddonManifest (cc.hyperium.internal.addons.AddonManifest)2 ChatColor (cc.hyperium.utils.ChatColor)1 Color (java.awt.Color)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 URISyntaxException (java.net.URISyntaxException)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 PacketBuffer (net.minecraft.network.PacketBuffer)1 C17PacketCustomPayload (net.minecraft.network.play.client.C17PacketCustomPayload)1 Inject (org.spongepowered.asm.mixin.injection.Inject)1