Skip to content

Commit 8fed3b7

Browse files
authored
Merge branch 'HMCL-dev:main' into mod-changelog
2 parents d351523 + a7b952f commit 8fed3b7

File tree

14 files changed

+75
-42
lines changed

14 files changed

+75
-42
lines changed

HMCL/src/main/java/org/jackhuang/hmcl/upgrade/UpdateChecker.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public static void requestCheckUpdate(UpdateChannel channel, boolean preview) {
112112
try {
113113
result = checkUpdate(channel, preview);
114114
LOG.info("Latest version (" + channel + ", preview=" + preview + ") is " + result);
115-
} catch (IOException e) {
115+
} catch (Throwable e) {
116116
LOG.warning("Failed to check for update", e);
117117
}
118118

HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/I18n.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.jackhuang.hmcl.download.game.GameRemoteVersion;
2222
import org.jackhuang.hmcl.util.i18n.translator.Translator;
2323
import org.jetbrains.annotations.Nullable;
24+
import org.jetbrains.annotations.PropertyKey;
2425

2526
import java.io.IOException;
2627
import java.io.InputStream;
@@ -59,11 +60,11 @@ public static Translator getTranslator() {
5960
return locale.getTranslator();
6061
}
6162

62-
public static String i18n(String key, Object... formatArgs) {
63+
public static String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key, Object... formatArgs) {
6364
return locale.i18n(key, formatArgs);
6465
}
6566

66-
public static String i18n(String key) {
67+
public static String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key) {
6768
return locale.i18n(key);
6869
}
6970

HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/MinecraftWiki.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public final class MinecraftWiki {
3030
private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("^[0-9]{2}w[0-9]{2}.+$");
3131

3232
public static String getWikiLink(SupportedLocale locale, GameRemoteVersion version) {
33-
String wikiVersion = version.getSelfVersion();
33+
String wikiVersion = StringUtils.removeSuffix(version.getSelfVersion(), "_unobfuscated");
3434
var gameVersion = GameVersionNumber.asGameVersion(wikiVersion);
3535

3636
if (locale.getLocale().getLanguage().equals("lzh")) {
@@ -80,8 +80,6 @@ else if (wikiVersion.startsWith("1.0.0-rc2"))
8080
if (SNAPSHOT_PATTERN.matcher(wikiVersion).matches()) {
8181
if (wikiVersion.equals("22w13oneblockatatime"))
8282
wikiVersion = "22w13oneBlockAtATime";
83-
else
84-
wikiVersion = StringUtils.removeSuffix(wikiVersion, "_unobfuscated");
8583
return locale.i18n("wiki.version.game.snapshot", wikiVersion) + variantSuffix;
8684
}
8785
}

HMCL/src/main/java/org/jackhuang/hmcl/util/i18n/SupportedLocale.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.jackhuang.hmcl.util.StringUtils;
2525
import org.jackhuang.hmcl.util.gson.JsonUtils;
2626
import org.jackhuang.hmcl.util.i18n.translator.Translator;
27+
import org.jetbrains.annotations.PropertyKey;
2728

2829
import java.io.IOException;
2930
import java.io.InputStream;
@@ -187,7 +188,7 @@ public List<Locale> getCandidateLocales() {
187188
return candidateLocales;
188189
}
189190

190-
public String i18n(String key, Object... formatArgs) {
191+
public String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key, Object... formatArgs) {
191192
try {
192193
return String.format(getResourceBundle().getString(key), formatArgs);
193194
} catch (MissingResourceException e) {
@@ -199,7 +200,7 @@ public String i18n(String key, Object... formatArgs) {
199200
return key + Arrays.toString(formatArgs);
200201
}
201202

202-
public String i18n(String key) {
203+
public String i18n(@PropertyKey(resourceBundle = "assets.lang.I18N") String key) {
203204
try {
204205
return getResourceBundle().getString(key);
205206
} catch (MissingResourceException e) {

HMCL/src/main/resources/assets/terracotta.json

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
{
2-
"version_legacy": "0\\.3\\.([89]-rc\\.([0-9]|10)|10|11|12)",
2+
"version_legacy": "0\\.3\\.([89]-rc\\.([0-9]|10)|(1[0-3]))",
33
"version_recent": [
4-
"0.3.12"
4+
"0.3.13"
55
],
6-
"version_latest": "0.3.13",
6+
"version_latest": "0.3.14",
77
"classifiers": {
8-
"freebsd-x86_64": "sha256:0713e54ee552496416bda9d9e814e33a8950ca8f321f5b3c6dd2e07e79b0e3af",
9-
"linux-arm64": "sha256:61affc46035337c182adeca3671b4cf4cc59c7b4e73039899f35416f7d00ad94",
10-
"linux-x86_64": "sha256:9399e1627b77d518950e66d944c9a4b70c20d2e13ca2c0e2fed0ded637e7ae06",
11-
"linux-loongarch64": "sha256:f3eb4c40dfccc25b5b355298c776abe3d399afb57a2af38803dd78089f0c182e",
12-
"linux-riscv64": "sha256:26f95f8b5f83746c9cf9a8362ce0ef793ede8515897a1ba15e5e6f93c3d39533",
13-
"macos-arm64": "sha256:35ba271c7dc924e91c2fdd8c1cabeff2ce3d060836748a7a07162b0a5900e8d5",
14-
"macos-arm64.pkg": "sha256:90a613ec69f28713fe06188247c57b7cc91743c95112de5aed85ea252103beaa",
15-
"macos-x86_64": "sha256:45b420b15a32d5450794a9776cf45a217871cf4333b29b65a35d7358c806b5b1",
16-
"macos-x86_64.pkg": "sha256:587623becb3593ccb5fe542a201a67ab3a4029dfa847fcef758faff7ba6d38d5",
17-
"windows-arm64.exe": "sha256:bd4e1acf2f304761cdabddd9ade94d046534f4c024bc3026ac98e6be58c2bc22",
18-
"windows-x86_64.exe": "sha256:b89599bbcc92b00222cfc6f2e5ef636b7daf192c96efba1049a892e6cb59ee70"
8+
"freebsd-x86_64": "sha256:ff8c50b701e55fde9701a1f7fbe9d7317b24087c28ca6337ba9d695c53ad499a",
9+
"linux-arm64": "sha256:6912a14255cdeedee512244c686dd7f80dcc45d8dfbe129ea4ea3f1b22d3de60",
10+
"linux-x86_64": "sha256:9b13f51dc41c5112f2ab163df5c0dccdff3d22deb793a6698c013e9c09badd00",
11+
"linux-loongarch64": "sha256:729ca24ef643547b6a3917520ec3335b92e226ad1884c85d6bb6c2cfa917cb03",
12+
"linux-riscv64": "sha256:afbd8cffeacc47431f18c3ae659f7a308e1d3f2efab0ab9c5ece5176d068bf30",
13+
"macos-arm64": "sha256:9ed9c7a35b01dce440135c91e4a5e617d84f6c8ba13a117d13a2796dc69584f5",
14+
"macos-arm64.pkg": "sha256:49dbebd608c4036c260f09d4005dedaacb26fc1582b10479ed51476baa48f4a9",
15+
"macos-x86_64": "sha256:40a44703237b0a194b0fb18075e3b2361ace8f4319b60269cb56c5548d2afb3a",
16+
"macos-x86_64.pkg": "sha256:95a9de782b9c3a352ae6ec702c2fc4ca34ba807e8e4a768e61902a0c78391332",
17+
"windows-arm64.exe": "sha256:8428c6bc6228213c5f645ab3dd0f3b684da515be103ee53d5bdc4adf59fc8a5f",
18+
"windows-x86_64.exe": "sha256:942b91888264e1c96a10b7c94bd134f4b10d3e352e3c731def0ff6a3069c8221"
1919
},
2020
"downloads": [
2121
"https://github.com/burningtnt/Terracotta/releases/download/v${version}/terracotta-${version}-${classifier}"

HMCLCore/src/main/java/org/jackhuang/hmcl/download/BMCLAPIDownloadProvider.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ public BMCLAPIDownloadProvider(String apiRoot) {
8282
pair("https://authlib-injector.yushi.moe", apiRoot + "/mirrors/authlib-injector"),
8383
pair("https://repo1.maven.org/maven2", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public"),
8484
pair("https://repo.maven.apache.org/maven2", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public"),
85-
pair("https://hmcl-dev.github.io/metadata/cleanroom", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/cleanroom"),
86-
pair("https://hmcl-dev.github.io/metadata/fmllibs", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/fmllibs"),
85+
pair("https://hmcl.glavo.site/metadata/cleanroom", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/cleanroom"),
86+
pair("https://hmcl.glavo.site/metadata/fmllibs", "https://alist.8mi.tech/d/mirror/HMCL-Metadata/Auto/fmllibs"),
8787
pair("https://zkitefly.github.io/unlisted-versions-of-minecraft", "https://alist.8mi.tech/d/mirror/unlisted-versions-of-minecraft/Auto")
8888
// // https://github.com/mcmod-info-mirror/mcim-rust-api
8989
// pair("https://api.modrinth.com", "https://mod.mcimirror.top/modrinth"),

HMCLCore/src/main/java/org/jackhuang/hmcl/download/cleanroom/CleanroomVersionList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727

2828
public final class CleanroomVersionList extends VersionList<CleanroomRemoteVersion> {
2929
private final DownloadProvider downloadProvider;
30-
private static final String LOADER_LIST_URL = "https://hmcl-dev.github.io/metadata/cleanroom/index.json";
31-
private static final String INSTALLER_URL = "https://hmcl-dev.github.io/metadata/cleanroom/files/cleanroom-%s-installer.jar";
30+
private static final String LOADER_LIST_URL = "https://hmcl.glavo.site/metadata/cleanroom/index.json";
31+
private static final String INSTALLER_URL = "https://hmcl.glavo.site/metadata/cleanroom/files/cleanroom-%s-installer.jar";
3232

3333
public CleanroomVersionList(DownloadProvider downloadProvider) {
3434
this.downloadProvider = downloadProvider;

HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@ public Task<?> refreshAsync() {
9696
});
9797
}
9898

99-
public static final URI FORGE_LIST = URI.create("https://hmcl-dev.github.io/metadata/forge/");
99+
public static final URI FORGE_LIST = URI.create("https://hmcl.glavo.site/metadata/forge/");
100100
}

HMCLCore/src/main/java/org/jackhuang/hmcl/download/game/GameLibrariesTask.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void execute() throws IOException {
149149
Path file = libDir.resolve(fmlLib.name);
150150
if (shouldDownloadFMLLib(fmlLib, file)) {
151151
List<URI> uris = dependencyManager.getDownloadProvider()
152-
.injectURLWithCandidates(fmlLib.getDownloadURI());
152+
.injectURLWithCandidates(fmlLib.downloadUrl());
153153
dependencies.add(new FileDownloadTask(uris, file)
154154
.withCounter("hmcl.install.libraries"));
155155
}
@@ -193,9 +193,12 @@ public void execute() throws IOException {
193193
if (forgeVersion.startsWith("7.8.1.")) {
194194
return List.of(
195195
new FMLLib("argo-small-3.2.jar", "58912ea2858d168c50781f956fa5b59f0f7c6b51"),
196-
new FMLLib("guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a"),
197-
new FMLLib("asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58"),
198-
new FMLLib("bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65"),
196+
new FMLLib("guava-14.0-rc3.jar", "931ae21fa8014c3ce686aaa621eae565fefb1a6a",
197+
"https://repo1.maven.org/maven2/com/google/guava/guava/14.0-rc3/guava-14.0-rc3.jar"),
198+
new FMLLib("asm-all-4.1.jar", "054986e962b88d8660ae4566475658469595ef58",
199+
"https://repo1.maven.org/maven2/org/ow2/asm/asm-all/4.1/asm-all-4.1.jar"),
200+
new FMLLib("bcprov-jdk15on-148.jar", "960dea7c9181ba0b17e8bab0c06a43f0a5f04e65",
201+
"https://repo1.maven.org/maven2/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar"),
199202
new FMLLib("deobfuscation_data_1.5.2.zip", "446e55cd986582c70fcf12cb27bc00114c5adfd9"),
200203
new FMLLib("scala-library.jar", "458d046151ad179c85429ed7420ffb1eaf6ddf85")
201204
);
@@ -204,9 +207,9 @@ public void execute() throws IOException {
204207
return null;
205208
}
206209

207-
private record FMLLib(String name, String sha1) {
208-
public String getDownloadURI() {
209-
return "https://hmcl-dev.github.io/metadata/fmllibs/" + name;
210+
private record FMLLib(String name, String sha1, String downloadUrl) {
211+
FMLLib(String name, String sha1) {
212+
this(name, sha1, "https://hmcl.glavo.site/metadata/fmllibs/" + name);
210213
}
211214
}
212215
}

HMCLCore/src/main/java/org/jackhuang/hmcl/task/FetchTask.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,9 @@ private void downloadHttp(URI uri, boolean checkETag) throws DownloadException,
187187

188188
ArrayList<IOException> exceptions = null;
189189

190-
for (int retryTime = 0; retryTime < retry; retryTime++) {
190+
// If loading the cache fails, the cache should not be loaded again.
191+
boolean useCachedResult = true;
192+
for (int retryTime = 0, retryLimit = retry; retryTime < retryLimit; retryTime++) {
191193
if (isCancelled()) {
192194
throw new InterruptedException();
193195
}
@@ -204,7 +206,7 @@ private void downloadHttp(URI uri, boolean checkETag) throws DownloadException,
204206

205207
LinkedHashMap<String, String> headers = new LinkedHashMap<>();
206208
headers.put("accept-encoding", "gzip");
207-
if (checkETag)
209+
if (useCachedResult && checkETag)
208210
headers.putAll(repository.injectConnection(uri));
209211

210212
do {
@@ -248,7 +250,7 @@ private void downloadHttp(URI uri, boolean checkETag) throws DownloadException,
248250
} while (true);
249251

250252
int responseCode = response.statusCode();
251-
if (responseCode == HttpURLConnection.HTTP_NOT_MODIFIED) {
253+
if (useCachedResult && responseCode == HttpURLConnection.HTTP_NOT_MODIFIED) {
252254
// Handle cache
253255
try {
254256
Path cache = repository.getCachedRemoteFile(currentURI, false);
@@ -260,9 +262,10 @@ private void downloadHttp(URI uri, boolean checkETag) throws DownloadException,
260262
} catch (IOException e) {
261263
LOG.warning("Unable to use cached file, redownload " + NetworkUtils.dropQuery(uri), e);
262264
repository.removeRemoteEntry(currentURI);
265+
useCachedResult = false;
263266
// Now we must reconnect the server since 304 may result in empty content,
264267
// if we want to redownload the file, we must reconnect the server without etag settings.
265-
retryTime--;
268+
retryLimit++;
266269
continue;
267270
}
268271
} else if (responseCode / 100 == 4) {

0 commit comments

Comments
 (0)