From 74d64378562378a2181bf096ea63e836673c8214 Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 30 Aug 2012 20:10:13 -0400 Subject: [PATCH] Add in random jar/zip files to the classpath. UGH this is so fucking ugly it's not funny. --- fml/common/cpw/mods/fml/common/Loader.java | 16 ++++++++++++++++ .../mods/fml/common/discovery/ModDiscoverer.java | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index 576d2fef9..ffe4994aa 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -16,6 +16,7 @@ package cpw.mods.fml.common; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.net.MalformedURLException; import java.util.Comparator; import java.util.List; import java.util.Map; @@ -438,6 +439,21 @@ public class Loader modController.distributeStateMessage(FMLLoadEvent.class); sortModList(); mods = ImmutableList.copyOf(mods); + for (File nonMod : disc.getNonModLibs()) + { + if (nonMod.isFile()) + { + FMLLog.severe("FML has found a non-mod file %s in your mods directory. It will now be injected into your classpath. This could severe stability issues, it should be removed if possible.", nonMod.getName()); + try + { + modClassLoader.addFile(nonMod); + } + catch (MalformedURLException e) + { + FMLLog.log(Level.SEVERE, e, "Encountered a weird problem with non-mod file injection : %s", nonMod.getName()); + } + } + } modController.transition(LoaderState.CONSTRUCTING); modController.distributeStateMessage(LoaderState.CONSTRUCTING, modClassLoader, disc.getASMTable()); modController.transition(LoaderState.PREINITIALIZATION); diff --git a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java index 4778dd90e..f12f1f8c6 100644 --- a/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java +++ b/fml/common/cpw/mods/fml/common/discovery/ModDiscoverer.java @@ -25,6 +25,8 @@ public class ModDiscoverer private ASMDataTable dataTable = new ASMDataTable(); + private List nonModLibs = Lists.newArrayList(); + public void findClasspathMods(ModClassLoader modClassLoader) { List knownLibraries = ImmutableList.builder().addAll(modClassLoader.getDefaultLibraries()).addAll(RelaunchLibraryManager.getLibraries()).build(); @@ -99,7 +101,14 @@ public class ModDiscoverer try { List mods = candidate.explore(dataTable); - modList.addAll(mods); + if (mods.isEmpty()) + { + nonModLibs.add(candidate.getModContainer()); + } + else + { + modList.addAll(mods); + } } catch (LoaderException le) { @@ -119,4 +128,9 @@ public class ModDiscoverer return dataTable; } + public List getNonModLibs() + { + return nonModLibs; + } + }