diff --git a/fml/common/cpw/mods/fml/common/launcher/FMLServerTweaker.java b/fml/common/cpw/mods/fml/common/launcher/FMLServerTweaker.java index f6de1ea35..08403cf00 100644 --- a/fml/common/cpw/mods/fml/common/launcher/FMLServerTweaker.java +++ b/fml/common/cpw/mods/fml/common/launcher/FMLServerTweaker.java @@ -13,13 +13,11 @@ public class FMLServerTweaker extends FMLTweaker { @Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { - computeCascadedTweaks(classLoader); classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); FMLLaunchHandler.configureForServerLaunch(classLoader, this); - runAdditionalTweaks(classLoader); FMLLaunchHandler.appendCoreMods(); } } diff --git a/fml/common/cpw/mods/fml/common/launcher/FMLTweaker.java b/fml/common/cpw/mods/fml/common/launcher/FMLTweaker.java index 68ef2c3b5..8a9b5778e 100644 --- a/fml/common/cpw/mods/fml/common/launcher/FMLTweaker.java +++ b/fml/common/cpw/mods/fml/common/launcher/FMLTweaker.java @@ -22,6 +22,7 @@ import com.google.common.collect.ObjectArrays; import cpw.mods.fml.relauncher.FMLLaunchHandler; import net.minecraft.launchwrapper.ITweaker; +import net.minecraft.launchwrapper.Launch; import net.minecraft.launchwrapper.LaunchClassLoader; public class FMLTweaker implements ITweaker { @@ -30,11 +31,6 @@ public class FMLTweaker implements ITweaker { private File assetsDir; private String profile; private static URI jarLocation; - private String[] array; - private List cascadedTweaks; - private String profileName; - private OptionSet parsedOptions; - private ArgumentAcceptingOptionSpec cascadedTweaksOption; @Override public void acceptOptions(List args, File gameDir, File assetsDir, String profile) @@ -42,6 +38,7 @@ public class FMLTweaker implements ITweaker { this.gameDir = (gameDir == null ? new File(".") : gameDir); this.assetsDir = assetsDir; this.profile = profile; + this.args = args; try { jarLocation = getClass().getProtectionDomain().getCodeSource().getLocation().toURI(); @@ -51,67 +48,19 @@ public class FMLTweaker implements ITweaker { Logger.getLogger("FMLTWEAK").log(Level.SEVERE, "Missing URI information for FML tweak"); throw Throwables.propagate(e); } - - OptionParser optionParser = new OptionParser(); - cascadedTweaksOption = optionParser.accepts("cascadedTweaks", "Additional tweaks to be called by FML, implementing ITweaker").withRequiredArg().ofType(String.class).withValuesSeparatedBy(','); - ArgumentAcceptingOptionSpec profileNameOption = optionParser.accepts("profileName", "A profile name, parsed by FML to control mod loading and such").withRequiredArg().ofType(String.class); - optionParser.allowsUnrecognizedOptions(); - NonOptionArgumentSpec nonOptions = optionParser.nonOptions(); - - parsedOptions = optionParser.parse(args.toArray(new String[args.size()])); - if (parsedOptions.has(profileNameOption)) - { - profileName = profileNameOption.value(parsedOptions); - } - this.args = parsedOptions.valuesOf(nonOptions); - this.cascadedTweaks = Lists.newArrayList(); } @Override public void injectIntoClassLoader(LaunchClassLoader classLoader) { - computeCascadedTweaks(classLoader); classLoader.addTransformerExclusion("cpw.mods.fml.repackage."); classLoader.addTransformerExclusion("cpw.mods.fml.relauncher."); classLoader.addTransformerExclusion("cpw.mods.fml.common.asm.transformers."); classLoader.addClassLoaderExclusion("LZMA."); FMLLaunchHandler.configureForClientLaunch(classLoader, this); - runAdditionalTweaks(classLoader); FMLLaunchHandler.appendCoreMods(); } - void computeCascadedTweaks(LaunchClassLoader classLoader) - { - if (parsedOptions.has(cascadedTweaksOption)) - { - for (String tweaker : cascadedTweaksOption.values(parsedOptions)) - { - try - { - classLoader.addClassLoaderExclusion(tweaker.substring(0,tweaker.lastIndexOf('.'))); - Class tweakClass = (Class) Class.forName(tweaker,true,classLoader); - ITweaker additionalTweak = tweakClass.newInstance(); - cascadedTweaks.add(additionalTweak); - } - catch (Exception e) - { - Logger.getLogger("FMLTWEAK").log(Level.INFO, "Missing additional tweak class "+tweaker); - } - } - } - } - - void runAdditionalTweaks(LaunchClassLoader classLoader) - { - List fmlArgs = Lists.newArrayList(args); - fmlArgs.add("--fmlIsPresent"); - for (ITweaker tweak : cascadedTweaks) - { - tweak.acceptOptions(fmlArgs, gameDir, assetsDir, profile); - tweak.injectIntoClassLoader(classLoader); - } - } - @Override public String getLaunchTarget() { @@ -121,35 +70,27 @@ public class FMLTweaker implements ITweaker { @Override public String[] getLaunchArguments() { - String[] array = args.toArray(new String[args.size()]); + List blackboardArgs = (List) Launch.blackboard.get("ArgumentList"); - for (ITweaker tweak: cascadedTweaks) + String[] launchArgsArray = args.toArray(new String[args.size()]); + + if (gameDir != null && !blackboardArgs.contains("--gameDir")) { - array = ObjectArrays.concat(tweak.getLaunchArguments(), array, String.class); + launchArgsArray = ObjectArrays.concat(gameDir.getAbsolutePath(),launchArgsArray); + launchArgsArray = ObjectArrays.concat("--gameDir",launchArgsArray); } - if (gameDir != null && !Arrays.asList(array).contains("--gameDir")) + if (assetsDir != null && !blackboardArgs.contains("--assetsDir")) { - array = ObjectArrays.concat(gameDir.getAbsolutePath(),array); - array = ObjectArrays.concat("--gameDir",array); + launchArgsArray = ObjectArrays.concat(assetsDir.getAbsolutePath(),launchArgsArray); + launchArgsArray = ObjectArrays.concat("--assetsDir",launchArgsArray); } - - if (assetsDir != null && !Arrays.asList(array).contains("--assetsDir")) + if (!blackboardArgs.contains("--version")) { - array = ObjectArrays.concat(assetsDir.getAbsolutePath(),array); - array = ObjectArrays.concat("--assetsDir",array); + launchArgsArray = ObjectArrays.concat(profile != null ? profile : "UnknownFMLProfile",launchArgsArray); + launchArgsArray = ObjectArrays.concat("--version",launchArgsArray); } - if (profile != null && !Arrays.asList(array).contains("--version")) - { - array = ObjectArrays.concat(profile,array); - array = ObjectArrays.concat("--version",array); - } - else if (!Arrays.asList(array).contains("--version")) - { - array = ObjectArrays.concat("UnknownFMLProfile",array); - array = ObjectArrays.concat("--version",array); - } - return array; + return launchArgsArray; } public File getGameDir() @@ -162,9 +103,10 @@ public class FMLTweaker implements ITweaker { return jarLocation; } - public void injectCascadingTweak(ITweaker tweaker) + public void injectCascadingTweak(String tweakClassName) { - cascadedTweaks.add(tweaker); + List tweakClasses = (List) Launch.blackboard.get("TweakClasses"); + tweakClasses.add(tweakClassName); } } diff --git a/fml/common/cpw/mods/fml/relauncher/CoreModManager.java b/fml/common/cpw/mods/fml/relauncher/CoreModManager.java index 61be9e06c..0cf06cab1 100644 --- a/fml/common/cpw/mods/fml/relauncher/CoreModManager.java +++ b/fml/common/cpw/mods/fml/relauncher/CoreModManager.java @@ -238,9 +238,7 @@ public class CoreModManager try { classLoader.addURL(coreMod.toURI().toURL()); - Class newTweakClass = (Class) Class.forName(cascadedTweaker, true, classLoader); - ITweaker newTweak = newTweakClass.newInstance(); - CoreModManager.tweaker.injectCascadingTweak(newTweak); + CoreModManager.tweaker.injectCascadingTweak(cascadedTweaker); } catch (Exception e) {