fix #2267: filter duplicate jars in the class path (#2280)

This commit is contained in:
Glavo 2023-06-11 15:47:43 +08:00 committed by GitHub
parent 811707b611
commit 0280a34d00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -23,10 +23,10 @@ import org.jackhuang.hmcl.util.platform.Platform;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.LinkedHashSet;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
/** /**
* Supports operations on versioning. * Supports operations on versioning.
@ -250,8 +250,8 @@ public interface GameRepository extends VersionProvider {
*/ */
Path getLoggingObject(String version, String assetId, LoggingInfo loggingInfo); Path getLoggingObject(String version, String assetId, LoggingInfo loggingInfo);
default List<String> getClasspath(Version version) { default Set<String> getClasspath(Version version) {
List<String> classpath = new ArrayList<>(); Set<String> classpath = new LinkedHashSet<>();
for (Library library : version.getLibraries()) for (Library library : version.getLibraries())
if (library.appliesToCurrentEnvironment() && !library.isNative()) { if (library.appliesToCurrentEnvironment() && !library.isNative()) {
File f = getLibraryFile(version, library); File f = getLibraryFile(version, library);

View File

@ -207,7 +207,7 @@ public class DefaultLauncher extends Launcher {
res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true"); res.addDefault("-Dfml.ignorePatchDiscrepancies=", "true");
} }
List<String> classpath = repository.getClasspath(version); Set<String> classpath = repository.getClasspath(version);
File jar = repository.getVersionJar(version); File jar = repository.getVersionJar(version);
if (!jar.exists() || !jar.isFile()) if (!jar.exists() || !jar.isFile())