Tweak the loader a little bit to just use file names, not fully qualified directories when referring

to mods.
This commit is contained in:
Christian Weeks 2012-04-18 14:03:30 -04:00
parent 0ec65b4b3a
commit e261ad1295
7 changed files with 22 additions and 16 deletions

View file

@ -245,9 +245,9 @@ public class FMLCommonHandler
* @param canonicalPath * @param canonicalPath
* @return * @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() { public File getMinecraftRootDirectory() {

View file

@ -12,6 +12,7 @@
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,9 +20,13 @@ public class FMLModContainer implements ModContainer
{ {
private Mod modDescriptor; private Mod modDescriptor;
private Object modInstance; 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; this.source = source;
} }
@ -106,7 +111,7 @@ public class FMLModContainer implements ModContainer
} }
@Override @Override
public String getSource() public File getSource()
{ {
return source; return source;
} }
@ -229,7 +234,7 @@ public class FMLModContainer implements ModContainer
@Override @Override
public String toString() public String toString()
{ {
return getSource(); return getSource().getName();
} }
/* (non-Javadoc) /* (non-Javadoc)

View file

@ -8,7 +8,7 @@ public interface IFMLSidedHandler
Logger getMinecraftLogger(); Logger getMinecraftLogger();
File getMinecraftRootDirectory(); File getMinecraftRootDirectory();
boolean isModLoaderMod(Class<?> clazz); boolean isModLoaderMod(Class<?> clazz);
ModContainer loadBaseModMod(Class<?> clazz, String canonicalPath); ModContainer loadBaseModMod(Class<?> clazz, File canonicalFile);
boolean isServer(); boolean isServer();
boolean isClient(); boolean isClient();
} }

View file

@ -447,7 +447,7 @@ public class Loader
else if (FMLCommonHandler.instance().isModLoaderMod(clazz)) else if (FMLCommonHandler.instance().isModLoaderMod(clazz))
{ {
log.fine(String.format("ModLoader BaseMod class %s found, loading", clazzName)); 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); mods.add(mc);
log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName)); log.fine(String.format("ModLoader BaseMod class %s loaded", clazzName));
} }

View file

@ -13,6 +13,7 @@
*/ */
package cpw.mods.fml.common; package cpw.mods.fml.common;
import java.io.File;
import java.util.List; import java.util.List;
/** /**
@ -69,10 +70,10 @@ public interface ModContainer
*/ */
boolean matches(Object mod); 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 * @return
*/ */
String getSource(); File getSource();
/** /**
* The actual mod object itself * The actual mod object itself
* @return * @return

View file

@ -185,11 +185,11 @@ public class FMLServerHandler implements IFMLSidedHandler
/** /**
* Load the supplied mod class into a mod container * 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") @SuppressWarnings("unchecked")
Class <? extends BaseMod > bmClazz = (Class <? extends BaseMod >) clazz; Class <? extends BaseMod > bmClazz = (Class <? extends BaseMod >) clazz;
return new ModLoaderModContainer(bmClazz, canonicalPath); return new ModLoaderModContainer(bmClazz, canonicalFile);
} }
/** /**

View file

@ -43,11 +43,11 @@ public class ModLoaderModContainer implements ModContainer
private Class <? extends BaseMod > modClazz; private Class <? extends BaseMod > modClazz;
private BaseMod mod; private BaseMod mod;
private boolean isTicking; private boolean isTicking;
private String modSource ; private File modSource ;
private ArrayList<String> dependencies; private ArrayList<String> dependencies;
private ArrayList<String> preDependencies; private ArrayList<String> preDependencies;
private ArrayList<String> postDependencies; private ArrayList<String> postDependencies;
public ModLoaderModContainer(Class <? extends BaseMod > modClazz, String modSource) public ModLoaderModContainer(Class <? extends BaseMod > modClazz, File modSource)
{ {
this.modClazz = modClazz; this.modClazz = modClazz;
this.modSource = modSource; this.modSource = modSource;
@ -334,7 +334,7 @@ public class ModLoaderModContainer implements ModContainer
} }
@Override @Override
public String getSource() public File getSource()
{ {
return modSource; return modSource;
} }
@ -475,7 +475,7 @@ public class ModLoaderModContainer implements ModContainer
public String toString() public String toString()
{ {
return modSource; return modSource.getName();
} }
@Override @Override