Some tweaks to ContainedDeps - it should extract to a file in versionedMods directly, even if the tag in the jar has a subpath element. It'll also skip if there is a matching filename in the main mods dir.

This commit is contained in:
cpw 2016-07-21 13:59:02 -04:00
parent 8f74d05d02
commit b7739ffc71

View file

@ -371,7 +371,7 @@ public class CoreModManager {
ignoredModFiles.add(coreMod.getName());
continue;
}
ModListHelper.additionalMods.putAll(extractContainedDepJars(jar, versionedModDir));
ModListHelper.additionalMods.putAll(extractContainedDepJars(jar, coreMods, versionedModDir));
fmlCorePlugin = mfAttributes.getValue("FMLCorePlugin");
if (fmlCorePlugin == null)
{
@ -424,7 +424,7 @@ public class CoreModManager {
}
}
private static Map<String,File> extractContainedDepJars(JarFile jar, File versionedModsDir) throws IOException
private static Map<String,File> extractContainedDepJars(JarFile jar, File baseModsDir, File versionedModsDir) throws IOException
{
Map<String,File> result = Maps.newHashMap();
if (!jar.getManifest().getMainAttributes().containsKey(MODCONTAINSDEPS)) return result;
@ -433,7 +433,8 @@ public class CoreModManager {
String[] depList = deps.split(" ");
for (String dep : depList)
{
if (skipContainedDeps.contains(dep))
String depEndName = new File(dep).getName(); // extract last part of name
if (skipContainedDeps.contains(dep) || skipContainedDeps.contains(depEndName))
{
FMLRelaunchLog.log(Level.ERROR, "Skipping dep at request: %s", dep);
continue;
@ -444,26 +445,34 @@ public class CoreModManager {
FMLRelaunchLog.log(Level.ERROR, "Found invalid ContainsDeps declaration %s in %s", dep, jar.getName());
continue;
}
File target = new File(versionedModsDir, dep);
File target = new File(versionedModsDir, depEndName);
File modTarget = new File(baseModsDir, depEndName);
if (target.exists())
{
FMLRelaunchLog.log(Level.DEBUG, "Found existing ContainsDep extracted to %s, skipping extraction", target.getCanonicalPath());
result.put(dep,target);
continue;
}
FMLRelaunchLog.log(Level.DEBUG, "Extracted ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath());
else if (modTarget.exists())
{
FMLRelaunchLog.log(Level.DEBUG, "Found ContainsDep in main mods directory at %s, skipping extraction", modTarget.getCanonicalPath());
result.put(dep, modTarget);
continue;
}
FMLRelaunchLog.log(Level.DEBUG, "Extracting ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath());
try
{
Files.createParentDirs(target);
FileOutputStream targ = new FileOutputStream(target);
ByteStreams.copy(jar.getInputStream(jarEntry), targ);
targ.close();
FMLRelaunchLog.log(Level.DEBUG, "Extracted ContainedDep %s from %s to %s", dep, jar.getName(), target.getCanonicalPath());
result.put(dep,target);
} catch (IOException e)
{
FMLRelaunchLog.log(Level.ERROR, e, "An error occurred extracting dependency");
continue;
}
result.put(dep,target);
}
return result;
}