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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Expand Up @@ -196,6 +196,7 @@ private List<RemoteVersion> loadVersions() {
switch (it.getVersionType()) {
case RELEASE:
return chkRelease.isSelected();
case PENDING:
case SNAPSHOT:
return chkSnapshot.isSelected();
case OLD:
Expand Down Expand Up @@ -308,6 +309,7 @@ public void updateItem(RemoteVersion remoteVersion, boolean empty) {
content.getTags().setAll(i18n("version.game.release"));
content.setImage(VersionIconType.GRASS.getIcon());
break;
case PENDING:
case SNAPSHOT:
content.getTags().setAll(i18n("version.game.snapshot"));
content.setImage(VersionIconType.COMMAND.getIcon());
Expand All @@ -317,6 +319,9 @@ public void updateItem(RemoteVersion remoteVersion, boolean empty) {
content.setImage(VersionIconType.CRAFT_TABLE.getIcon());
break;
}
if (remoteVersion.getUrls().stream().anyMatch(url -> url.contains("unlisted-versions-of-minecraft"))) {
content.getTags().add("Unlisted Minecraft");
}
} else {
VersionIconType iconType;
if (remoteVersion instanceof LiteLoaderRemoteVersion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public String getVersionListURL() {
return getPreferredDownloadProvider().getVersionListURL();
}

@Override
public String getUnlistedMinecraftURL() {
return getPreferredDownloadProvider().getUnlistedMinecraftURL();
}

@Override
public String getAssetBaseURL() {
return getPreferredDownloadProvider().getAssetBaseURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public String getVersionListURL() {
return versionListProvider.getVersionListURL();
}

@Override
public String getUnlistedMinecraftURL() {
return versionListProvider.getUnlistedMinecraftURL();
}

@Override
public String getAssetBaseURL() {
return fileProvider.getAssetBaseURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,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 的实现

);
}

Expand All @@ -90,6 +91,11 @@ public String getVersionListURL() {
return apiRoot + "/mc/game/version_manifest.json";
}

@Override
public String getUnlistedMinecraftURL() {
return "https://vip.123pan.cn/1821946486/unlisted-versions-of-minecraft/version_manifest.json";
}

@Override
public String getAssetBaseURL() {
return apiRoot + "/assets/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ public String getVersionListURL() {
throw new UnsupportedOperationException();
}

@Override
public String getUnlistedMinecraftURL() {
throw new UnsupportedOperationException();
}

@Override
public String getAssetBaseURL() {
throw new UnsupportedOperationException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public interface DownloadProvider {

String getVersionListURL();

String getUnlistedMinecraftURL();

String getAssetBaseURL();

default List<URL> getAssetObjectCandidates(String assetObjectLocation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public String getVersionListURL() {
return "https://piston-meta.mojang.com/mc/game/version_manifest.json";
}

@Override
public String getUnlistedMinecraftURL() {
return "https://zkitefly.github.io/unlisted-versions-of-minecraft/version_manifest.json";
}

@Override
public String getAssetBaseURL() {
return "https://resources.download.minecraft.net/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ public enum Type {
UNCATEGORIZED,
RELEASE,
SNAPSHOT,
OLD
OLD,
PENDING
Copy link
Member

Choose a reason for hiding this comment

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

使用 PENDING 类型的意义是什么?在其他地方代码和 SNAPSHOT 类型似乎完全是一致的?还是只是我没发现

Copy link
Member Author

@zkitefly zkitefly Jan 27, 2025

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

我的意思是,你同时在 ReleaseType 和 RemoteVersion.Type 中声明了新的类型 PENDING,但这一类型和 SNAPSHOT 类型完全一致。这么做的意义是什么?

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Stream;

/**
*
Expand All @@ -48,19 +49,30 @@ protected Collection<GameRemoteVersion> getVersionsImpl(String gameVersion) {

@Override
public CompletableFuture<?> refreshAsync() {
return HttpRequest.GET(downloadProvider.getVersionListURL()).getJsonAsync(GameRemoteVersions.class)
.thenAcceptAsync(root -> {
CompletableFuture<GameRemoteVersions> primaryFuture = HttpRequest.GET(downloadProvider.getVersionListURL())
.getJsonAsync(GameRemoteVersions.class);

CompletableFuture<GameRemoteVersions> unlistedMinecraftFuture = HttpRequest.GET(downloadProvider.getUnlistedMinecraftURL())
.getJsonAsync(GameRemoteVersions.class);

return CompletableFuture.allOf(primaryFuture, unlistedMinecraftFuture)
.thenAcceptAsync(ignored -> {
lock.writeLock().lock();
try {
versions.clear();

for (GameRemoteVersionInfo remoteVersion : root.getVersions()) {
versions.put(remoteVersion.getGameVersion(), new GameRemoteVersion(
remoteVersion.getGameVersion(),
remoteVersion.getGameVersion(),
Collections.singletonList(remoteVersion.getUrl()),
remoteVersion.getType(), remoteVersion.getReleaseTime()));
}
Stream.of(primaryFuture.join(), unlistedMinecraftFuture.join())
.flatMap(gameRemoteVersions -> gameRemoteVersions.getVersions().stream())
.forEach(remoteVersion -> versions.put(
remoteVersion.getGameVersion(),
new GameRemoteVersion(
remoteVersion.getGameVersion(),
remoteVersion.getGameVersion(),
Collections.singletonList(remoteVersion.getUrl()),
remoteVersion.getType(),
remoteVersion.getReleaseTime()
)
));
} finally {
lock.writeLock().unlock();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading