尝试从候选源获取 AuthlibInjectorVersionInfo (#2711)

* 尝试从候选源获取 AuthlibInjectorVersionInfo

* update

* update

* update
This commit is contained in:
Glavo 2024-01-31 01:56:06 +08:00 committed by GitHub
parent 0bcda9eb46
commit 19cae84a01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -110,11 +110,22 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide
}
private AuthlibInjectorVersionInfo getLatestArtifactInfo() throws IOException {
try {
return HttpRequest.GET(downloadProvider.get().injectURL(LATEST_BUILD_URL)).getJson(AuthlibInjectorVersionInfo.class);
} catch (JsonParseException e) {
throw new IOException("Malformed response", e);
IOException exception = null;
for (URL url : downloadProvider.get().injectURLWithCandidates(LATEST_BUILD_URL)) {
try {
return HttpRequest.GET(url.toExternalForm()).getJson(AuthlibInjectorVersionInfo.class);
} catch (IOException | JsonParseException e) {
if (exception == null) {
exception = new IOException("Failed to fetch authlib-injector artifact info");
}
exception.addSuppressed(e);
}
}
if (exception == null) {
exception = new IOException("No authlib-injector download providers available");
}
throw exception;
}
private Optional<AuthlibInjectorArtifactInfo> getLocalArtifact() {
@ -133,7 +144,7 @@ public class AuthlibInjectorDownloader implements AuthlibInjectorArtifactProvide
}
}
private static class AuthlibInjectorVersionInfo {
private static final class AuthlibInjectorVersionInfo {
@SerializedName("build_number")
public int buildNumber;