mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-08-03 19:36:53 -04:00
Merge e8a4780055d8cb81ee1d54afb492c1c245d3d222 into 9969dc60c5278340b6b9a4d7facdde620e99d1f5
This commit is contained in:
commit
db83d6098a
@ -342,7 +342,7 @@ download.failed.no_code=Failed to download
|
||||
download.failed.refresh=Failed to fetch version list. Please click here to retry.
|
||||
download.game=New Game
|
||||
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)
|
||||
download.provider.mojang=Official (OptiFine is provided by BMCLAPI)
|
||||
download.provider.mojang=Official (OptiFine is provided by OF-302)
|
||||
download.provider.official=From Official Sources
|
||||
download.provider.balanced=From Fastest Available
|
||||
download.provider.mirror=From Mirror
|
||||
|
@ -343,7 +343,7 @@ download.failed.no_code=No se ha podido descargar
|
||||
download.failed.refresh=No se ha podido obtener la lista de versiones. Por favor, haga clic aquí para volver a intentarlo.
|
||||
download.game=Nuevo juego
|
||||
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)
|
||||
download.provider.mojang=Oficial (OptiFine es proporcionado por BMCLAPI)
|
||||
download.provider.mojang=Oficial (OptiFine es proporcionado por OF-302)
|
||||
download.provider.official=De fuentes oficiales
|
||||
download.provider.balanced=De la fuente más rápida disponible
|
||||
download.provider.mirror=Desde espejo
|
||||
|
@ -297,7 +297,7 @@ download.failed.empty=候補者なし。戻るにはここをクリックして
|
||||
download.failed.refresh=バージョンリストをダウンロードできません。ここをクリックして再試行してください。
|
||||
download.game=ゲームのダウンロード
|
||||
download.provider.bmclapi=BMCLAPI(ミラーソース)
|
||||
download.provider.mojang=Mojang(OptiFineはBMCLAPIにより提供されます) 推奨
|
||||
download.provider.mojang=Mojang(OptiFineはOF-302により提供されます) 推奨
|
||||
download.provider.official=公式ソースからロード
|
||||
download.provider.balanced=mcbbsのソースからロード
|
||||
download.provider.mirror=ミラーソースからロード
|
||||
|
@ -344,7 +344,7 @@ download.failed.no_code=Не удалось скачать
|
||||
download.failed.refresh=Не удалось получить список версий. Нажмите здесь, чтобы повторить попытку.
|
||||
download.game=Новая игра
|
||||
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)
|
||||
download.provider.mojang=Официальный (OptiFine предоставляется BMCLAPI)
|
||||
download.provider.mojang=Официальный (OptiFine предоставляется OF-302)
|
||||
download.provider.official=Из официальных источников
|
||||
download.provider.balanced=Из самых быстрых доступных
|
||||
download.provider.mirror=Из зеркала
|
||||
|
@ -344,7 +344,7 @@ download.failed.no_code=下載失敗
|
||||
download.failed.refresh=載入版本清單失敗,按一下此處重試。
|
||||
download.game=新遊戲
|
||||
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com/)
|
||||
download.provider.mojang=官方伺服器 (OptiFine 由 BMCLAPI 提供)
|
||||
download.provider.mojang=官方伺服器 (OptiFine 由 OF-302 提供)
|
||||
download.provider.official=盡量使用官方源 (最新,但可能載入慢)
|
||||
download.provider.balanced=選取載入速度快的下載源 (平衡,但可能不是最新)
|
||||
download.provider.mirror=盡量使用鏡像源 (載入快,但可能不是最新)
|
||||
|
@ -352,7 +352,7 @@ download.failed.no_code=下载失败
|
||||
download.failed.refresh=[加载版本列表失败,点击此处重试]\n(你可以点击右上角帮助按钮进行求助)
|
||||
download.game=新游戏
|
||||
download.provider.bmclapi=BMCLAPI (bangbang93, https://bmclapi2.bangbang93.com)
|
||||
download.provider.mojang=官方 (OptiFine 自动安装使用 BMCLAPI 下载源)
|
||||
download.provider.mojang=官方 (OptiFine 自动安装使用 OF-302 下载源)
|
||||
download.provider.official=尽量使用官方源 (最新,但可能加载慢)
|
||||
download.provider.balanced=选择加载速度快的下载源 (平衡,但可能不是最新)
|
||||
download.provider.mirror=尽量使用镜像源 (加载快,但可能不是最新)
|
||||
|
@ -23,7 +23,7 @@ import org.jackhuang.hmcl.download.forge.ForgeVersionList;
|
||||
import org.jackhuang.hmcl.download.game.GameVersionList;
|
||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList;
|
||||
import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList;
|
||||
import org.jackhuang.hmcl.download.optifine.OptiFineBMCLVersionList;
|
||||
import org.jackhuang.hmcl.download.optifine.OptiFine302VersionList;
|
||||
import org.jackhuang.hmcl.download.quilt.QuiltAPIVersionList;
|
||||
import org.jackhuang.hmcl.download.quilt.QuiltVersionList;
|
||||
|
||||
@ -38,7 +38,7 @@ public class MojangDownloadProvider implements DownloadProvider {
|
||||
private final ForgeVersionList forge;
|
||||
private final NeoForgeOfficialVersionList neoforge;
|
||||
private final LiteLoaderVersionList liteLoader;
|
||||
private final OptiFineBMCLVersionList optifine;
|
||||
private final OptiFine302VersionList optifine;
|
||||
private final QuiltVersionList quilt;
|
||||
private final QuiltAPIVersionList quiltApi;
|
||||
|
||||
@ -52,7 +52,7 @@ public class MojangDownloadProvider implements DownloadProvider {
|
||||
this.forge = new ForgeVersionList(this);
|
||||
this.neoforge = new NeoForgeOfficialVersionList(this);
|
||||
this.liteLoader = new LiteLoaderVersionList(this);
|
||||
this.optifine = new OptiFineBMCLVersionList(apiRoot);
|
||||
this.optifine = new OptiFine302VersionList("https://hmcl-dev.github.io/metadata/optifine/");
|
||||
this.quilt = new QuiltVersionList(this);
|
||||
this.quiltApi = new QuiltAPIVersionList(this);
|
||||
}
|
||||
|
@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Hello Minecraft! Launcher
|
||||
* Copyright (C) 2020 huangyuhui <huanghongxun2008@126.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.jackhuang.hmcl.download.optifine;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.jackhuang.hmcl.download.VersionList;
|
||||
import org.jackhuang.hmcl.util.io.HttpRequest;
|
||||
import org.jackhuang.hmcl.util.versioning.VersionNumber;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author huangyuhui
|
||||
*/
|
||||
public final class OptiFine302VersionList extends VersionList<OptiFineRemoteVersion> {
|
||||
private final String versionListURL;
|
||||
|
||||
public OptiFine302VersionList(String versionListURL) {
|
||||
this.versionListURL = versionListURL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasType() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletableFuture<?> refreshAsync() {
|
||||
return HttpRequest.GET(versionListURL).getJsonAsync(TypeToken.get(OptiFine302VersionList.VersionList.class)).thenAcceptAsync(root -> {
|
||||
lock.writeLock().lock();
|
||||
|
||||
try {
|
||||
versions.clear();
|
||||
for (OptiFineVersion element : root.versions) {
|
||||
String gameVersion = VersionNumber.normalize(element.gameVersion);
|
||||
versions.put(gameVersion, new OptiFineRemoteVersion(
|
||||
gameVersion, element.version,
|
||||
root.downloadBases.stream().map(u -> u + element.fileName).collect(Collectors.toList()),
|
||||
element.fileName.startsWith("pre")
|
||||
));
|
||||
}
|
||||
} finally {
|
||||
lock.writeLock().unlock();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static final class VersionList {
|
||||
@SerializedName("file")
|
||||
private final List<OptiFineVersion> versions;
|
||||
|
||||
@SerializedName("download")
|
||||
private final List<String> downloadBases;
|
||||
|
||||
public VersionList(List<OptiFineVersion> versions, List<String> downloadBases) {
|
||||
this.versions = versions;
|
||||
this.downloadBases = downloadBases;
|
||||
}
|
||||
}
|
||||
|
||||
private static final class OptiFineVersion {
|
||||
@SerializedName("name")
|
||||
private final String version;
|
||||
@SerializedName("filename")
|
||||
private final String fileName;
|
||||
@SerializedName("mcversion")
|
||||
private final String gameVersion;
|
||||
|
||||
public OptiFineVersion(String version, String fileName, String gameVersion) {
|
||||
this.version = version;
|
||||
this.fileName = fileName;
|
||||
this.gameVersion = gameVersion;
|
||||
}
|
||||
}
|
||||
}
|
@ -80,17 +80,17 @@ public final class OptiFineBMCLVersionList extends VersionList<OptiFineRemoteVer
|
||||
versions.clear();
|
||||
Set<String> duplicates = new HashSet<>();
|
||||
for (OptiFineVersion element : root) {
|
||||
String version = element.getType() + "_" + element.getPatch();
|
||||
String mirror = "https://bmclapi2.bangbang93.com/optifine/" + toLookupVersion(element.getGameVersion()) + "/" + element.getType() + "/" + element.getPatch();
|
||||
String version = element.type + "_" + element.patch;
|
||||
String mirror = apiRoot + "/optifine/" + toLookupVersion(element.gameVersion) + "/" + element.type + "/" + element.patch;
|
||||
if (!duplicates.add(mirror))
|
||||
continue;
|
||||
|
||||
boolean isPre = element.getPatch() != null && (element.getPatch().startsWith("pre") || element.getPatch().startsWith("alpha"));
|
||||
boolean isPre = element.patch != null && (element.patch.startsWith("pre") || element.patch.startsWith("alpha"));
|
||||
|
||||
if (StringUtils.isBlank(element.getGameVersion()))
|
||||
if (StringUtils.isBlank(element.gameVersion))
|
||||
continue;
|
||||
|
||||
String gameVersion = VersionNumber.normalize(fromLookupVersion(element.getGameVersion()));
|
||||
String gameVersion = VersionNumber.normalize(fromLookupVersion(element.gameVersion));
|
||||
versions.put(gameVersion, new OptiFineRemoteVersion(gameVersion, version, Collections.singletonList(mirror), isPre));
|
||||
}
|
||||
} finally {
|
||||
@ -103,68 +103,19 @@ public final class OptiFineBMCLVersionList extends VersionList<OptiFineRemoteVer
|
||||
* @author huangyuhui
|
||||
*/
|
||||
private static final class OptiFineVersion {
|
||||
|
||||
@SerializedName("dl")
|
||||
private final String downloadLink;
|
||||
|
||||
@SerializedName("ver")
|
||||
private final String version;
|
||||
|
||||
@SerializedName("date")
|
||||
private final String date;
|
||||
|
||||
@SerializedName("type")
|
||||
private final String type;
|
||||
|
||||
@SerializedName("patch")
|
||||
private final String patch;
|
||||
|
||||
@SerializedName("mirror")
|
||||
private final String mirror;
|
||||
|
||||
@SerializedName("mcversion")
|
||||
private final String gameVersion;
|
||||
|
||||
public OptiFineVersion() {
|
||||
this(null, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
public OptiFineVersion(String downloadLink, String version, String date, String type, String patch, String mirror, String gameVersion) {
|
||||
this.downloadLink = downloadLink;
|
||||
this.version = version;
|
||||
this.date = date;
|
||||
public OptiFineVersion(String type, String patch, String gameVersion) {
|
||||
this.type = type;
|
||||
this.patch = patch;
|
||||
this.mirror = mirror;
|
||||
this.gameVersion = gameVersion;
|
||||
}
|
||||
|
||||
public String getDownloadLink() {
|
||||
return downloadLink;
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public String getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public String getPatch() {
|
||||
return patch;
|
||||
}
|
||||
|
||||
public String getMirror() {
|
||||
return mirror;
|
||||
}
|
||||
|
||||
public String getGameVersion() {
|
||||
return gameVersion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user