diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java index 6f155399..7464ebff 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java @@ -49,6 +49,7 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti jvmArgs.add("-XX:G1HeapRegionSize=32M"); // ----------- Optional forge = findOption(options, MakeProfileOptionForge.class); + Optional fabric = findOption(options, MakeProfileOptionFabric.class); if (version.compareTo(ClientProfile.Version.MC1122) > 0) { jvmArgs.add("-Djava.library.path=natives"); OptionalFile optionalMacOs = new OptionalFile(); @@ -59,6 +60,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti optionalMacOs.triggersList = List.of(new OSTrigger(JVMHelper.OS.MACOSX)); optionals.add(optionalMacOs); } + if (fabric.isPresent()) { + builder.setAltClassPath(fabric.orElseThrow().getAltClassPath()); + } if (findOption(options, MakeProfileOptionLwjgl.class).isPresent()) { OptionalFile optionalMac = new OptionalFile(); optionalMac.name = "MacLwjgl"; @@ -163,7 +167,7 @@ public static MakeProfileOption[] getMakeProfileOptionsFromDir(Path dir, ClientP options.add(new MakeProfileOptionForge(dir)); } if (Files.exists(dir.resolve("libraries/net/fabricmc/fabric-loader"))) { - options.add(new MakeProfileOptionFabric()); + options.add(new MakeProfileOptionFabric(dir)); } } if (Files.exists(dir.resolve("liteloader.jar"))) { @@ -232,12 +236,37 @@ private static Path findFirstDir(Path path) throws IOException { return Files.list(path).findFirst().orElse(null); } + private static Path findFirstMavenFile(Path path) throws IOException { + return Files.list(Files.list(path).findFirst().orElseThrow()).filter(e -> e.getFileName().toString().endsWith(".jar")).findFirst().orElseThrow(); + } + public static class MakeProfileOptionLaunchWrapper implements MakeProfileOption { } public static class MakeProfileOptionFabric implements MakeProfileOption { + public String jimfsPath; + public String guavaPath; + public List getAltClassPath() { + if (jimfsPath == null || guavaPath == null) return List.of(); + return List.of(jimfsPath, guavaPath); + } + + public MakeProfileOptionFabric() { + } + + public MakeProfileOptionFabric(String jimfsPath, String guavaPath) { + this.jimfsPath = jimfsPath; + this.guavaPath = guavaPath; + } + + public MakeProfileOptionFabric(Path clientDir) throws IOException { + if (Files.exists(clientDir.resolve("libraries/com/google/jimfs/jimfs"))) { + jimfsPath = clientDir.relativize(findFirstMavenFile(clientDir.resolve("libraries/com/google/jimfs/jimfs"))).toString(); + guavaPath = clientDir.relativize(findFirstMavenFile(clientDir.resolve("libraries/com/google/guava/guava/"))).toString(); + } + } } public static class MakeProfileOptionLiteLoader implements MakeProfileOption {