SKCraft / Launcher

🚀 Distribute your Minecraft modpacks with a custom launcher
Other
622 stars 433 forks source link

Using forge-1.12.2-14.23.5.2854-installer.jar as loader causes NPE #347

Closed Heimdell closed 3 years ago

Heimdell commented 4 years ago

The exception log is:

To report this error, please provide:

java.lang.NullPointerException
    at com.skcraft.launcher.builder.PackageBuilder.processLoader(PackageBuilder.java:197)
    at com.skcraft.launcher.builder.PackageBuilder.addLoaders(PackageBuilder.java:127)
    at com.skcraft.launcher.builder.PackageBuilder.main(PackageBuilder.java:401)
    at com.skcraft.launcher.creator.controller.task.PackBuilder.call(PackBuilder.java:66)
    at com.skcraft.launcher.creator.controller.task.PackBuilder.call(PackBuilder.java:21)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)

So, the reason being, in launcher-builder/src/main/java/com/skcraft/launcher/builder/PackageBuilder.java:157 the

InstallProfile profile = mapper.readValue(data, InstallProfile.class);

pulls the profile that looks like this:

InstallProfile(installData=null, versionInfo=null)

I've put forge-1.12.2-14.23.5.2854-installer.jar into ./loaders/ of my modpack.

My system is Linux.

I've selected 1.12.2 as modpack minecraft version.

spannerman79 commented 4 years ago

java -version?

If indeed it is 8 then https://github.com/SKCraft/Launcher/issues/235 would be the issue.

OliDucks commented 4 years ago

i got the same issue but still couldnt find how to solve it :(

spannerman79 commented 4 years ago

Read the issue I linked...

OliDucks commented 4 years ago

Read the issue I linked...

I did read.. i Tried many time and read at least 3 times from the top to the bottom, i must had missed something idk, i'm gonna try again

edit: I tried to do the modification with #270 #271 #272 but still not working, it give me the same error, i tried with some other.. all i get is [infos] Installing forge-1.12.2-14.23.5.2854-installer.jar... [avertissement] Task failed java.lang.NullPointerException at com.skcraft.launcher.builder.PackageBuilder.processLoader(PackageBuilder.java:162) at com.skcraft.launcher.builder.PackageBuilder.addLoaders(PackageBuilder.java:128) at com.skcraft.launcher.builder.PackageBuilder.main(PackageBuilder.java:392) at com.skcraft.launcher.creator.controller.task.PackBuilder.call(PackBuilder.java:66) at com.skcraft.launcher.creator.controller.task.PackBuilder.call(PackBuilder.java:21) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

KarmaDeb commented 4 years ago

I know where's the problem, but I don't know how to fix it...

For example, in forge 1.8 installer, versionInfo is inside install_profile, but in forge 1.12.2, versionInfo is in a separate file (version.json)

If you open the installer as zip, you will understand it better

In my opinion, processLoader needs to be updated, and also

"profile.getVersionInfo()"

KarmaDeb commented 4 years ago

This fixes the versionInfo, but now I'm stuck at

"install" : { }

Wich is also removed in 1.12.2 forge

https://pastebin.com/bYMgirC9

InstallProfile:

https://pastebin.com/eCfVkprr

KarmaDeb commented 4 years ago

I think I fixed it, I'm going to test it....

KarmaDeb commented 4 years ago

Done!

But, for some reason, some libraries won't be downloaded on the _upload folder, so you will have to download these libraries manually and upload them to your FTP site

https://i.imgur.com/h98XEAz.jpg

KarmaDeb commented 4 years ago
private void processLoader(LinkedHashSet<Library> loaderLibraries, File file, File librariesDir) throws IOException {
        log.info("Installing " + file.getName() + "...");

        JarFile jarFile = new JarFile(file);
        Closer closer = Closer.create();

        try {
            ZipEntry profileEntry = BuilderUtils.getZipEntry(jarFile, "install_profile.json");
            if (BuilderUtils.getZipEntry(jarFile, "version.json") == null) {

                if (profileEntry != null) {
                    InputStream stream = jarFile.getInputStream(profileEntry);

                    // Read file
                    String data = CharStreams.toString(closer.register(new InputStreamReader(stream)));
                    data = data.replaceAll(",\\s*\\}", "}");

                    InstallProfile profile = mapper.readValue(data, InstallProfile.class);
                    VersionManifest version = manifest.getVersionManifest();

                    // Copy tweak class arguments
                    String args = profile.getVersionInfo().getMinecraftArguments();
                    if (args != null) {
                        String existingArgs = Strings.nullToEmpty(version.getMinecraftArguments());

                        Matcher m = TWEAK_CLASS_ARG.matcher(args);
                        while (m.find()) {
                            version.setMinecraftArguments(existingArgs + " " + m.group());
                            log.info("Adding " + m.group() + " to launch arguments");
                        }
                    }

                    // Add libraries
                    List<Library> libraries = profile.getVersionInfo().getLibraries();
                    if (libraries != null) {
                        for (Library library : libraries) {
                            if (!version.getLibraries().contains(library)) {
                                loaderLibraries.add(library);
                            }
                        }
                    }

                    // Copy main class
                    String mainClass = profile.getVersionInfo().getMainClass();
                    if (mainClass != null) {
                        version.setMainClass(mainClass);
                        log.info("Using " + mainClass + " as the main class");
                    }

                    // Extract the library
                    String filePath = profile.getInstallData().getFilePath();
                    String libraryPath = profile.getInstallData().getPath();

                    if (filePath != null && libraryPath != null) {
                        ZipEntry libraryEntry = BuilderUtils.getZipEntry(jarFile, filePath);

                        if (libraryEntry != null) {
                            Library library = new Library();
                            library.setName(libraryPath);
                            File extractPath = new File(librariesDir, library.getPath(Environment.getInstance()));
                            Files.createParentDirs(extractPath);
                            ByteStreams.copy(closer.register(jarFile.getInputStream(libraryEntry)), Files.newOutputStreamSupplier(extractPath));
                        } else {
                            log.warning("Could not find the file '" + filePath + "' in " + file.getAbsolutePath() + ", which means that this mod loader will not work correctly");
                        }
                    }
                } else {
                    log.warning("The file at " + file.getAbsolutePath() + " did not appear to have an " +
                            "install_profile.json file inside -- is it actually an installer for a mod loader?");
                }
            } else {
                log.info("Version json found, using it");
                ZipEntry versionEntry = BuilderUtils.getZipEntry(jarFile, "version.json");

                if (profileEntry != null) {
                    InputStream Stream = jarFile.getInputStream(profileEntry);
                    InputStream vStream = jarFile.getInputStream(versionEntry);

                    // Read file
                    String Data = CharStreams.toString(closer.register(new InputStreamReader(Stream)));
                    String vData = CharStreams.toString(closer.register(new InputStreamReader(vStream)));
                    vData = vData.replaceAll(",\\s*\\}", "}");

                    InstallProfile vProfile = mapper.readValue(vData, InstallProfile.class);
                    InstallProfile profile = mapper.readValue(Data, InstallProfile.class);
                    VersionManifest version = manifest.getVersionManifest();

                    // Copy tweak class arguments
                    String args = vProfile.getMinecraftArguments();
                    if (args != null) {
                        String existingArgs = Strings.nullToEmpty(version.getMinecraftArguments());

                        Matcher m = TWEAK_CLASS_ARG.matcher(args);
                        while (m.find()) {
                            version.setMinecraftArguments(existingArgs + " " + m.group());
                            log.info("Adding " + m.group() + " to launch arguments");
                        }
                    }

                    // Add libraries
                    List<Library> libraries = vProfile.getLibraries();
                    if (libraries != null) {
                        for (Library library : libraries) {
                            if (!version.getLibraries().contains(library)) {
                                loaderLibraries.add(library);
                            }
                        }
                    }

                    // Copy main class
                    String mainClass = vProfile.getMainClass();
                    if (mainClass != null) {
                        version.setMainClass(mainClass);
                        log.info("Using " + mainClass + " as the main class");
                    }

                    // Extract the library
                    String filePath = profile.getFilePath();
                    String libraryPath = profile.getPath();

                    if (filePath != null && libraryPath != null) {
                        ZipEntry libraryEntry = BuilderUtils.getZipEntry(jarFile, filePath);

                        if (libraryEntry != null) {
                            Library library = new Library();
                            library.setName(libraryPath);
                            File extractPath = new File(librariesDir, library.getPath(Environment.getInstance()));
                            Files.createParentDirs(extractPath);
                            ByteStreams.copy(closer.register(jarFile.getInputStream(libraryEntry)), Files.newOutputStreamSupplier(extractPath));
                        } else {
                            log.warning("Could not find the file '" + filePath + "' in " + file.getAbsolutePath() + ", which means that this mod loader will not work correctly");
                        }
                    }
                } else {
                    log.warning("The file at " + file.getAbsolutePath() + " did not appear to have an " +
                            "install_profile.json file inside -- is it actually an installer for a mod loader?");
                }
            }
        } finally {
            closer.close();
            jarFile.close();
        }
    }
package com.skcraft.launcher.model.loader;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.skcraft.launcher.model.minecraft.Library;
import lombok.Data;

import java.util.List;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class InstallProfile {

    @JsonProperty("install")
    private InstallData installData;
    private VersionInfo versionInfo;
    private String minecraftArguments;
    private List<Library> libraries;
    private String mainClass;
    private String path;
    private String filePath;
}
darealHeroBrine commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

xemnes commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success.

@KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854

KarmaDeb commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success.

@KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854 @xemnes

My fix works for even Forge 1.16 and due 1.16 forge SKCraft can't run 1.16 forge, but < 1.15 (Idk if that's what you were talking about), anyway I decided to develop my custom modpack updater, see this (No, it's not spam, it's an alternative I've made)

xemnes commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success. @KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854 @xemnes

My fix works for even Forge 1.16 and due 1.16 forge SKCraft can't run 1.16 forge, but < 1.15 (Idk if that's what you were talking about), anyway I decided to develop my custom modpack updater, see this (No, it's not spam, it's an alternative I've made)

my issue was the same as ops, 2854 causes npe when trying to build the modpack in creator tools. i just looked at your modpack creator, it doesnt look like it works with sklauncher, well... at least it doesnt seem to from what i was reading in your how-to

KarmaDeb commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success. @KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854 @xemnes

My fix works for even Forge 1.16 and due 1.16 forge SKCraft can't run 1.16 forge, but < 1.15 (Idk if that's what you were talking about), anyway I decided to develop my custom modpack updater, see this (No, it's not spam, it's an alternative I've made)

my issue was the same as ops, 2854 causes npe when trying to build the modpack in creator tools. i just looked at your modpack creator, it doesnt look like it works with sklauncher

It doesn't works with it, it's a complete alternative to create a modpack and installing it in your minecraft folder and it injects a profile with the modpack name, as its name sais, it's a modpack creator, installer and updater

xemnes commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success. @KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854 @xemnes

My fix works for even Forge 1.16 and due 1.16 forge SKCraft can't run 1.16 forge, but < 1.15 (Idk if that's what you were talking about), anyway I decided to develop my custom modpack updater, see this (No, it's not spam, it's an alternative I've made)

my issue was the same as ops, 2854 causes npe when trying to build the modpack in creator tools. i just looked at your modpack creator, it doesnt look like it works with sklauncher

It doesn't works with it, it's a complete alternative to create a modpack and installing it in your minecraft folder and it injects a profile with the modpack name, as its name sais, it's a modpack creator, installer and updater

hmm ok, though it would mean id have to ditch the launcher which ive been using for a long time in place of yours. edit: seems that your launcher doesnt allow me to select where my .minecraft is, as mine is not in appdata so it cant find a forge version.

KarmaDeb commented 4 years ago

The Easy Fix for this is use a slightly older version of the installer

could you elaborate on which "older" version to use? ive used 2.0.0 and 2.0.1 with no success. @KarmaConfigs said he fixed it but im unsure how to apply said fix. this only seems to be an issue with forge 2854, i can use others just fine but i need 2854 @xemnes

My fix works for even Forge 1.16 and due 1.16 forge SKCraft can't run 1.16 forge, but < 1.15 (Idk if that's what you were talking about), anyway I decided to develop my custom modpack updater, see this (No, it's not spam, it's an alternative I've made)

my issue was the same as ops, 2854 causes npe when trying to build the modpack in creator tools. i just looked at your modpack creator, it doesnt look like it works with sklauncher

It doesn't works with it, it's a complete alternative to create a modpack and installing it in your minecraft folder and it injects a profile with the modpack name, as its name sais, it's a modpack creator, installer and updater

hmm ok, though it would mean id have to ditch the launcher which ive been using for a long time in place of yours. edit: seems that your launcher doesnt allow me to select where my .minecraft is, as mine is not in appdata so it cant find a forge version.

It does, in creator panel

xemnes commented 4 years ago

It does, in creator panel

i cannot open the creator panel, it says i need to install forge which i have, just not in appdata

KarmaDeb commented 4 years ago

It does, in creator panel

i cannot open the creator panel, it says i need to install forge which i have, just not in appdata

Run ModpackTool again, it should update the tool to the latest version which should fix the problem

AceKiller250 commented 3 years ago

Done!

But, for some reason, some libraries won't be downloaded on the _upload folder, so you will have to download these libraries manually and upload them to your FTP site

https://i.imgur.com/h98XEAz.jpg

how did you do it? I don't understand :(

AceKiller250 commented 3 years ago

Ok i fixed it by using a slightly older version of 1.12.2 but now I'm getting this error msg:

java.io.IOException: 3 file(s) could not be downloaded at com.skcraft.launcher.install.HttpDownloader.execute(HttpDownloader.java:139) at com.skcraft.launcher.install.Installer.download(Installer.java:46) at com.skcraft.launcher.update.Updater.update(Updater.java:178) at com.skcraft.launcher.update.Updater.call(Updater.java:95) at com.skcraft.launcher.update.Updater.call(Updater.java:38) at java.util.concurrent.FutureTask.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)

AceKiller250 commented 3 years ago

@KarmaConfigs

KarmaDeb commented 3 years ago

@KarmaConfigs

I literally removed my SKCraft launcher instance, as it was impossible for me to make it to work with +1.12 versions, so I don't have it anymore and I can't help you