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 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
添加 unlisted-versions-of-minecraft
  • Loading branch information
zkitefly committed Aug 19, 2024
commit deb21c12eaf981c285cb7fb7147b714d3d2e3dba
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 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 getUvmcListURL() {
return getPreferredDownloadProvider().getUvmcListURL();
}

@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 getUvmcListURL() {
return versionListProvider.getUvmcListURL();
}

@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://gitee.com/bleaker/unlisted-versions-of-minecraft/raw/main")
);
}

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

@Override
public String getUvmcListURL() {
return "https://gitee.com/bleaker/unlisted-versions-of-minecraft/raw/main/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 getUvmcListURL() {
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 getUvmcListURL();

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 getUvmcListURL() {
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
}
}
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> uvmcFuture = HttpRequest.GET(downloadProvider.getUvmcListURL())
.getJsonAsync(GameRemoteVersions.class);

return CompletableFuture.allOf(primaryFuture, uvmcFuture)
.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(), uvmcFuture.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