添加 Forge 官方源

This commit is contained in:
Zkitefly 2024-08-23 00:09:57 +00:00
parent d507998e79
commit e6100ac032
2 changed files with 16 additions and 8 deletions

View File

@ -19,7 +19,7 @@ package com.tungsten.fclcore.download;
import com.tungsten.fclcore.download.fabric.FabricAPIVersionList; import com.tungsten.fclcore.download.fabric.FabricAPIVersionList;
import com.tungsten.fclcore.download.fabric.FabricVersionList; import com.tungsten.fclcore.download.fabric.FabricVersionList;
import com.tungsten.fclcore.download.forge.ForgeBMCLVersionList; import com.tungsten.fclcore.download.forge.ForgeVersionList;
import com.tungsten.fclcore.download.game.GameVersionList; import com.tungsten.fclcore.download.game.GameVersionList;
import com.tungsten.fclcore.download.liteloader.LiteLoaderVersionList; import com.tungsten.fclcore.download.liteloader.LiteLoaderVersionList;
import com.tungsten.fclcore.download.neoforge.NeoForgeOfficialVersionList; import com.tungsten.fclcore.download.neoforge.NeoForgeOfficialVersionList;
@ -34,7 +34,7 @@ public class MojangDownloadProvider implements DownloadProvider {
private final GameVersionList game; private final GameVersionList game;
private final FabricVersionList fabric; private final FabricVersionList fabric;
private final FabricAPIVersionList fabricApi; private final FabricAPIVersionList fabricApi;
private final ForgeBMCLVersionList forge; private final ForgeVersionList forge;
private final NeoForgeOfficialVersionList neoforge; private final NeoForgeOfficialVersionList neoforge;
private final LiteLoaderVersionList liteLoader; private final LiteLoaderVersionList liteLoader;
private final OptiFineBMCLVersionList optifine; private final OptiFineBMCLVersionList optifine;
@ -47,7 +47,7 @@ public class MojangDownloadProvider implements DownloadProvider {
this.game = new GameVersionList(this); this.game = new GameVersionList(this);
this.fabric = new FabricVersionList(this); this.fabric = new FabricVersionList(this);
this.fabricApi = new FabricAPIVersionList(this); this.fabricApi = new FabricAPIVersionList(this);
this.forge = new ForgeBMCLVersionList(apiRoot); this.forge = new ForgeVersionList(this);
this.neoforge = new NeoForgeOfficialVersionList(this); this.neoforge = new NeoForgeOfficialVersionList(this);
this.liteLoader = new LiteLoaderVersionList(this); this.liteLoader = new LiteLoaderVersionList(this);
this.optifine = new OptiFineBMCLVersionList(apiRoot); this.optifine = new OptiFineBMCLVersionList(apiRoot);

View File

@ -39,9 +39,17 @@ public final class ForgeVersionList extends VersionList<ForgeRemoteVersion> {
return false; return false;
} }
private static String toLookupVersion(String gameVersion) {
return "1.7.10-pre4".equals(gameVersion) ? "1.7.10_pre4" : gameVersion;
}
private static String fromLookupVersion(String lookupVersion) {
return "1.7.10_pre4".equals(lookupVersion) ? "1.7.10-pre4" : lookupVersion;
}
@Override @Override
public CompletableFuture<?> refreshAsync() { public CompletableFuture<?> refreshAsync() {
return HttpRequest.GET(downloadProvider.injectURL(FORGE_LIST)).getJsonAsync(ForgeVersionRoot.class) return HttpRequest.GET(FORGE_LIST).getJsonAsync(ForgeVersionRoot.class)
.thenAcceptAsync(root -> { .thenAcceptAsync(root -> {
lock.writeLock().lock(); lock.writeLock().lock();
@ -51,7 +59,7 @@ public final class ForgeVersionList extends VersionList<ForgeRemoteVersion> {
versions.clear(); versions.clear();
for (Map.Entry<String, int[]> entry : root.getGameVersions().entrySet()) { for (Map.Entry<String, int[]> entry : root.getGameVersions().entrySet()) {
String gameVersion = VersionNumber.normalize(entry.getKey()); String gameVersion = fromLookupVersion(VersionNumber.normalize(entry.getKey()));
for (int v : entry.getValue()) { for (int v : entry.getValue()) {
ForgeVersion version = root.getNumber().get(v); ForgeVersion version = root.getNumber().get(v);
if (version == null) if (version == null)
@ -68,7 +76,7 @@ public final class ForgeVersionList extends VersionList<ForgeRemoteVersion> {
if (jar == null) if (jar == null)
continue; continue;
versions.put(gameVersion, new ForgeRemoteVersion( versions.put(gameVersion, new ForgeRemoteVersion(
version.getGameVersion(), version.getVersion(), null, Collections.singletonList(jar) toLookupVersion(version.getGameVersion()), version.getVersion(), null, Collections.singletonList(jar)
)); ));
} }
} }
@ -78,5 +86,5 @@ public final class ForgeVersionList extends VersionList<ForgeRemoteVersion> {
}); });
} }
public static final String FORGE_LIST = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/json"; public static final String FORGE_LIST = "https://zkitefly.github.io/forge-maven-metadata/list.json";
} }