From 0f0cf555090f2518103a9a6b833071ab677ca4c0 Mon Sep 17 00:00:00 2001 From: Zkitefly <2573874409@qq.com> Date: Sat, 24 Aug 2024 03:32:45 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E6=94=AF=E6=8C=81=20Forge=20=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=BA=90=20(#3251)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 支持 Forge 官方源 * 更新 ForgeVersionList.java * 更新 ForgeVersionList.java --- .../hmcl/download/MojangDownloadProvider.java | 6 +++--- .../hmcl/download/forge/ForgeVersionList.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java index a0a677f250..86fc3e032f 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java @@ -19,7 +19,7 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList; 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.liteloader.LiteLoaderVersionList; import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList; @@ -35,7 +35,7 @@ public class MojangDownloadProvider implements DownloadProvider { private final GameVersionList game; private final FabricVersionList fabric; private final FabricAPIVersionList fabricApi; - private final ForgeBMCLVersionList forge; + private final ForgeVersionList forge; private final NeoForgeOfficialVersionList neoforge; private final LiteLoaderVersionList liteLoader; private final OptiFineBMCLVersionList optifine; @@ -49,7 +49,7 @@ public MojangDownloadProvider() { this.game = new GameVersionList(this); this.fabric = new FabricVersionList(this); this.fabricApi = new FabricAPIVersionList(this); - this.forge = new ForgeBMCLVersionList(apiRoot); + this.forge = new ForgeVersionList(this); this.neoforge = new NeoForgeOfficialVersionList(this); this.liteLoader = new LiteLoaderVersionList(this); this.optifine = new OptiFineBMCLVersionList(apiRoot); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java index fa9a558133..e450a70c13 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java @@ -43,9 +43,17 @@ public boolean hasType() { 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 public CompletableFuture refreshAsync() { - return HttpRequest.GET(downloadProvider.injectURL(FORGE_LIST)).getJsonAsync(ForgeVersionRoot.class) + return HttpRequest.GET(FORGE_LIST).getJsonAsync(ForgeVersionRoot.class) .thenAcceptAsync(root -> { lock.writeLock().lock(); @@ -55,7 +63,7 @@ public CompletableFuture refreshAsync() { versions.clear(); for (Map.Entry entry : root.getGameVersions().entrySet()) { - String gameVersion = VersionNumber.normalize(entry.getKey()); + String gameVersion = fromLookupVersion(VersionNumber.normalize(entry.getKey())); for (int v : entry.getValue()) { ForgeVersion version = root.getNumber().get(v); if (version == null) @@ -72,7 +80,7 @@ public CompletableFuture refreshAsync() { if (jar == null) continue; 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 CompletableFuture refreshAsync() { }); } - 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"; } From abd37a093ac04cdda61196e1fdf1b1a23a8b1dad Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 24 Aug 2024 14:50:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?Revert=20"=E6=94=AF=E6=8C=81=20Forge=20?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E6=BA=90=20(#3251)"=20(#3258)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0f0cf555090f2518103a9a6b833071ab677ca4c0. --- .../hmcl/download/MojangDownloadProvider.java | 6 +++--- .../hmcl/download/forge/ForgeVersionList.java | 16 ++++------------ 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java index 86fc3e032f..a0a677f250 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java @@ -19,7 +19,7 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList; import org.jackhuang.hmcl.download.fabric.FabricVersionList; -import org.jackhuang.hmcl.download.forge.ForgeVersionList; +import org.jackhuang.hmcl.download.forge.ForgeBMCLVersionList; import org.jackhuang.hmcl.download.game.GameVersionList; import org.jackhuang.hmcl.download.liteloader.LiteLoaderVersionList; import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList; @@ -35,7 +35,7 @@ public class MojangDownloadProvider implements DownloadProvider { private final GameVersionList game; private final FabricVersionList fabric; private final FabricAPIVersionList fabricApi; - private final ForgeVersionList forge; + private final ForgeBMCLVersionList forge; private final NeoForgeOfficialVersionList neoforge; private final LiteLoaderVersionList liteLoader; private final OptiFineBMCLVersionList optifine; @@ -49,7 +49,7 @@ public MojangDownloadProvider() { this.game = new GameVersionList(this); this.fabric = new FabricVersionList(this); this.fabricApi = new FabricAPIVersionList(this); - this.forge = new ForgeVersionList(this); + this.forge = new ForgeBMCLVersionList(apiRoot); this.neoforge = new NeoForgeOfficialVersionList(this); this.liteLoader = new LiteLoaderVersionList(this); this.optifine = new OptiFineBMCLVersionList(apiRoot); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java index e450a70c13..fa9a558133 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java @@ -43,17 +43,9 @@ public boolean hasType() { 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 public CompletableFuture refreshAsync() { - return HttpRequest.GET(FORGE_LIST).getJsonAsync(ForgeVersionRoot.class) + return HttpRequest.GET(downloadProvider.injectURL(FORGE_LIST)).getJsonAsync(ForgeVersionRoot.class) .thenAcceptAsync(root -> { lock.writeLock().lock(); @@ -63,7 +55,7 @@ public CompletableFuture refreshAsync() { versions.clear(); for (Map.Entry entry : root.getGameVersions().entrySet()) { - String gameVersion = fromLookupVersion(VersionNumber.normalize(entry.getKey())); + String gameVersion = VersionNumber.normalize(entry.getKey()); for (int v : entry.getValue()) { ForgeVersion version = root.getNumber().get(v); if (version == null) @@ -80,7 +72,7 @@ public CompletableFuture refreshAsync() { if (jar == null) continue; versions.put(gameVersion, new ForgeRemoteVersion( - toLookupVersion(version.getGameVersion()), version.getVersion(), null, Collections.singletonList(jar) + version.getGameVersion(), version.getVersion(), null, Collections.singletonList(jar) )); } } @@ -90,5 +82,5 @@ public CompletableFuture refreshAsync() { }); } - public static final String FORGE_LIST = "https://zkitefly.github.io/forge-maven-metadata/list.json"; + public static final String FORGE_LIST = "https://files.minecraftforge.net/maven/net/minecraftforge/forge/json"; } From fd97f6c321577ccdfa8e1c705794e667cea100b3 Mon Sep 17 00:00:00 2001 From: Zkitefly Date: Sat, 24 Aug 2024 23:43:50 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E6=94=AF=E6=8C=81=20Forge=20=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=BA=90=20(#3259)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Revert "支持 Forge 官方源 (#3251)" (#3258)" This reverts commit abd37a093ac04cdda61196e1fdf1b1a23a8b1dad. * Update ForgeVersionList.java --- .../hmcl/download/MojangDownloadProvider.java | 6 +++--- .../hmcl/download/forge/ForgeVersionList.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java index a0a677f250..86fc3e032f 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MojangDownloadProvider.java @@ -19,7 +19,7 @@ import org.jackhuang.hmcl.download.fabric.FabricAPIVersionList; 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.liteloader.LiteLoaderVersionList; import org.jackhuang.hmcl.download.neoforge.NeoForgeOfficialVersionList; @@ -35,7 +35,7 @@ public class MojangDownloadProvider implements DownloadProvider { private final GameVersionList game; private final FabricVersionList fabric; private final FabricAPIVersionList fabricApi; - private final ForgeBMCLVersionList forge; + private final ForgeVersionList forge; private final NeoForgeOfficialVersionList neoforge; private final LiteLoaderVersionList liteLoader; private final OptiFineBMCLVersionList optifine; @@ -49,7 +49,7 @@ public MojangDownloadProvider() { this.game = new GameVersionList(this); this.fabric = new FabricVersionList(this); this.fabricApi = new FabricAPIVersionList(this); - this.forge = new ForgeBMCLVersionList(apiRoot); + this.forge = new ForgeVersionList(this); this.neoforge = new NeoForgeOfficialVersionList(this); this.liteLoader = new LiteLoaderVersionList(this); this.optifine = new OptiFineBMCLVersionList(apiRoot); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java index fa9a558133..95199986da 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java @@ -43,9 +43,17 @@ public boolean hasType() { 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 public CompletableFuture refreshAsync() { - return HttpRequest.GET(downloadProvider.injectURL(FORGE_LIST)).getJsonAsync(ForgeVersionRoot.class) + return HttpRequest.GET(FORGE_LIST).getJsonAsync(ForgeVersionRoot.class) .thenAcceptAsync(root -> { lock.writeLock().lock(); @@ -55,7 +63,7 @@ public CompletableFuture refreshAsync() { versions.clear(); for (Map.Entry entry : root.getGameVersions().entrySet()) { - String gameVersion = VersionNumber.normalize(entry.getKey()); + String gameVersion = fromLookupVersion(VersionNumber.normalize(entry.getKey())); for (int v : entry.getValue()) { ForgeVersion version = root.getNumber().get(v); if (version == null) @@ -72,7 +80,7 @@ public CompletableFuture refreshAsync() { if (jar == null) continue; 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 CompletableFuture refreshAsync() { }); } - 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/"; } From abf58b2c20337cc624d9b41462861cbf1535f036 Mon Sep 17 00:00:00 2001 From: Haowei Wen Date: Sat, 24 Aug 2024 23:44:13 +0800 Subject: [PATCH 4/7] Fix missing i18n key curse.category.7418 (#3260) --- HMCL/src/main/resources/assets/lang/I18N.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_es.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_ja.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_ru.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_zh.properties | 1 + HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties | 1 + 6 files changed, 6 insertions(+) diff --git a/HMCL/src/main/resources/assets/lang/I18N.properties b/HMCL/src/main/resources/assets/lang/I18N.properties index dc1bdd651e..2f48a992f0 100644 --- a/HMCL/src/main/resources/assets/lang/I18N.properties +++ b/HMCL/src/main/resources/assets/lang/I18N.properties @@ -211,6 +211,7 @@ curse.category.4482=Extra Large curse.category.4472=Tech curse.category.4473=Magic curse.category.5128=Vanilla+ +curse.category.7418=Horror # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5299=Education diff --git a/HMCL/src/main/resources/assets/lang/I18N_es.properties b/HMCL/src/main/resources/assets/lang/I18N_es.properties index 0172d1c54f..57cd8908d8 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_es.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_es.properties @@ -187,6 +187,7 @@ curse.category.4482=Extra grande curse.category.4472=Tecnología curse.category.4473=Magia curse.category.5128=Vanilla+ +curse.category.7418=Horror # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5299=Educación diff --git a/HMCL/src/main/resources/assets/lang/I18N_ja.properties b/HMCL/src/main/resources/assets/lang/I18N_ja.properties index 057ddc5e98..e93f3186b7 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ja.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ja.properties @@ -173,6 +173,7 @@ curse.category.4479=ハードコア curse.category.4482=特大 curse.category.4472=Tech curse.category.4473=魔法 +curse.category.7418=ホラー # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5129=Vanilla+ diff --git a/HMCL/src/main/resources/assets/lang/I18N_ru.properties b/HMCL/src/main/resources/assets/lang/I18N_ru.properties index 37b91035a7..c50bb7178a 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_ru.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_ru.properties @@ -184,6 +184,7 @@ curse.category.4482=Extra Large curse.category.4472=Tech curse.category.4473=Magic curse.category.5128=Vanilla+ +curse.category.7418=Horror # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5299=Education diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh.properties b/HMCL/src/main/resources/assets/lang/I18N_zh.properties index a11eb2474b..57fa6e02a6 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh.properties @@ -221,6 +221,7 @@ curse.category.4482=大型模組包 curse.category.4472=科技 curse.category.4473=魔法 curse.category.5128=原版增強 +curse.category.7418=恐怖 # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5299=教育 diff --git a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties index ededc00cd6..7746fe32af 100644 --- a/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties +++ b/HMCL/src/main/resources/assets/lang/I18N_zh_CN.properties @@ -222,6 +222,7 @@ curse.category.4482=大型整合包 curse.category.4472=科技 curse.category.4473=魔法 curse.category.5128=原版增强 +curse.category.7418=恐怖 # https://addons-ecs.forgesvc.net/api/v2/category/section/6 curse.category.5299=教育 From 9b5445b6866453396b68326c0e47d9a65d8e6833 Mon Sep 17 00:00:00 2001 From: Zkitefly Date: Sun, 25 Aug 2024 02:55:55 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E7=BB=84?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E5=9B=BE=E6=A0=87=E9=97=AE=E9=A2=98?= =?UTF-8?q?=20(#3227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * Update ModListPageSkin.java * update * 调整判断逻辑 * update * update --------- Co-authored-by: Glavo --- .../hmcl/ui/versions/ModListPageSkin.java | 78 ++++++++++++++----- 1 file changed, 57 insertions(+), 21 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java index acd647a5fd..4c35fe6308 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPageSkin.java @@ -59,15 +59,11 @@ import org.jackhuang.hmcl.util.io.NetworkUtils; import org.jetbrains.annotations.NotNull; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; +import java.io.InputStream; import java.nio.file.FileSystem; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Arrays; -import java.util.List; -import java.util.Locale; -import java.util.Optional; +import java.util.*; import java.util.function.Predicate; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -297,25 +293,65 @@ class ModInfoDialog extends JFXDialogLayout { titleContainer.setSpacing(8); ImageView imageView = new ImageView(); - if (StringUtils.isNotBlank(modInfo.getModInfo().getLogoPath())) { - Task.supplyAsync(() -> { - try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modInfo.getModInfo().getFile())) { - Path iconPath = fs.getPath(modInfo.getModInfo().getLogoPath()); + Task.supplyAsync(() -> { + try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(modInfo.getModInfo().getFile())) { + String logoPath = modInfo.getModInfo().getLogoPath(); + if (StringUtils.isNotBlank(logoPath)) { + Path iconPath = fs.getPath(logoPath); if (Files.exists(iconPath)) { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - Files.copy(iconPath, stream); - return new ByteArrayInputStream(stream.toByteArray()); + try (InputStream stream = Files.newInputStream(iconPath)) { + Image image = new Image(stream, 40, 40, true, true); + if (!image.isError() && image.getWidth() == image.getHeight()) + return image; + } catch (Throwable e) { + LOG.warning("Failed to load image " + logoPath, e); + } } } - return null; - }).whenComplete(Schedulers.javafx(), (stream, exception) -> { - if (stream != null) { - imageView.setImage(new Image(stream, 40, 40, true, true)); - } else { - imageView.setImage(FXUtils.newBuiltinImage("/assets/img/command.png", 40, 40, true, true)); + + List defaultPaths = new ArrayList<>(Arrays.asList( + "icon.png", + "logo.png", + "mod_logo.png", + "pack.png", + "logoFile.png" + )); + + String id = modInfo.getModInfo().getId(); + if (StringUtils.isNotBlank(id)) { + defaultPaths.addAll(Arrays.asList( + "assets/" + id + "/icon.png", + "assets/" + id.replace("-", "") + "/icon.png", + id + ".png", + id + "-logo.png", + id + "-icon.png", + id + "_logo.png", + id + "_icon.png" + )); } - }).start(); - } + + for (String path : defaultPaths) { + Path iconPath = fs.getPath(path); + if (Files.exists(iconPath)) { + try (InputStream stream = Files.newInputStream(iconPath)) { + Image image = new Image(stream, 40, 40, true, true); + if (!image.isError() && image.getWidth() == image.getHeight()) + return image; + } + } + } + } catch (Exception e) { + LOG.warning("Failed to load icon", e); + } + + return null; + }).whenComplete(Schedulers.javafx(), (image, exception) -> { + if (image != null) { + imageView.setImage(image); + } else { + imageView.setImage(FXUtils.newBuiltinImage("/assets/img/command.png", 40, 40, true, true)); + } + }).start(); TwoLineListItem title = new TwoLineListItem(); title.setTitle(modInfo.getModInfo().getName()); From 738000ff399bf38e18a149af76f52e50b6cabb1f Mon Sep 17 00:00:00 2001 From: Burning_TNT <88144530+burningtnt@users.noreply.github.com> Date: Sun, 25 Aug 2024 03:03:48 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=B1=BB=E4=B8=8E=E6=96=B9=E6=B3=95=20(#3132)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove useless classes. * Remove useless methods --- .../org/jackhuang/hmcl/countly/Countly.java | 86 ------------------- .../jackhuang/hmcl/countly/CrashReport.java | 56 ------------ .../org/jackhuang/hmcl/game/LoadingState.java | 38 -------- 3 files changed, 180 deletions(-) delete mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java delete mode 100644 HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java b/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java deleted file mode 100644 index f18b196859..0000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/countly/Countly.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui 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 . - */ -package org.jackhuang.hmcl.countly; - -import org.jackhuang.hmcl.util.io.HttpRequest; - -import java.io.IOException; -import java.time.ZonedDateTime; -import java.util.Calendar; -import java.util.Locale; - -import static org.jackhuang.hmcl.util.Pair.pair; - -public class Countly { - - private String deviceId; - private String endpoint; - private String serverURL; - - public void sendMetric(String metrics) throws IOException { - HttpRequest.GET(serverURL + endpoint, - pair("begin_session", "1"), - pair("session_id", "1"), - pair("metrics", metrics), - pair("device_id", deviceId), - pair("timestamp", Long.toString(System.currentTimeMillis())), - pair("tz", Integer.toString(getTimezoneOffset())), - pair("hour", Integer.toString(currentHour())), - pair("dow", Integer.toString(currentDayOfWeek())), - pair("app_key", APP_KEY), - pair("sdk_name", "java-native"), - pair("sdk_version", "20.11.1")) - .getString(); - } - - private static int getTimezoneOffset() { - return ZonedDateTime.now().getOffset().getTotalSeconds() / 60; - } - - private static String getLocale() { - final Locale locale = Locale.getDefault(); - return locale.getLanguage() + "_" + locale.getCountry(); - } - - private static int currentHour() { - return Calendar.getInstance().get(Calendar.HOUR_OF_DAY); - } - - private int currentDayOfWeek() { - int day = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); - switch (day) { - case Calendar.SUNDAY: - return 0; - case Calendar.MONDAY: - return 1; - case Calendar.TUESDAY: - return 2; - case Calendar.WEDNESDAY: - return 3; - case Calendar.THURSDAY: - return 4; - case Calendar.FRIDAY: - return 5; - case Calendar.SATURDAY: - return 6; - } - return 0; - } - - private static final String APP_KEY = ""; -} diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java b/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java index a18d405f7a..6c3847e587 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/countly/CrashReport.java @@ -5,14 +5,8 @@ import org.jackhuang.hmcl.util.platform.Architecture; import org.jackhuang.hmcl.util.platform.OperatingSystem; -import java.io.File; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Map; - -import static org.jackhuang.hmcl.util.Lang.mapOf; -import static org.jackhuang.hmcl.util.Pair.pair; -import static org.jackhuang.hmcl.util.logging.Logger.LOG; public class CrashReport { @@ -20,24 +14,16 @@ public class CrashReport { private final Throwable throwable; private final String stackTrace; - private boolean nonFatal; - public CrashReport(Thread thread, Throwable throwable) { this.thread = thread; this.throwable = throwable; stackTrace = StringUtils.getStackTrace(throwable); - nonFatal = false; } public Throwable getThrowable() { return this.throwable; } - public CrashReport setNonFatal() { - nonFatal = true; - return this; - } - public boolean shouldBeReport() { if (!stackTrace.contains("org.jackhuang")) return false; @@ -48,23 +34,6 @@ public boolean shouldBeReport() { return true; } - public Map getMetrics(long runningTime) { - return mapOf( - pair("_run", runningTime), - pair("_app_version", Metadata.VERSION), - pair("_os", OperatingSystem.SYSTEM_NAME), - pair("_os_version", OperatingSystem.SYSTEM_VERSION), - pair("_disk_current", getDiskAvailable()), - pair("_disk_total", getDiskTotal()), - pair("_ram_current", getMemoryAvailable()), - pair("_ram_total", Runtime.getRuntime().maxMemory() / BYTES_IN_MB), - pair("_error", stackTrace), - pair("_logs", LOG.getLogs()), - pair("_name", throwable.getLocalizedMessage()), - pair("_nonfatal", nonFatal) - ); - } - public String getDisplayText() { return "---- Hello Minecraft! Crash Report ----\n" + " Version: " + Metadata.VERSION + "\n" + @@ -82,29 +51,4 @@ public String getDisplayText() { " JVM Total Memory: " + Runtime.getRuntime().totalMemory() + "\n" + " JVM Free Memory: " + Runtime.getRuntime().freeMemory() + "\n"; } - - private static final Long BYTES_IN_MB = 1024L * 1024; - - private static long getMemoryAvailable() { - Long total = Runtime.getRuntime().totalMemory(); - Long availMem = Runtime.getRuntime().freeMemory(); - return (total - availMem) / BYTES_IN_MB; - } - - private static long getDiskAvailable() { - long total = 0, free = 0; - for (File f : File.listRoots()) { - total += f.getTotalSpace(); - free += f.getUsableSpace(); - } - return (total - free) / BYTES_IN_MB; - } - - private static long getDiskTotal() { - long total = 0; - for (File f : File.listRoots()) { - total += f.getTotalSpace(); - } - return total / BYTES_IN_MB; - } } diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java deleted file mode 100644 index 6b434a9b59..0000000000 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/LoadingState.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Hello Minecraft! Launcher - * Copyright (C) 2020 huangyuhui 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 . - */ -package org.jackhuang.hmcl.game; - -import static org.jackhuang.hmcl.util.i18n.I18n.i18n; - -public enum LoadingState { - DEPENDENCIES("launch.state.dependencies"), - MODS("launch.state.modpack"), - LOGGING_IN("launch.state.logging_in"), - LAUNCHING("launch.state.waiting_launching"), - DONE("launch.state.done"); - - private final String key; - - LoadingState(String key) { - this.key = key; - } - - public String getLocalizedMessage() { - return i18n(key); - } -} From 48417b9b7b62f6bcd6e0c35a8ff76137046d3e28 Mon Sep 17 00:00:00 2001 From: Zkitefly <2573874409@qq.com> Date: Sat, 31 Aug 2024 00:44:43 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E6=98=BE=E7=A4=BA=20Forge=20=E5=8F=91?= =?UTF-8?q?=E7=89=88=E6=97=B6=E9=97=B4=20(#3256)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 显示时间 * Fix * update * update --------- Co-authored-by: Glavo --- .../org/jackhuang/hmcl/download/forge/ForgeVersion.java | 6 +++--- .../jackhuang/hmcl/download/forge/ForgeVersionList.java | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java index 429f61d371..a7bb771935 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersion.java @@ -33,7 +33,7 @@ public final class ForgeVersion implements Validation { private final String jobver; private final String version; private final int build; - private final double modified; + private final long modified; private final String[][] files; /** @@ -44,7 +44,7 @@ public ForgeVersion() { this(null, null, null, null, 0, 0, null); } - public ForgeVersion(String branch, String mcversion, String jobver, String version, int build, double modified, String[][] files) { + public ForgeVersion(String branch, String mcversion, String jobver, String version, int build, long modified, String[][] files) { this.branch = branch; this.mcversion = mcversion; this.jobver = jobver; @@ -74,7 +74,7 @@ public int getBuild() { return build; } - public double getModified() { + public long getModified() { return modified; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java index 95199986da..acb97fef3c 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/forge/ForgeVersionList.java @@ -23,6 +23,7 @@ import org.jackhuang.hmcl.util.io.HttpRequest; import org.jackhuang.hmcl.util.versioning.VersionNumber; +import java.time.Instant; import java.util.Collections; import java.util.Map; import java.util.concurrent.CompletableFuture; @@ -79,8 +80,12 @@ public CompletableFuture refreshAsync() { if (jar == null) continue; + versions.put(gameVersion, new ForgeRemoteVersion( - toLookupVersion(version.getGameVersion()), version.getVersion(), null, Collections.singletonList(jar) + toLookupVersion(version.getGameVersion()), + version.getVersion(), + version.getModified() > 0 ? Instant.ofEpochSecond(version.getModified()) : null, + Collections.singletonList(jar) )); } }