修复无法识别部分 Forge 模组信息的问题 (#4654)
This commit is contained in:
@@ -158,7 +158,8 @@ public final class ModListPage extends ListPageBase<ModListPageSkin.ModInfoObjec
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sinytra Connector
|
// Sinytra Connector
|
||||||
if (analyzer.has(LibraryAnalyzer.LibraryType.NEO_FORGE) && modManager.hasMod("connectormod", ModLoaderType.NEO_FORGED)) {
|
if (analyzer.has(LibraryAnalyzer.LibraryType.NEO_FORGE) && modManager.hasMod("connectormod", ModLoaderType.NEO_FORGED)
|
||||||
|
|| "1.20.1".equals(gameVersion) && analyzer.has(LibraryAnalyzer.LibraryType.FORGE) && modManager.hasMod("connectormod", ModLoaderType.FORGE)) {
|
||||||
supportedLoaders.add(ModLoaderType.FABRIC);
|
supportedLoaders.add(ModLoaderType.FABRIC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,12 +124,14 @@ public final class ModManager {
|
|||||||
|
|
||||||
LocalModFile modInfo = null;
|
LocalModFile modInfo = null;
|
||||||
|
|
||||||
|
List<Exception> exceptions = new ArrayList<>();
|
||||||
try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(file)) {
|
try (FileSystem fs = CompressingUtils.createReadOnlyZipFileSystem(file)) {
|
||||||
for (ModMetadataReader reader : supportedReaders) {
|
for (ModMetadataReader reader : supportedReaders) {
|
||||||
try {
|
try {
|
||||||
modInfo = reader.fromFile(this, file, fs);
|
modInfo = reader.fromFile(this, file, fs);
|
||||||
break;
|
break;
|
||||||
} catch (Exception ignore) {
|
} catch (Exception e) {
|
||||||
|
exceptions.add(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +140,7 @@ public final class ModManager {
|
|||||||
try {
|
try {
|
||||||
modInfo = reader.fromFile(this, file, fs);
|
modInfo = reader.fromFile(this, file, fs);
|
||||||
break;
|
break;
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -147,6 +149,12 @@ public final class ModManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modInfo == null) {
|
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);
|
String fileNameWithoutExtension = FileUtils.getNameWithoutExtension(file);
|
||||||
|
|
||||||
modInfo = new LocalModFile(this,
|
modInfo = new LocalModFile(this,
|
||||||
|
|||||||
@@ -244,7 +244,19 @@ public final class ForgeNewModMetadata {
|
|||||||
private static ModLoaderType analyzeLoader(Toml toml, String modID, ModLoaderType loader) throws IOException {
|
private static ModLoaderType analyzeLoader(Toml toml, String modID, ModLoaderType loader) throws IOException {
|
||||||
List<HashMap<String, Object>> dependencies = toml.getList("dependencies." + modID);
|
List<HashMap<String, Object>> dependencies = toml.getList("dependencies." + modID);
|
||||||
if (dependencies == null) {
|
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) {
|
if (dependencies == null) {
|
||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user