Skip to content

Commit 0d9e2d9

Browse files
authored
[release/3.9] 修复 CurseForge 源无法搜索到内容的问题 (#5232)
#5220
1 parent 9f754e7 commit 0d9e2d9

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

HMCLCore/src/main/java/org/jackhuang/hmcl/mod/curse/CurseForgeRemoteModRepository.java

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,16 +114,20 @@ public SearchResult search(DownloadProvider downloadProvider, String gameVersion
114114
if (category != null && category.getSelf() instanceof CurseAddon.Category) {
115115
categoryId = ((CurseAddon.Category) category.getSelf()).getId();
116116
}
117-
Response<List<CurseAddon>> response = withApiKey(HttpRequest.GET(downloadProvider.injectURL(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", mapOf(
118-
pair("gameId", "432"),
119-
pair("classId", Integer.toString(section)),
120-
pair("categoryId", Integer.toString(categoryId)),
121-
pair("gameVersion", gameVersion),
122-
pair("searchFilter", searchFilter),
123-
pair("sortField", Integer.toString(toModsSearchSortField(sortType))),
124-
pair("sortOrder", toSortOrder(sortOrder)),
125-
pair("index", Integer.toString(pageOffset * pageSize)),
126-
pair("pageSize", Integer.toString(pageSize)))))))
117+
118+
var query = new LinkedHashMap<String, String>();
119+
query.put("gameId", "432");
120+
query.put("classId", Integer.toString(section));
121+
if (categoryId != 0)
122+
query.put("categoryId", Integer.toString(categoryId));
123+
query.put("gameVersion", gameVersion);
124+
query.put("searchFilter", searchFilter);
125+
query.put("sortField", Integer.toString(toModsSearchSortField(sortType)));
126+
query.put("sortOrder", toSortOrder(sortOrder));
127+
query.put("index", Integer.toString(pageOffset * pageSize));
128+
query.put("pageSize", Integer.toString(pageSize));
129+
130+
Response<List<CurseAddon>> response = withApiKey(HttpRequest.GET(downloadProvider.injectURL(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", query))))
127131
.getJson(Response.typeOf(listTypeOf(CurseAddon.class)));
128132
if (searchFilter.isEmpty()) {
129133
return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize));

0 commit comments

Comments
 (0)