Bump SJH version. Closes #8127

Attempt addressing loading libraries during dev time, and bump SPI version introducing GAMELIBRARY type. #7976 #7957 #8090
This commit is contained in:
LexManos committed 2021-10-01 13:21:00 -07:00
1 parent 96303f6570
commit 5e2e404828
5 files changed
+175 -134

No files matched your search

@@ -25,6 +25,7 @@ import net.minecraftforge.forgespi.locating.IModFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
@@ -34,17 +35,14 @@ import java.util.Enumeration;
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.jar.JarInputStream;
import java.util.stream.Stream;
import java.util.zip.ZipInputStream;
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
public class ClasspathLocator extends AbstractJarFileLocator {
private static final Logger LOGGER = LogManager.getLogger();
private static final String MODS_TOML = "META-INF/mods.toml";
private static final String MANIFEST = "META-INF/MANIFEST.MF";
private final List<String> ignoreList = Arrays.stream(System.getProperty("ignoreList", "").split(",")).toList();
private final List<Path> legacyClasspath = Arrays.stream(System.getProperty("legacyClassPath", "").split(File.pathSeparator)).map(Path::of).toList();
private boolean enabled = false;
@Override
@@ -59,7 +57,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
try {
var modCoords = Stream.<IModFile>builder();
locateMods(modCoords, MODS_TOML, "classpath_mod", sj -> true);
locateMods(modCoords, MANIFEST, "manifest_jar", sj -> isValidManifest(sj) && sj.getManifest().getMainAttributes().getValue(ModFile.TYPE) != null);
locateMods(modCoords, MANIFEST, "manifest_jar", sj -> sj.getManifest() != ModFile.DEFAULTMANIFEST && sj.getManifest().getMainAttributes().getValue(ModFile.TYPE) != null);
return modCoords.build().toList();
} catch (IOException e) {
LOGGER.fatal(CORE, "Error trying to find resources", e);
@@ -77,7 +75,7 @@ public class ClasspathLocator extends AbstractJarFileLocator {
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
Path path = LibraryFinder.findJarPathFor(resource, name, url);
if (ignoreList.stream().anyMatch(path.toString()::contains) || Files.isDirectory(path))
if (legacyClasspath.stream().anyMatch(path::equals) || Files.isDirectory(path))
continue;
ModJarMetadata.buildFile(this, filter, path).ifPresent(mf -> {
@@ -92,12 +90,4 @@ public class ClasspathLocator extends AbstractJarFileLocator {
var launchTarget = (String) arguments.get("launchTarget");
enabled = launchTarget != null && launchTarget.contains("dev");
}
private static boolean isValidManifest(SecureJar sj) {
try (var jis = new JarInputStream(Files.newInputStream(sj.getRootPath()))) {
return jis.getManifest() != null;
} catch (IOException e) {
return false;
}
}
}
@@ -116,7 +116,7 @@ public class ModFile implements IModFile {
public boolean identifyMods() {
this.modFileInfo = ModFileParser.readModList(this, this.parser);
if (this.modFileInfo == null) return false;
if (this.modFileInfo == null) return this.getType() != Type.MOD;
LOGGER.debug(LOADING,"Loading mod file {} with languages {}", this.getFilePath(), this.modFileInfo.requiredLanguageLoaders());
this.coreMods = ModFileParser.getCoreMods(this);
this.coreMods.forEach(mi-> LOGGER.debug(LOADING,"Found coremod {}", mi.getPath()));
@@ -1,20 +1,15 @@
package net.minecraftforge.fml.loading.moddiscovery;
import cpw.mods.jarhandling.SecureJar;
import cpw.mods.modlauncher.api.IModuleLayerManager;
import cpw.mods.modlauncher.api.ITransformationService;
import net.minecraftforge.fml.loading.*;
import net.minecraftforge.fml.loading.progress.StartupMessageManager;
import net.minecraftforge.forgespi.locating.IModFile;
import net.minecraftforge.forgespi.locating.ModFileFactory;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static net.minecraftforge.fml.loading.LogMarkers.SCAN;
public class ModValidator {
@@ -27,9 +22,14 @@ public class ModValidator {
public ModValidator(final Map<IModFile.Type, List<ModFile>> modFiles) {
this.modFiles = modFiles;
this.candidateMods = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.MOD, List.of()));
this.candidatePlugins = new ArrayList<>(modFiles.getOrDefault(IModFile.Type.LANGPROVIDER, List.of()));
this.candidatePlugins.addAll(modFiles.getOrDefault(IModFile.Type.LIBRARY, List.of()));
this.candidateMods = lst(modFiles.get(IModFile.Type.MOD));
this.candidateMods.addAll(lst(modFiles.get(IModFile.Type.GAMELIBRARY)));
this.candidatePlugins = lst(modFiles.get(IModFile.Type.LANGPROVIDER));
this.candidatePlugins.addAll(lst(modFiles.get(IModFile.Type.LIBRARY)));
}
private static List<ModFile> lst(List<ModFile> files) {
return files == null ? new ArrayList<>() : new ArrayList<>(files);
}
public void stage1Validation() {