mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-03 19:36:53 -04:00
支持 Forge 官方源 (#3259)
* Revert "Revert "支持 Forge 官方源 (#3251)" (#3258)" This reverts commit abd37a093ac04cdda61196e1fdf1b1a23a8b1dad. * Update ForgeVersionList.java
This commit is contained in:
parent
abd37a093a
commit
fd97f6c321
@ -19,7 +19,7 @@ package org.jackhuang.hmcl.download;
|
|||||||
|
|
||||||
import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList;
|
import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList;
|
||||||
import org.jackhuang.hmcl.download.fabric.FabricVersionList;
|
import org.jackhuang.hmcl.download.fabric.FabricVersionList;
|
||||||
import org.jackhuang.hmcl.download.forge.ForgeBMCLVersionList;
|
import org.jackhuang.hmcl.download.forge.ForgeVersionList;
|
||||||
import org.jackhuang.hmcl.download.game.GameVersionList;
|
import org.jackhuang.hmcl.download.game.GameVersionList;
|
||||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList;
|
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList;
|
||||||
import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList;
|
import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList;
|
||||||
@ -35,7 +35,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;
|
||||||
@ -49,7 +49,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);
|
||||||
|
@ -43,9 +43,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();
|
||||||
|
|
||||||
@ -55,7 +63,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)
|
||||||
@ -72,7 +80,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)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -82,5 +90,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://hmcl-dev.github.io/metadata/forge/";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user