From 30565c2b5077d53fd85847a4d9d8a1d7e0ecb7fa Mon Sep 17 00:00:00 2001 From: Tungstend <74163103+Tungstend@users.noreply.github.com> Date: Thu, 2 Jun 2022 14:14:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcf=E6=BA=90=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=89=8D=E7=BD=AE=E6=A8=A1=E7=BB=84=20(#1520?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复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 --- .../jackhuang/hmcl/mod/curse/CurseAddon.java | 36 +++++++------------ .../curse/CurseForgeRemoteModRepository.java | 6 ++-- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java index 82a2485e5..00cf85b95 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseAddon.java @@ -182,8 +182,8 @@ public class CurseAddon implements RemoteMod.IMod { public List loadDependencies(RemoteModRepository modRepository) throws IOException { Set 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 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; } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java index f981ae736..0999806d3 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java @@ -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 response = HttpRequest.GET(PREFIX + "/v1/mods/" + id) .header("X-API-KEY", apiKey) - .getJson(CurseAddon.class).toMod(); + .getJson(new TypeToken>() { + }.getType()); + return response.data.toMod(); } @Override