diff --git a/build.gradle b/build.gradle index 3b59215d5c..65b673d1f9 100644 --- a/build.gradle +++ b/build.gradle @@ -44,7 +44,7 @@ ext { COREMODS_VERSION = '5.0.1' EVENTBUS_VERSION = '6.0.0' MODLAUNCHER_VERSION = '10.0.1' - SECUREJARHANDLER_VERSION = '1.0.5' + SECUREJARHANDLER_VERSION = '2.0.3' BOOTSTRAPLAUNCHER_VERSION = '1.1.0' ASM_VERSION = '9.3' INSTALLER_VERSION = '2.1.+' diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java index 4529342547..11e4bb6486 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/ModSorter.java @@ -162,7 +162,8 @@ public class ModSorter modFiles.stream() .filter(modFile -> modFile.getProvider().getClass() == MinecraftLocator.class) .map(ModFile::getSecureJar) - .map(SecureJar::getManifest) + .map(SecureJar::moduleDataProvider) + .map(SecureJar.ModuleDataProvider::getManifest) .map(Manifest::getMainAttributes) .map(mf -> mf.getValue("FML-System-Mods")) .filter(Objects::nonNull) diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java index 74c3246f40..abec568c97 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/AbstractModProvider.java @@ -37,26 +37,24 @@ public abstract class AbstractModProvider implements IModProvider var mjm = new ModJarMetadata(); var sj = SecureJar.from( Manifest::new, - jar -> jar.findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path), + jar -> jar.moduleDataProvider().findFile(MODS_TOML).isPresent() ? mjm : JarMetadata.from(jar, path), (root, p) -> true, path ); IModFile mod; - var type = sj.getManifest().getMainAttributes().getValue(ModFile.TYPE); + var type = sj.moduleDataProvider().getManifest().getMainAttributes().getValue(ModFile.TYPE); if (type == null) { type = getDefaultJarModType(); } - try { - if (sj.findFile(MODS_TOML).isPresent()) { - LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); - mod = new ModFile(sj, this, ModFileParser::modsTomlParser); - } else if (type != null) { - LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path); - mod = new ModFile(sj, this, this::manifestParser, type); + if (sj.moduleDataProvider().findFile(MODS_TOML).isPresent()) { + LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MODS_TOML, type, path); + mod = new ModFile(sj, this, ModFileParser::modsTomlParser); + } else if (type != null) { + LOGGER.debug(LogMarkers.SCAN, "Found {} mod of type {}: {}", MANIFEST, type, path); + mod = new ModFile(sj, this, this::manifestParser, type); } else { return new IModLocator.ModFileOrException(null, new ModFileLoadingException("Invalid mod file found "+ Arrays.toString(path))); - } } catch (InvalidModFileException e) { return new IModLocator.ModFileOrException(null, e); } @@ -66,7 +64,7 @@ public abstract class AbstractModProvider implements IModProvider } protected IModFileInfo manifestParser(final IModFile mod) { - Function> cfg = name -> Optional.ofNullable(mod.getSecureJar().getManifest().getMainAttributes().getValue(name)); + Function> cfg = name -> Optional.ofNullable(mod.getSecureJar().moduleDataProvider().getManifest().getMainAttributes().getValue(name)); var license = cfg.apply("LICENSE").orElse(""); var dummy = new IConfigurable() { @Override diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java index 1d4ebc95b4..27303484f6 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ExplodedDirectoryLocator.java @@ -33,7 +33,7 @@ public class ExplodedDirectoryLocator implements IModLocator { public List scanMods() { explodedMods.forEach(explodedMod -> ModJarMetadata.buildFile(this, - jar->jar.findFile("/META-INF/mods.toml").isPresent(), + jar->jar.moduleDataProvider().findFile("/META-INF/mods.toml").isPresent(), (a,b) -> true, explodedMod.paths().toArray(Path[]::new)) .ifPresentOrElse(f->mods.put(explodedMod, f), () -> LOGGER.warn(LogMarkers.LOADING, "Failed to find exploded resource mods.toml in directory {}", explodedMod.paths().get(0).toString()))); diff --git a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java index 888f046038..17feeb36cb 100644 --- a/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java +++ b/fmlloader/src/main/java/net/minecraftforge/fml/loading/moddiscovery/ModFile.java @@ -73,7 +73,7 @@ public class ModFile implements IModFile { this.jar = jar; this.parser = parser; - manifest = this.jar.getManifest(); + manifest = this.jar.moduleDataProvider().getManifest(); modFileType = Type.valueOf(type); jarVersion = Optional.ofNullable(manifest.getMainAttributes().getValue(Attributes.Name.IMPLEMENTATION_VERSION)).orElse("0.0NONE"); this.modFileInfo = ModFileParser.readModList(this, this.parser); @@ -214,7 +214,7 @@ public class ModFile implements IModFile { } private static String parseType(final SecureJar jar) { - final Manifest m = jar.getManifest(); + final Manifest m = jar.moduleDataProvider().getManifest(); final Optional value = Optional.ofNullable(m.getMainAttributes().getValue(TYPE)); return value.orElse("MOD"); }