Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加 unlisted-versions-of-minecraft #3247

Merged
merged 11 commits into from
Apr 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -292,6 +292,7 @@ private List<RemoteVersion> loadVersions() {
switch (it.getVersionType()) {
case RELEASE:
return chkRelease.isSelected();
case PENDING:
case SNAPSHOT:
return chkSnapshot.isSelected();
case OLD:
@@ -411,11 +412,10 @@ public void updateItem(RemoteVersion remoteVersion, boolean empty) {
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:
Original file line number Diff line number Diff line change
@@ -78,7 +78,8 @@ public BMCLAPIDownloadProvider(String apiRoot) {
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WTF 这俩镜像太地狱了

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

应该够用的,不行就去掉得了(

等下做一个 version_manifest 构建时拉取

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

你可以在这里将镜像更改为 hmcl://assets/unlisted-version-of-mc,并在 HttpRequest 中添加对 hmcl schema 的实现

);
}

Original file line number Diff line number Diff line change
@@ -127,6 +127,7 @@ public enum Type {
UNCATEGORIZED,
RELEASE,
SNAPSHOT,
OLD
OLD,
PENDING
}
}
Original file line number Diff line number Diff line change
@@ -68,6 +68,8 @@ private static Type getReleaseType(ReleaseType type) {
return Type.SNAPSHOT;
case UNKNOWN:
return Type.UNCATEGORIZED;
case PENDING:
return Type.PENDING;
default:
return Type.OLD;
}
Original file line number Diff line number Diff line change
@@ -19,12 +19,17 @@

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 @@ protected Collection<GameRemoteVersion> getVersionsImpl(String gameVersion) {
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(),
Original file line number Diff line number Diff line change
@@ -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;
Loading