From 94befda8dc928303f7034abbd728a4ab3e263adf Mon Sep 17 00:00:00 2001 From: CiiLu <109708109+CiiLu@users.noreply.github.com> Date: Sun, 6 Sep 2026 09:11:20 +0800 Subject: [PATCH] =?UTF-8?q?<9>=20=E4=B8=8D=E6=95=A2=E9=97=AE=E4=B9=A6?= =?UTF-8?q?=E7=AC=BA=20=E5=BF=83=E4=BA=8B=E6=89=98=E9=B8=BF=E9=9B=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../optifine/OptiFineBMCLVersionList.java | 80 +++---------------- 1 file changed, 11 insertions(+), 69 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineBMCLVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineBMCLVersionList.java index 4ec3b8d193..24d1c67c3b 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineBMCLVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/optifine/OptiFineBMCLVersionList.java @@ -22,6 +22,7 @@ import org.jackhuang.hmcl.task.GetTask; import org.jackhuang.hmcl.task.Task; import org.jackhuang.hmcl.util.StringUtils; +import org.jackhuang.hmcl.util.gson.JsonSerializable; import org.jackhuang.hmcl.util.versioning.VersionNumber; import java.util.Collections; @@ -79,17 +80,17 @@ public Task refreshAsync() { versions.clear(); Set duplicates = new HashSet<>(); for (OptiFineVersion element : root) { - String version = element.getType() + "_" + element.getPatch(); - String mirror = apiRoot + "/optifine/" + toLookupVersion(element.getGameVersion()) + "/" + element.getType() + "/" + element.getPatch(); + String version = element.type() + "_" + element.patch(); + String mirror = apiRoot + "/optifine/" + toLookupVersion(element.gameVersion()) + "/" + element.type() + "/" + element.patch(); if (!duplicates.add(mirror)) continue; - boolean isPre = element.getPatch() != null && (element.getPatch().startsWith("pre") || element.getPatch().startsWith("alpha")); + boolean isPre = element.patch() != null && (element.patch().startsWith("pre") || element.patch().startsWith("alpha")); - if (StringUtils.isBlank(element.getGameVersion())) + if (StringUtils.isBlank(element.gameVersion())) continue; - String gameVersion = VersionNumber.normalize(fromLookupVersion(element.getGameVersion())); + String gameVersion = VersionNumber.normalize(fromLookupVersion(element.gameVersion())); versions.put(gameVersion, new OptiFineRemoteVersion(gameVersion, version, Collections.singletonList(mirror), isPre)); } } finally { @@ -97,73 +98,14 @@ public Task refreshAsync() { } }); } - /** * @author huangyuhui */ - private static final class OptiFineVersion { - - @SerializedName("dl") - private final String downloadLink; - - @SerializedName("ver") - private final String version; - - @SerializedName("date") - private final String date; - - @SerializedName("type") - private final String type; - - @SerializedName("patch") - private final String patch; - - @SerializedName("mirror") - private final String mirror; - @SerializedName("mcversion") - private final String gameVersion; - - public OptiFineVersion() { - this(null, null, null, null, null, null, null); - } - - public OptiFineVersion(String downloadLink, String version, String date, String type, String patch, String mirror, String gameVersion) { - this.downloadLink = downloadLink; - this.version = version; - this.date = date; - this.type = type; - this.patch = patch; - this.mirror = mirror; - this.gameVersion = gameVersion; - } - - public String getDownloadLink() { - return downloadLink; - } - - public String getVersion() { - return version; - } - - public String getDate() { - return date; - } - - public String getType() { - return type; - } - - public String getPatch() { - return patch; - } - - public String getMirror() { - return mirror; - } - - public String getGameVersion() { - return gameVersion; - } + @JsonSerializable + private record OptiFineVersion(@SerializedName("dl") String downloadLink, @SerializedName("ver") String version, + @SerializedName("date") String date, @SerializedName("type") String type, + @SerializedName("patch") String patch, @SerializedName("mirror") String mirror, + @SerializedName("mcversion") String gameVersion) { } }