From 8ad5d83946958410e02b96660442296c6fb0ea6d Mon Sep 17 00:00:00 2001 From: Glavo Date: Sat, 11 Oct 2025 21:27:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A0=E6=B3=95=E8=AF=86?= =?UTF-8?q?=E5=88=AB=E9=83=A8=E5=88=86=20Forge=20=E6=A8=A1=E7=BB=84?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E9=97=AE=E9=A2=98=20(#4654)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jackhuang/hmcl/ui/versions/ModListPage.java | 3 ++- .../java/org/jackhuang/hmcl/mod/ModManager.java | 12 ++++++++++-- .../hmcl/mod/modinfo/ForgeNewModMetadata.java | 14 +++++++++++++- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java index 0b3060efe..3a74e3840 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/versions/ModListPage.java @@ -158,7 +158,8 @@ public final class ModListPage extends ListPageBase exceptions = new ArrayList<>(); try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(file)) { for (ModMetadataReader reader : supportedReaders) { try { modInfo = reader.fromFile(this, file, fs); break; - } catch (Exception ignore) { + } catch (Exception e) { + exceptions.add(e); } } @@ -138,7 +140,7 @@ public final class ModManager { try { modInfo = reader.fromFile(this, file, fs); break; - } catch (Exception ignore) { + } catch (Exception ignored) { } } } @@ -147,6 +149,12 @@ public final class ModManager { } if (modInfo == null) { + Exception exception = new Exception("Failed to read mod metadata"); + for (Exception e : exceptions) { + exception.addSuppressed(e); + } + LOG.warning("Failed to read mod metadata", exception); + String fileNameWithoutExtension = FileUtils.getNameWithoutExtension(file); modInfo = new LocalModFile(this, diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/ForgeNewModMetadata.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/ForgeNewModMetadata.java index 9fb52c380..a6c24ce70 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/ForgeNewModMetadata.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/mod/modinfo/ForgeNewModMetadata.java @@ -244,7 +244,19 @@ public final class ForgeNewModMetadata { private static ModLoaderType analyzeLoader(Toml toml, String modID, ModLoaderType loader) throws IOException { List> dependencies = toml.getList("dependencies." + modID); if (dependencies == null) { - dependencies = toml.getList("dependencies"); // ??? I have no idea why some of the Forge mods use [[dependencies]] + try { + dependencies = toml.getList("dependencies"); // ??? I have no idea why some of the Forge mods use [[dependencies]] + } catch (ClassCastException e) { + try { + Toml table = toml.getTable("dependencies"); + if (table == null) + return loader; + + dependencies = table.getList(modID); + } catch (Throwable ignored) { + } + } + if (dependencies == null) { return loader; }