mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-03 19:36:53 -04:00
添加 unlisted-versions-of-minecraft (#3247)
* 添加 unlisted-versions-of-minecraft * Update BMCLAPIDownloadProvider.java * Update VersionsPage.java * Update VersionsPage.java * Update BMCLAPIDownloadProvider.java * update name * update * update * update * update --------- Co-authored-by: Glavo <zjx001202@gmail.com>
This commit is contained in:
parent
fd51fb7d26
commit
78b043c19c
@ -292,6 +292,7 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
||||
switch (it.getVersionType()) {
|
||||
case RELEASE:
|
||||
return chkRelease.isSelected();
|
||||
case PENDING:
|
||||
case SNAPSHOT:
|
||||
return chkSnapshot.isSelected();
|
||||
case OLD:
|
||||
@ -411,11 +412,10 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
||||
content.setImage(VersionIconType.GRASS.getIcon());
|
||||
content.setExternalLink(i18n("wiki.version.game.release", remoteVersion.getGameVersion()));
|
||||
break;
|
||||
case PENDING:
|
||||
case SNAPSHOT:
|
||||
content.getTags().setAll(i18n("version.game.snapshot"));
|
||||
content.setImage(VersionIconType.COMMAND.getIcon());
|
||||
|
||||
|
||||
content.setExternalLink(i18n("wiki.version.game.snapshot", remoteVersion.getGameVersion()));
|
||||
break;
|
||||
default:
|
||||
|
@ -78,7 +78,8 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
|
||||
pair("https://meta.fabricmc.net", apiRoot + "/fabric-meta"),
|
||||
pair("https://maven.fabricmc.net", apiRoot + "/maven"),
|
||||
pair("https://authlib-injector.yushi.moe", apiRoot + "/mirrors/authlib-injector"),
|
||||
pair("https://repo1.maven.org/maven2", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public")
|
||||
pair("https://repo1.maven.org/maven2", "https://mirrors.cloud.tencent.com/nexus/repository/maven-public"),
|
||||
pair("https://zkitefly.github.io/unlisted-versions-of-minecraft", "https://vip.123pan.cn/1821946486/unlisted-versions-of-minecraft")
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -127,6 +127,7 @@ public class RemoteVersion implements Comparable<RemoteVersion> {
|
||||
UNCATEGORIZED,
|
||||
RELEASE,
|
||||
SNAPSHOT,
|
||||
OLD
|
||||
OLD,
|
||||
PENDING
|
||||
}
|
||||
}
|
||||
|
@ -68,6 +68,8 @@ public final class GameRemoteVersion extends RemoteVersion {
|
||||
return Type.SNAPSHOT;
|
||||
case UNKNOWN:
|
||||
return Type.UNCATEGORIZED;
|
||||
case PENDING:
|
||||
return Type.PENDING;
|
||||
default:
|
||||
return Type.OLD;
|
||||
}
|
||||
|
@ -19,12 +19,17 @@ package org.jackhuang.hmcl.download.game;
|
||||
|
||||
import org.jackhuang.hmcl.download.DownloadProvider;
|
||||
import org.jackhuang.hmcl.download.VersionList;
|
||||
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author huangyuhui
|
||||
@ -50,10 +55,30 @@ public final class GameVersionList extends VersionList<GameRemoteVersion> {
|
||||
public CompletableFuture<?> refreshAsync() {
|
||||
return HttpRequest.GET(downloadProvider.getVersionListURL()).getJsonAsync(GameRemoteVersions.class)
|
||||
.thenAcceptAsync(root -> {
|
||||
GameRemoteVersions unlistedVersions = null;
|
||||
|
||||
//noinspection DataFlowIssue
|
||||
try (Reader input = new InputStreamReader(
|
||||
GameVersionList.class.getResourceAsStream("/assets/game/unlisted-versions.json"))) {
|
||||
unlistedVersions = JsonUtils.GSON.fromJson(input, GameRemoteVersions.class);
|
||||
} catch (Throwable e) {
|
||||
LOG.error("Failed to load unlisted versions", e);
|
||||
}
|
||||
|
||||
lock.writeLock().lock();
|
||||
try {
|
||||
versions.clear();
|
||||
|
||||
if (unlistedVersions != null) {
|
||||
for (GameRemoteVersionInfo unlistedVersion : unlistedVersions.getVersions()) {
|
||||
versions.put(unlistedVersion.getGameVersion(), new GameRemoteVersion(
|
||||
unlistedVersion.getGameVersion(),
|
||||
unlistedVersion.getGameVersion(),
|
||||
Collections.singletonList(unlistedVersion.getUrl()),
|
||||
unlistedVersion.getType(), unlistedVersion.getReleaseTime()));
|
||||
}
|
||||
}
|
||||
|
||||
for (GameRemoteVersionInfo remoteVersion : root.getVersions()) {
|
||||
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
|
||||
remoteVersion.getGameVersion(),
|
||||
|
@ -27,6 +27,7 @@ public enum ReleaseType {
|
||||
MODIFIED("modified"),
|
||||
OLD_BETA("old-beta"),
|
||||
OLD_ALPHA("old-alpha"),
|
||||
PENDING("pending"),
|
||||
UNKNOWN("unknown");
|
||||
|
||||
private final String id;
|
||||
|
1362
HMCLCore/src/main/resources/assets/game/unlisted-versions.json
Normal file
1362
HMCLCore/src/main/resources/assets/game/unlisted-versions.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user