From e261ad1295eb452970206d64fa31cefcb691a5d9 Mon Sep 17 00:00:00 2001 From: Christian Weeks Date: Wed, 18 Apr 2012 14:03:30 -0400 Subject: [PATCH] Tweak the loader a little bit to just use file names, not fully qualified directories when referring to mods. --- .../cpw/mods/fml/common/FMLCommonHandler.java | 4 ++-- fml/common/cpw/mods/fml/common/FMLModContainer.java | 13 +++++++++---- .../cpw/mods/fml/common/IFMLSidedHandler.java | 2 +- fml/common/cpw/mods/fml/common/Loader.java | 2 +- fml/common/cpw/mods/fml/common/ModContainer.java | 5 +++-- .../cpw/mods/fml/server/FMLServerHandler.java | 4 ++-- .../cpw/mods/fml/server/ModLoaderModContainer.java | 8 ++++---- 7 files changed, 22 insertions(+), 16 deletions(-) diff --git a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java index 108155c4d..5750e115d 100644 --- a/fml/common/cpw/mods/fml/common/FMLCommonHandler.java +++ b/fml/common/cpw/mods/fml/common/FMLCommonHandler.java @@ -245,9 +245,9 @@ public class FMLCommonHandler * @param canonicalPath * @return */ - public ModContainer loadBaseModMod(Class clazz, String canonicalPath) + public ModContainer loadBaseModMod(Class clazz, File canonicalFile) { - return sidedDelegate.loadBaseModMod(clazz, canonicalPath); + return sidedDelegate.loadBaseModMod(clazz, canonicalFile); } public File getMinecraftRootDirectory() { diff --git a/fml/common/cpw/mods/fml/common/FMLModContainer.java b/fml/common/cpw/mods/fml/common/FMLModContainer.java index 931f1d7f6..197fe0582 100644 --- a/fml/common/cpw/mods/fml/common/FMLModContainer.java +++ b/fml/common/cpw/mods/fml/common/FMLModContainer.java @@ -12,6 +12,7 @@ */ package cpw.mods.fml.common; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -19,9 +20,13 @@ public class FMLModContainer implements ModContainer { private Mod modDescriptor; private Object modInstance; - private String source; + private File source; - public FMLModContainer(String source) + public FMLModContainer(String dummy) + { + this(new File(dummy)); + } + public FMLModContainer(File source) { this.source = source; } @@ -106,7 +111,7 @@ public class FMLModContainer implements ModContainer } @Override - public String getSource() + public File getSource() { return source; } @@ -229,7 +234,7 @@ public class FMLModContainer implements ModContainer @Override public String toString() { - return getSource(); + return getSource().getName(); } /* (non-Javadoc) diff --git a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java index 74a220388..bf6d4d085 100644 --- a/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java +++ b/fml/common/cpw/mods/fml/common/IFMLSidedHandler.java @@ -8,7 +8,7 @@ public interface IFMLSidedHandler Logger getMinecraftLogger(); File getMinecraftRootDirectory(); boolean isModLoaderMod(Class clazz); - ModContainer loadBaseModMod(Class clazz, String canonicalPath); + ModContainer loadBaseModMod(Class clazz, File canonicalFile); boolean isServer(); boolean isClient(); } diff --git a/fml/common/cpw/mods/fml/common/Loader.java b/fml/common/cpw/mods/fml/common/Loader.java index 1268ed3dc..bc4b33a27 100644 --- a/fml/common/cpw/mods/fml/common/Loader.java +++ b/fml/common/cpw/mods/fml/common/Loader.java @@ -447,7 +447,7 @@ public class Loader else if (FMLCommonHandler.instance().isModLoaderMod(clazz)) { log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName)); - ModContainer mc = FMLCommonHandler.instance().loadBaseModMod(clazz, classSource.getCanonicalPath()); + ModContainer mc = FMLCommonHandler.instance().loadBaseModMod(clazz, classSource.getCanonicalFile()); mods.add(mc); log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName)); } diff --git a/fml/common/cpw/mods/fml/common/ModContainer.java b/fml/common/cpw/mods/fml/common/ModContainer.java index 0b61f7e7e..f7728e732 100644 --- a/fml/common/cpw/mods/fml/common/ModContainer.java +++ b/fml/common/cpw/mods/fml/common/ModContainer.java @@ -13,6 +13,7 @@ */ package cpw.mods.fml.common; +import java.io.File; import java.util.List; /** @@ -69,10 +70,10 @@ public interface ModContainer */ boolean matches(Object mod); /** - * The source of this mod: usually the file name on the file system + * The source of this mod: the file on the file system * @return */ - String getSource(); + File getSource(); /** * The actual mod object itself * @return diff --git a/fml/server/cpw/mods/fml/server/FMLServerHandler.java b/fml/server/cpw/mods/fml/server/FMLServerHandler.java index c11d355ed..0aa90e7da 100644 --- a/fml/server/cpw/mods/fml/server/FMLServerHandler.java +++ b/fml/server/cpw/mods/fml/server/FMLServerHandler.java @@ -185,11 +185,11 @@ public class FMLServerHandler implements IFMLSidedHandler /** * Load the supplied mod class into a mod container */ - public ModContainer loadBaseModMod(Class clazz, String canonicalPath) + public ModContainer loadBaseModMod(Class clazz, File canonicalFile) { @SuppressWarnings("unchecked") Class bmClazz = (Class ) clazz; - return new ModLoaderModContainer(bmClazz, canonicalPath); + return new ModLoaderModContainer(bmClazz, canonicalFile); } /** diff --git a/fml/server/cpw/mods/fml/server/ModLoaderModContainer.java b/fml/server/cpw/mods/fml/server/ModLoaderModContainer.java index bfc850f43..665dad107 100644 --- a/fml/server/cpw/mods/fml/server/ModLoaderModContainer.java +++ b/fml/server/cpw/mods/fml/server/ModLoaderModContainer.java @@ -43,11 +43,11 @@ public class ModLoaderModContainer implements ModContainer private Class modClazz; private BaseMod mod; private boolean isTicking; - private String modSource ; + private File modSource ; private ArrayList dependencies; private ArrayList preDependencies; private ArrayList postDependencies; - public ModLoaderModContainer(Class modClazz, String modSource) + public ModLoaderModContainer(Class modClazz, File modSource) { this.modClazz = modClazz; this.modSource = modSource; @@ -334,7 +334,7 @@ public class ModLoaderModContainer implements ModContainer } @Override - public String getSource() + public File getSource() { return modSource; } @@ -475,7 +475,7 @@ public class ModLoaderModContainer implements ModContainer public String toString() { - return modSource; + return modSource.getName(); } @Override