[Fix 2378] Invalid Modrinth Mod ID 错误的 Modrinth Mod ID (#2385)
* Upgrade timeout to 30s * Fix #2378 * Revert "Upgrade timeout to 30s" This reverts commit 366a9dd34b7d2706d3a6ec42398c0c9ba43af4f8.
This commit is contained in:
@@ -30,6 +30,19 @@ import java.util.stream.Stream;
|
||||
import static org.jackhuang.hmcl.util.io.NetworkUtils.encodeLocation;
|
||||
|
||||
public class RemoteMod {
|
||||
private static RemoteMod EMPTY = null;
|
||||
|
||||
public static void registerEmptyRemoteMod(RemoteMod empty) {
|
||||
EMPTY = empty;
|
||||
}
|
||||
|
||||
public static RemoteMod getEmptyRemoteMod() {
|
||||
if (EMPTY == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
private final String slug;
|
||||
private final String author;
|
||||
private final String title;
|
||||
|
||||
@@ -291,6 +291,9 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository {
|
||||
.collect(Collectors.toSet());
|
||||
List<RemoteMod> mods = new ArrayList<>();
|
||||
for (String dependencyId : dependencies) {
|
||||
if (dependencyId == null) {
|
||||
mods.add(RemoteMod.getEmptyRemoteMod());
|
||||
}
|
||||
if (StringUtils.isNotBlank(dependencyId)) {
|
||||
mods.add(modRepository.getModById(dependencyId));
|
||||
}
|
||||
@@ -493,7 +496,7 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository {
|
||||
datePublished,
|
||||
type,
|
||||
files.get(0).toFile(),
|
||||
dependencies.stream().map(Dependency::getProjectId).filter(Objects::nonNull).collect(Collectors.toList()),
|
||||
dependencies.stream().map(dependency -> dependency.getVersionId() == null ? null : dependency.getProjectId()).collect(Collectors.toList()),
|
||||
gameVersions,
|
||||
loaders.stream().flatMap(loader -> {
|
||||
if ("fabric".equalsIgnoreCase(loader)) return Stream.of(ModLoaderType.FABRIC);
|
||||
@@ -653,6 +656,9 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository {
|
||||
.collect(Collectors.toSet());
|
||||
List<RemoteMod> mods = new ArrayList<>();
|
||||
for (String dependencyId : dependencies) {
|
||||
if (dependencyId == null) {
|
||||
mods.add(RemoteMod.getEmptyRemoteMod());
|
||||
}
|
||||
if (StringUtils.isNotBlank(dependencyId)) {
|
||||
mods.add(modRepository.getModById(dependencyId));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user