diff options
| author | TheKodeToad <TheKodeToad@proton.me> | 2025-06-30 20:36:21 +0100 |
|---|---|---|
| committer | TheKodeToad <TheKodeToad@proton.me> | 2025-06-30 20:47:47 +0100 |
| commit | d36485185be6ef6e580a0664a5a4a5ac8748b707 (patch) | |
| tree | 1f66c38f667f66e04c486a6eedc2c47c7f8d0f8a | |
| parent | e2640cd13c11f4c91daf3bc438a7e45252f0393c (diff) | |
| download | Project-Tick-d36485185be6ef6e580a0664a5a4a5ac8748b707.tar.gz Project-Tick-d36485185be6ef6e580a0664a5a4a5ac8748b707.zip | |
Improve libraries folder detection
| -rw-r--r-- | src/main/java/io/github/zekerzhayard/forgewrapper/installer/detector/IFileDetector.java | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/detector/IFileDetector.java b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/detector/IFileDetector.java index 4f1b7c3558..1d3fb1f274 100644 --- a/src/main/java/io/github/zekerzhayard/forgewrapper/installer/detector/IFileDetector.java +++ b/src/main/java/io/github/zekerzhayard/forgewrapper/installer/detector/IFileDetector.java @@ -29,9 +29,17 @@ public interface IFileDetector { return Paths.get(libraryDir).toAbsolutePath(); } try { - Path launcher = Paths.get(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toAbsolutePath(); - // /<version> /modlauncher/mods /cpw /libraries - return launcher.getParent().getParent().getParent().getParent().getParent().toAbsolutePath(); + Path launcher = Paths.get(Launcher.class.getProtectionDomain().getCodeSource().getLocation().toURI()); + + while (!launcher.getFileName().toString().equals("libraries")) { + launcher = launcher.getParent(); + + if (launcher == null || launcher.getFileName() == null) { + throw new UnsupportedOperationException("Could not detect the libraries folder - it can be manually specified with `-Dforgewrapper.librariesDir=` (Java runtime argument)"); + } + } + + return launcher.toAbsolutePath(); } catch (URISyntaxException e) { throw new RuntimeException(e); } |
