diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/multimc/MultiMCInstancePatch.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/multimc/MultiMCInstancePatch.java index 06baad358..97d8c8a5f 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/multimc/MultiMCInstancePatch.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/multimc/MultiMCInstancePatch.java @@ -47,7 +47,6 @@ import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Set; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -190,12 +189,14 @@ public final class MultiMCInstancePatch { return value != null && !value.isEmpty() ? value : Collections.emptyList(); } - private static List dropDuplicate(List original, Function mapper) { - Set values = new HashSet<>(); + private static List dropDuplicate(List original) { + // TODO: Maybe new ArrayList(new LinkedHashSet(original)) ? + + Set values = new HashSet<>(); List result = new ArrayList<>(); for (T item : original) { - if (values.add(mapper.apply(item))) { + if (values.add(item)) { result.add(item); } } @@ -285,6 +286,8 @@ public final class MultiMCInstancePatch { Library mainJar; List traits; List tweakers; + /* TODO: MultiMC use a slightly different way to store jars containing jni files. + Transforming them to Official Scheme might boost compatibility with other launchers. */ List libraries; List mavenOnlyFiles; List jarModFileNames; @@ -338,10 +341,9 @@ public final class MultiMCInstancePatch { } } - traits = dropDuplicate(traits, Function.identity()); - tweakers = dropDuplicate(tweakers, Function.identity()); - libraries = dropDuplicate(libraries, Library::getName); - jarModFileNames = dropDuplicate(jarModFileNames, Function.identity()); + traits = dropDuplicate(traits); + tweakers = dropDuplicate(tweakers); + jarModFileNames = dropDuplicate(jarModFileNames); for (String tweaker : tweakers) { minecraftArguments.add("--tweakClass");