@@ -159,7 +159,7 @@ public final class RemoteMod {
|
||||
if (this.type == DependencyType.BROKEN) {
|
||||
this.remoteMod = RemoteMod.BROKEN;
|
||||
} else {
|
||||
this.remoteMod = this.remoteModRepository.getModById(this.id);
|
||||
this.remoteMod = this.remoteModRepository.resolveDependency(this.id);
|
||||
}
|
||||
}
|
||||
return this.remoteMod;
|
||||
|
||||
@@ -92,6 +92,10 @@ public interface RemoteModRepository {
|
||||
|
||||
RemoteMod getModById(String id) throws IOException;
|
||||
|
||||
default RemoteMod resolveDependency(String id) throws IOException {
|
||||
return getModById(id);
|
||||
}
|
||||
|
||||
RemoteMod.File getModFile(String modId, String fileId) throws IOException;
|
||||
|
||||
Stream<RemoteMod.Version> getRemoteVersionsById(String id) throws IOException;
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jackhuang.hmcl.util.io.NetworkUtils;
|
||||
import org.jackhuang.hmcl.util.io.ResponseCodeException;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.NoSuchFileException;
|
||||
import java.nio.file.Path;
|
||||
@@ -154,6 +155,20 @@ public final class ModrinthRemoteModRepository implements RemoteModRepository {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteMod resolveDependency(String id) throws IOException {
|
||||
try {
|
||||
return getModById(id);
|
||||
} catch (ResponseCodeException e) {
|
||||
if (e.getResponseCode() == 502 || e.getResponseCode() == 404) {
|
||||
return RemoteMod.BROKEN;
|
||||
}
|
||||
throw e;
|
||||
} catch (FileNotFoundException e) {
|
||||
return RemoteMod.BROKEN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public RemoteMod.File getModFile(String modId, String fileId) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
|
||||
Reference in New Issue
Block a user