[Fix 2378] Invalid Modrinth Mod ID 错误的 Modrinth Mod ID (#2385)

* Upgrade timeout to 30s

* Fix #2378

* Revert "Upgrade timeout to 30s"

This reverts commit 366a9dd34b.
This commit is contained in:
Burning_TNT authored and GitHub committed 2023-07-20 14:30:22 +08:00
1 parent 83120afb63
commit 61165dd71d
7 files changed
+43 -2

No files matched your search

@@ -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));
}