|
26 | 26 | import org.jackhuang.hmcl.util.StringUtils; |
27 | 27 | import org.jackhuang.hmcl.util.io.HttpRequest; |
28 | 28 | import org.jackhuang.hmcl.util.io.JarUtils; |
| 29 | +import org.jackhuang.hmcl.util.io.NetworkUtils; |
29 | 30 | import org.jetbrains.annotations.Nullable; |
30 | 31 |
|
31 | 32 | import java.io.ByteArrayOutputStream; |
@@ -105,18 +106,19 @@ public SearchResult search(String gameVersion, @Nullable RemoteModRepository.Cat |
105 | 106 | if (category != null && category.getSelf() instanceof CurseAddon.Category) { |
106 | 107 | categoryId = ((CurseAddon.Category) category.getSelf()).getId(); |
107 | 108 | } |
108 | | - Response<List<CurseAddon>> response = HttpRequest.GET(PREFIX + "/v1/mods/search", |
109 | | - pair("gameId", "432"), |
110 | | - pair("classId", Integer.toString(section)), |
111 | | - pair("categoryId", Integer.toString(categoryId)), |
112 | | - pair("gameVersion", gameVersion), |
113 | | - pair("searchFilter", searchFilter), |
114 | | - pair("sortField", Integer.toString(toModsSearchSortField(sortType))), |
115 | | - pair("sortOrder", toSortOrder(sortOrder)), |
116 | | - pair("index", Integer.toString(pageOffset * pageSize)), |
117 | | - pair("pageSize", Integer.toString(pageSize))) |
118 | | - .header("X-API-KEY", apiKey) |
119 | | - .getJson(Response.typeOf(listTypeOf(CurseAddon.class))); |
| 109 | + Map<String, String> query = new LinkedHashMap<>(); |
| 110 | + query.put("gameId", "432"); |
| 111 | + query.put("classId", Integer.toString(section)); |
| 112 | + if (categoryId != 0) |
| 113 | + query.put("categoryId", Integer.toString(categoryId)); |
| 114 | + query.put("gameVersion", gameVersion); |
| 115 | + query.put("searchFilter", searchFilter); |
| 116 | + query.put("sortField", Integer.toString(toModsSearchSortField(sortType))); |
| 117 | + query.put("sortOrder", toSortOrder(sortOrder)); |
| 118 | + query.put("index", Integer.toString(pageOffset * pageSize)); |
| 119 | + query.put("pageSize", Integer.toString(pageSize)); |
| 120 | + |
| 121 | + Response<List<CurseAddon>> response = HttpRequest.GET(NetworkUtils.withQuery(PREFIX + "/v1/mods/search", query)).header("X-API-KEY", apiKey).getJson(Response.typeOf(listTypeOf(CurseAddon.class))); |
120 | 122 | if (searchFilter.isEmpty()) { |
121 | 123 | return new SearchResult(response.getData().stream().map(CurseAddon::toMod), calculateTotalPages(response, pageSize)); |
122 | 124 | } |
|
0 commit comments