From 0280a34d00e44b0975822e537423a934d6eb50ba Mon Sep 17 00:00:00 2001 From: Glavo Date: Sun, 11 Jun 2023 15:47:43 +0800 Subject: [PATCH] fix #2267: filter duplicate jars in the class path (#2280) --- .../main/java/org/jackhuang/hmcl/game/GameRepository.java | 8 ++++---- .../java/org/jackhuang/hmcl/launch/DefaultLauncher.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/GameRepository.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/GameRepository.java index 6ddad8999..33d4f60af 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/GameRepository.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/GameRepository.java @@ -23,10 +23,10 @@ import org.jackhuang.hmcl.util.platform.Platform; import java.io.File; import java.io.IOException; import java.nio.file.Path; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; +import java.util.LinkedHashSet; import java.util.Optional; +import java.util.Set; /** * Supports operations on versioning. @@ -250,8 +250,8 @@ public interface GameRepository extends VersionProvider { */ Path getLoggingObject(String version, String assetId, LoggingInfo loggingInfo); - default List getClasspath(Version version) { - List classpath = new ArrayList<>(); + default Set getClasspath(Version version) { + Set classpath = new LinkedHashSet<>(); for (Library library : version.getLibraries()) if (library.appliesToCurrentEnvironment() && !library.isNative()) { File f = getLibraryFile(version, library); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java index b5915a7c8..4459e9ee2 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/launch/DefaultLauncher.java @@ -207,7 +207,7 @@ public class DefaultLauncher extends Launcher { res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true"); } - List classpath = repository.getClasspath(version); + Set classpath = repository.getClasspath(version); File jar = repository.getVersionJar(version); if (!jar.exists() || !jar.isFile())