修复cf源无法获取前置模组 (#1520)

* 修复Modrinth源加载列表失败,增加Modrinth源获取前置模组功能

* Revert "修复Modrinth源加载列表失败,增加Modrinth源获取前置模组功能"

This reverts commit 1d29c69d92db8714599ed8f8b524e143e278b80a.

* 修复CF源获取模组版本列表不全

* Modrinth源获取类别列表,搜索时增加类别选项

* Update ModrinthRemoteModRepository.java

* Update ModrinthRemoteModRepository.java

* 修复cf源获取前置模组失败

* Revert "Update ModrinthRemoteModRepository.java"

This reverts commit 40b7c1d59d4b8918e633d6db1ed73df5bcbbc9ae.

* Revert "Revert "Update ModrinthRemoteModRepository.java""

This reverts commit 2027c9ef4c9d7fc668229c9484f63bfb9d4dbb07.

* Revert "修复cf源获取前置模组失败"

This reverts commit 4404daf0eaecf194fa264208a3d7edeccad15c1e.

* fix conflict

* 修复cf源无法获取前置模组

* fix check style
This commit is contained in:
Tungstend
2022-06-02 14:14:51 +08:00
committed by GitHub
parent c400c7be9d
commit 30565c2b50
2 changed files with 16 additions and 26 deletions

View File

@@ -182,8 +182,8 @@ public class CurseAddon implements RemoteMod.IMod {
public List<RemoteMod> loadDependencies(RemoteModRepository modRepository) throws IOException {
Set<Integer> dependencies = latestFiles.stream()
.flatMap(latestFile -> latestFile.getDependencies().stream())
.filter(dep -> dep.getType() == 3)
.map(Dependency::getAddonId)
.filter(dep -> dep.getRelationType() == 3)
.map(Dependency::getModId)
.collect(Collectors.toSet());
List<RemoteMod> mods = new ArrayList<>();
for (int dependencyId : dependencies) {
@@ -370,36 +370,24 @@ public class CurseAddon implements RemoteMod.IMod {
@Immutable
public static class Dependency {
private final int id;
private final int addonId;
private final int type;
private final int fileId;
private final int modId;
private final int relationType;
public Dependency() {
this(0, 0, 0, 0);
this(0, 1);
}
public Dependency(int id, int addonId, int type, int fileId) {
this.id = id;
this.addonId = addonId;
this.type = type;
this.fileId = fileId;
public Dependency(int modId, int relationType) {
this.modId = modId;
this.relationType = relationType;
}
public int getId() {
return id;
public int getModId() {
return modId;
}
public int getAddonId() {
return addonId;
}
public int getType() {
return type;
}
public int getFileId() {
return fileId;
public int getRelationType() {
return relationType;
}
}

View File

@@ -145,9 +145,11 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository
@Override
public RemoteMod getModById(String id) throws IOException {
return HttpRequest.GET(PREFIX + "/v1/mods/" + id)
Response<CurseAddon> response = HttpRequest.GET(PREFIX + "/v1/mods/" + id)
.header("X-API-KEY", apiKey)
.getJson(CurseAddon.class).toMod();
.getJson(new TypeToken<Response<CurseAddon>>() {
}.getType());
return response.data.toMod();
}
@Override