diff --git a/README.md b/README.md index a7a9f29..6b7ad6c 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,28 @@ You will find modpack/mod name with some numbers after it. That is totally inten Installing a modpack will also generate a profile. However, the profile doesn't use the correct mod loader. Please install the mod loader yourself as instructed. +## Compiling +To compile the program yourself, some libraries are needed: +- [Apache Commons IO](https://commons.apache.org/proper/commons-io/) +- [jansi](https://github.com/fusesource/jansi) +- [JSON Simple](https://code.google.com/archive/p/json-simple) + +Download them and put them somewhere. + +This program is compiled with IntelliJ, so I don't know how to compile it outside of IntelliJ. +Anyway, follow the steps: +1. Download the repository by `git clone` or downloading as ZIP and extract it. +2. Launch IntelliJ IDEA if you haven't. +3. Open the directory where the files are extracted into. +4. In the top bar, go to File->Project Structure. +5. On the left side, go to Global Libraries. +6. Click the + symbol and choose Java. +7. In the file chooser, choose the Java libraries you downloaded. +8. Click OK on everything. +9. In the top bar, go to Build->Build Artifacts. +10. In the little window, choose Build. +11. The `.jar` file should be built inside `out/artifacts`. + ## Support If you want to support me, please consider becoming [my Patron](https://www.patreon.com/nww). diff --git a/src/ml/northwestwind/Constants.java b/src/ml/northwestwind/Constants.java index 2f836e0..9dd3607 100644 --- a/src/ml/northwestwind/Constants.java +++ b/src/ml/northwestwind/Constants.java @@ -6,7 +6,7 @@ public class Constants { public static final String CURSEFORGE_API = "https://northwestwind.ml/api/curseforge/mods/"; - public static final String VERSION = "1.4.0"; + public static final String VERSION = "1.4.1"; private static final String OS = System.getProperty("os.name").toLowerCase(); public static final boolean IS_WINDOWS = (OS.contains("win")); public static final boolean IS_MAC = (OS.contains("mac")); diff --git a/src/ml/northwestwind/Modpack.java b/src/ml/northwestwind/Modpack.java index 42c5126..e15897f 100644 --- a/src/ml/northwestwind/Modpack.java +++ b/src/ml/northwestwind/Modpack.java @@ -199,18 +199,28 @@ private static String getModVersion(JSONObject manifest) { String[] splitted = id.split("-"); String loader = splitted[0].toLowerCase(); String modVer = Arrays.stream(splitted).skip(1).collect(Collectors.joining("-")); - List versions = Arrays.stream(new File(Utils.getMinecraftPath() + File.separator + "versions").listFiles()).map(File::getName).collect(Collectors.toList()); - Optional found = versions.stream().filter(name -> name.contains(loader) && name.contains(modVer) && name.contains(version)).findFirst(); - if (found.isPresent()) return found.get(); + File versionsDir = new File(Utils.getMinecraftPath() + File.separator + "versions"); + if (versionsDir.exists()) { + System.out.println(Ansi.ansi().fg(Ansi.Color.MAGENTA).a("Looking into versions directory: ").a(versionsDir.getAbsolutePath()).reset()); + String[] versionNames = versionsDir.list(); + if (versionNames != null) { + Optional found = Arrays.stream(versionNames).filter(name -> name.contains(loader) && name.contains(modVer) && name.contains(version)).findFirst(); + if (found.isPresent()) return found.get(); + } + } System.out.println(Ansi.ansi().fg(Ansi.Color.YELLOW).a("We couldn't find the mod launcher version required for your modpack!")); System.out.println(Ansi.ansi().a("Please download the required mod launcher version from the link below. Enter y after you have that installed, or enter n to skip it for now [y/n]")); if (loader.equalsIgnoreCase("forge")) System.out.println(Ansi.ansi().a("https://files.minecraftforge.net/net/minecraftforge/forge/").reset()); else if (loader.equalsIgnoreCase("fabric")) System.out.println((Ansi.ansi().a("https://fabricmc.net/use/installer/")).reset()); else if (loader.equalsIgnoreCase("quilt")) System.out.println(Ansi.ansi().a("https://quiltmc.org/en/install/").reset()); if (Utils.readYesNo()) { - versions = Arrays.stream(new File(Utils.getMinecraftPath() + File.separator + "versions").listFiles()).map(f -> f.getName().toLowerCase()).collect(Collectors.toList()); - found = versions.stream().filter(name -> name.contains(loader) && name.contains(modVer) && name.contains(version)).findFirst(); - if (found.isPresent()) return found.get(); + if (versionsDir.exists()) { + String[] versionNames = versionsDir.list(); + if (versionNames != null) { + Optional found = Arrays.stream(versionNames).filter(name -> name.contains(loader) && name.contains(modVer) && name.contains(version)).findFirst(); + if (found.isPresent()) return found.get(); + } + } System.out.println(Ansi.ansi().fg(Ansi.Color.YELLOW).a("We still couldn't find the mod launcher version required! The installation will continue anyway. You may have to change the profile settings after this.")); } if (loader.equalsIgnoreCase("forge")) id = version + "-forge-" + modVer; diff --git a/update.json b/update.json index aa322dc..3bfd5bd 100644 --- a/update.json +++ b/update.json @@ -1,4 +1,7 @@ { + "1.4.1": { + "title": "Prevent crashing when no versions directory is found" + }, "1.4.0": { "title": "Quilt support" }, @@ -83,5 +86,5 @@ "1.2.0": { "title": "Update Checker & Profile Generator" }, - "latest": "1.4.0" + "latest": "1.4.1" }