From ba91c60e953cf8ddb2cfced1e355b9d2ac5ca5c7 Mon Sep 17 00:00:00 2001 From: Burning_TNT <88144530+burningtnt@users.noreply.github.com> Date: Sun, 10 Mar 2024 22:45:34 +0800 Subject: [PATCH] Always sort the results while searching in CurseForge. (#2916) --- .../hmcl/mod/curse/CurseForgeRemoteModRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3d8340d570..a02ce58abe 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 @@ -44,7 +44,7 @@ public final class CurseForgeRemoteModRepository implements RemoteModRepository private static final String PREFIX = "https://api.curseforge.com"; private static final String apiKey = System.getProperty("hmcl.curseforge.apikey", JarUtils.getManifestAttribute("CurseForge-Api-Key", "")); - private static final int WORD_PERFECT_MATCH_WEIGHT = 50; + private static final int WORD_PERFECT_MATCH_WEIGHT = 5; public static boolean isAvailable() { return !apiKey.isEmpty(); @@ -112,7 +112,7 @@ public SearchResult search(String gameVersion, @Nullable RemoteModRepository.Cat .getJson(new TypeToken>>() { }.getType()); Stream res = response.getData().stream().map(CurseAddon::toMod); - if (sortType != SortType.NAME || searchFilter.isEmpty()) { + if (searchFilter.isEmpty()) { return new SearchResult(res, (int)Math.ceil((double)response.pagination.totalCount / pageSize)); }