mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-04 03:46:57 -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()) {
|
switch (it.getVersionType()) {
|
||||||
case RELEASE:
|
case RELEASE:
|
||||||
return chkRelease.isSelected();
|
return chkRelease.isSelected();
|
||||||
|
case PENDING:
|
||||||
case SNAPSHOT:
|
case SNAPSHOT:
|
||||||
return chkSnapshot.isSelected();
|
return chkSnapshot.isSelected();
|
||||||
case OLD:
|
case OLD:
|
||||||
@ -411,11 +412,10 @@ public final class VersionsPage extends BorderPane implements WizardPage, Refres
|
|||||||
content.setImage(VersionIconType.GRASS.getIcon());
|
content.setImage(VersionIconType.GRASS.getIcon());
|
||||||
content.setExternalLink(i18n("wiki.version.game.release", remoteVersion.getGameVersion()));
|
content.setExternalLink(i18n("wiki.version.game.release", remoteVersion.getGameVersion()));
|
||||||
break;
|
break;
|
||||||
|
case PENDING:
|
||||||
case SNAPSHOT:
|
case SNAPSHOT:
|
||||||
content.getTags().setAll(i18n("version.game.snapshot"));
|
content.getTags().setAll(i18n("version.game.snapshot"));
|
||||||
content.setImage(VersionIconType.COMMAND.getIcon());
|
content.setImage(VersionIconType.COMMAND.getIcon());
|
||||||
|
|
||||||
|
|
||||||
content.setExternalLink(i18n("wiki.version.game.snapshot", remoteVersion.getGameVersion()));
|
content.setExternalLink(i18n("wiki.version.game.snapshot", remoteVersion.getGameVersion()));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -78,7 +78,8 @@ public final class BMCLAPIDownloadProvider implements DownloadProvider {
|
|||||||
pair("https://meta.fabricmc.net", apiRoot + "/fabric-meta"),
|
pair("https://meta.fabricmc.net", apiRoot + "/fabric-meta"),
|
||||||
pair("https://maven.fabricmc.net", apiRoot + "/maven"),
|
pair("https://maven.fabricmc.net", apiRoot + "/maven"),
|
||||||
pair("https://authlib-injector.yushi.moe", apiRoot + "/mirrors/authlib-injector"),
|
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,
|
UNCATEGORIZED,
|
||||||
RELEASE,
|
RELEASE,
|
||||||
SNAPSHOT,
|
SNAPSHOT,
|
||||||
OLD
|
OLD,
|
||||||
|
PENDING
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,6 +68,8 @@ public final class GameRemoteVersion extends RemoteVersion {
|
|||||||
return Type.SNAPSHOT;
|
return Type.SNAPSHOT;
|
||||||
case UNKNOWN:
|
case UNKNOWN:
|
||||||
return Type.UNCATEGORIZED;
|
return Type.UNCATEGORIZED;
|
||||||
|
case PENDING:
|
||||||
|
return Type.PENDING;
|
||||||
default:
|
default:
|
||||||
return Type.OLD;
|
return Type.OLD;
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,17 @@ package org.jackhuang.hmcl.download.game;
|
|||||||
|
|
||||||
import org.jackhuang.hmcl.download.DownloadProvider;
|
import org.jackhuang.hmcl.download.DownloadProvider;
|
||||||
import org.jackhuang.hmcl.download.VersionList;
|
import org.jackhuang.hmcl.download.VersionList;
|
||||||
|
import org.jackhuang.hmcl.util.gson.JsonUtils;
|
||||||
import org.jackhuang.hmcl.util.io.HttpRequest;
|
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||||
|
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.Reader;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
import static org.jackhuang.hmcl.util.logging.Logger.LOG;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author huangyuhui
|
* @author huangyuhui
|
||||||
@ -50,10 +55,30 @@ public final class GameVersionList extends VersionList<GameRemoteVersion> {
|
|||||||
public CompletableFuture<?> refreshAsync() {
|
public CompletableFuture<?> refreshAsync() {
|
||||||
return HttpRequest.GET(downloadProvider.getVersionListURL()).getJsonAsync(GameRemoteVersions.class)
|
return HttpRequest.GET(downloadProvider.getVersionListURL()).getJsonAsync(GameRemoteVersions.class)
|
||||||
.thenAcceptAsync(root -> {
|
.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();
|
lock.writeLock().lock();
|
||||||
try {
|
try {
|
||||||
versions.clear();
|
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()) {
|
for (GameRemoteVersionInfo remoteVersion : root.getVersions()) {
|
||||||
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
|
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
|
||||||
remoteVersion.getGameVersion(),
|
remoteVersion.getGameVersion(),
|
||||||
|
@ -27,6 +27,7 @@ public enum ReleaseType {
|
|||||||
MODIFIED("modified"),
|
MODIFIED("modified"),
|
||||||
OLD_BETA("old-beta"),
|
OLD_BETA("old-beta"),
|
||||||
OLD_ALPHA("old-alpha"),
|
OLD_ALPHA("old-alpha"),
|
||||||
|
PENDING("pending"),
|
||||||
UNKNOWN("unknown");
|
UNKNOWN("unknown");
|
||||||
|
|
||||||
private final String id;
|
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