mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-08 03:15:17 -04:00
Fix: MultiMC allows libraries with the same artifact descriptor string. (#4016)
This commit is contained in:
parent
bc41499d1c
commit
730febca8c
@ -47,7 +47,6 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -190,12 +189,14 @@ public final class MultiMCInstancePatch {
|
|||||||
return value != null && !value.isEmpty() ? value : Collections.emptyList();
|
return value != null && !value.isEmpty() ? value : Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T, K> List<T> dropDuplicate(List<T> original, Function<T, K> mapper) {
|
private static <T> List<T> dropDuplicate(List<T> original) {
|
||||||
Set<K> values = new HashSet<>();
|
// TODO: Maybe new ArrayList(new LinkedHashSet(original)) ?
|
||||||
|
|
||||||
|
Set<T> values = new HashSet<>();
|
||||||
List<T> result = new ArrayList<>();
|
List<T> result = new ArrayList<>();
|
||||||
|
|
||||||
for (T item : original) {
|
for (T item : original) {
|
||||||
if (values.add(mapper.apply(item))) {
|
if (values.add(item)) {
|
||||||
result.add(item);
|
result.add(item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -285,6 +286,8 @@ public final class MultiMCInstancePatch {
|
|||||||
Library mainJar;
|
Library mainJar;
|
||||||
List<String> traits;
|
List<String> traits;
|
||||||
List<String> tweakers;
|
List<String> 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<Library> libraries;
|
List<Library> libraries;
|
||||||
List<Library> mavenOnlyFiles;
|
List<Library> mavenOnlyFiles;
|
||||||
List<String> jarModFileNames;
|
List<String> jarModFileNames;
|
||||||
@ -338,10 +341,9 @@ public final class MultiMCInstancePatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
traits = dropDuplicate(traits, Function.identity());
|
traits = dropDuplicate(traits);
|
||||||
tweakers = dropDuplicate(tweakers, Function.identity());
|
tweakers = dropDuplicate(tweakers);
|
||||||
libraries = dropDuplicate(libraries, Library::getName);
|
jarModFileNames = dropDuplicate(jarModFileNames);
|
||||||
jarModFileNames = dropDuplicate(jarModFileNames, Function.identity());
|
|
||||||
|
|
||||||
for (String tweaker : tweakers) {
|
for (String tweaker : tweakers) {
|
||||||
minecraftArguments.add("--tweakClass");
|
minecraftArguments.add("--tweakClass");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user