Commit 07ffd14f4ec95e8a0a4b2572d33918e8c52d4682

Authored by Mumfrey
1 parent 5cdae378

LiteLoader 1.6.4_01

.classpath
@@ -3,14 +3,14 @@ @@ -3,14 +3,14 @@
3 <classpathentry kind="src" path="java"/> 3 <classpathentry kind="src" path="java"/>
4 <classpathentry kind="src" path="res"/> 4 <classpathentry kind="src" path="res"/>
5 <classpathentry kind="src" path="debug"/> 5 <classpathentry kind="src" path="debug"/>
6 - <classpathentry combineaccessrules="false" kind="src" path="/Client"/> 6 + <classpathentry combineaccessrules="false" exported="true" kind="src" path="/Client"/>
7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
8 - <classpathentry kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/> 8 + <classpathentry exported="true" kind="lib" path="/Client/jars/libraries/org/lwjgl/lwjgl/lwjgl/2.9.0/lwjgl-2.9.0.jar"/>
9 <classpathentry kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar"/> 9 <classpathentry kind="lib" path="/Client/jars/libraries/com/google/code/gson/gson/2.2.2/gson-2.2.2.jar"/>
10 <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"/> 10 <classpathentry kind="lib" path="/Client/jars/libraries/com/google/guava/guava/14.0/guava-14.0.jar"/>
11 <classpathentry kind="lib" path="/Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar"/> 11 <classpathentry kind="lib" path="/Client/jars/libraries/commons-io/commons-io/2.4/commons-io-2.4.jar"/>
12 - <classpathentry exported="true" kind="lib" path="lib/launchwrapper-1.7.jar"/> 12 + <classpathentry exported="true" kind="lib" path="lib/launchwrapper-1.8.jar"/>
13 <classpathentry kind="lib" path="lib/jopt-simple-4.5.jar"/> 13 <classpathentry kind="lib" path="lib/jopt-simple-4.5.jar"/>
14 - <classpathentry exported="true" kind="lib" path="lib/launcher.jar"/> 14 + <classpathentry kind="lib" path="lib/launcher.jar"/>
15 <classpathentry kind="output" path="bin"/> 15 <classpathentry kind="output" path="bin"/>
16 </classpath> 16 </classpath>
java/com/mumfrey/liteloader/core/LiteLoader.java
@@ -17,6 +17,8 @@ import java.util.Map; @@ -17,6 +17,8 @@ import java.util.Map;
17 import java.util.Map.Entry; 17 import java.util.Map.Entry;
18 import java.util.Properties; 18 import java.util.Properties;
19 import java.util.TreeSet; 19 import java.util.TreeSet;
  20 +import java.util.jar.Attributes;
  21 +import java.util.jar.JarFile;
20 import java.util.logging.FileHandler; 22 import java.util.logging.FileHandler;
21 import java.util.logging.Formatter; 23 import java.util.logging.Formatter;
22 import java.util.logging.Level; 24 import java.util.logging.Level;
@@ -30,11 +32,19 @@ import javax.activity.InvalidActivityException; @@ -30,11 +32,19 @@ import javax.activity.InvalidActivityException;
30 32
31 import net.minecraft.client.ClientBrandRetriever; 33 import net.minecraft.client.ClientBrandRetriever;
32 import net.minecraft.launchwrapper.LaunchClassLoader; 34 import net.minecraft.launchwrapper.LaunchClassLoader;
33 -import net.minecraft.src.*; 35 +import net.minecraft.src.CrashReport;
  36 +import net.minecraft.src.GuiControls;
  37 +import net.minecraft.src.GuiScreen;
  38 +import net.minecraft.src.KeyBinding;
  39 +import net.minecraft.src.Minecraft;
  40 +import net.minecraft.src.NetHandler;
  41 +import net.minecraft.src.Packet1Login;
  42 +import net.minecraft.src.ResourcePack;
  43 +import net.minecraft.src.SimpleReloadableResourceManager;
34 44
35 import com.mumfrey.liteloader.*; 45 import com.mumfrey.liteloader.*;
36 -import com.mumfrey.liteloader.Tickable;  
37 import com.mumfrey.liteloader.gui.GuiControlsPaginated; 46 import com.mumfrey.liteloader.gui.GuiControlsPaginated;
  47 +import com.mumfrey.liteloader.launch.LiteLoaderTweaker;
38 import com.mumfrey.liteloader.log.LiteLoaderLogFormatter; 48 import com.mumfrey.liteloader.log.LiteLoaderLogFormatter;
39 import com.mumfrey.liteloader.permissions.PermissionsManagerClient; 49 import com.mumfrey.liteloader.permissions.PermissionsManagerClient;
40 import com.mumfrey.liteloader.util.PrivateFields; 50 import com.mumfrey.liteloader.util.PrivateFields;
@@ -44,14 +54,14 @@ import com.mumfrey.liteloader.util.PrivateFields; @@ -44,14 +54,14 @@ import com.mumfrey.liteloader.util.PrivateFields;
44 * lightweight mods 54 * lightweight mods
45 * 55 *
46 * @author Adam Mummery-Smith 56 * @author Adam Mummery-Smith
47 - * @version 1.6.4 57 + * @version 1.6.4_01
48 */ 58 */
49 public final class LiteLoader implements FilenameFilter 59 public final class LiteLoader implements FilenameFilter
50 { 60 {
51 /** 61 /**
52 * Liteloader version 62 * Liteloader version
53 */ 63 */
54 - private static final LiteLoaderVersion VERSION = LiteLoaderVersion.MC_1_6_4_R0; 64 + private static final LiteLoaderVersion VERSION = LiteLoaderVersion.MC_1_6_4_R1;
55 65
56 /** 66 /**
57 * Maximum recursion depth for mod discovery 67 * Maximum recursion depth for mod discovery
@@ -66,7 +76,7 @@ public final class LiteLoader implements FilenameFilter @@ -66,7 +76,7 @@ public final class LiteLoader implements FilenameFilter
66 /** 76 /**
67 * Logger for LiteLoader events 77 * Logger for LiteLoader events
68 */ 78 */
69 - private static Logger logger = Logger.getLogger("liteloader"); 79 + private static final Logger logger = Logger.getLogger("liteloader");
70 80
71 /** 81 /**
72 * Use stdout rather than stderr 82 * Use stdout rather than stderr
@@ -132,7 +142,7 @@ public final class LiteLoader implements FilenameFilter @@ -132,7 +142,7 @@ public final class LiteLoader implements FilenameFilter
132 /** 142 /**
133 * Reference to the Minecraft game instance 143 * Reference to the Minecraft game instance
134 */ 144 */
135 - private Minecraft minecraft = Minecraft.getMinecraft(); 145 + private Minecraft minecraft;
136 146
137 /** 147 /**
138 * File containing the properties 148 * File containing the properties
@@ -164,17 +174,17 @@ public final class LiteLoader implements FilenameFilter @@ -164,17 +174,17 @@ public final class LiteLoader implements FilenameFilter
164 /** 174 /**
165 * Classes to load, mapped by class name 175 * Classes to load, mapped by class name
166 */ 176 */
167 - private Map<String, Class<? extends LiteMod>> modsToLoad = new HashMap<String, Class<? extends LiteMod>>(); 177 + private final Map<String, Class<? extends LiteMod>> modsToLoad = new HashMap<String, Class<? extends LiteMod>>();
168 178
169 /** 179 /**
170 * Mod metadata from version file 180 * Mod metadata from version file
171 */ 181 */
172 - private Map<String, ModFile> modFiles = new HashMap<String, ModFile>(); 182 + private final Map<String, ModFile> modFiles = new HashMap<String, ModFile>();
173 183
174 /** 184 /**
175 * Registered resource packs 185 * Registered resource packs
176 */ 186 */
177 - private Map<String, ResourcePack> registeredResourcePacks = new HashMap<String, ResourcePack>(); 187 + private final Map<String, ResourcePack> registeredResourcePacks = new HashMap<String, ResourcePack>();
178 188
179 /** 189 /**
180 * List of loaded mods, for crash reporting 190 * List of loaded mods, for crash reporting
@@ -184,17 +194,17 @@ public final class LiteLoader implements FilenameFilter @@ -184,17 +194,17 @@ public final class LiteLoader implements FilenameFilter
184 /** 194 /**
185 * Global list of mods which we can loaded 195 * Global list of mods which we can loaded
186 */ 196 */
187 - private LinkedList<LiteMod> mods = new LinkedList<LiteMod>(); 197 + private final LinkedList<LiteMod> mods = new LinkedList<LiteMod>();
188 198
189 /** 199 /**
190 * Global list of mods which we have loaded 200 * Global list of mods which we have loaded
191 */ 201 */
192 - private LinkedList<LiteMod> loadedMods = new LinkedList<LiteMod>(); 202 + private final LinkedList<LiteMod> loadedMods = new LinkedList<LiteMod>();
193 203
194 /** 204 /**
195 * Mods which are loaded but disabled 205 * Mods which are loaded but disabled
196 */ 206 */
197 - private LinkedList<ModFile> disabledMods = new LinkedList<ModFile>(); 207 + private final LinkedList<ModFile> disabledMods = new LinkedList<ModFile>();
198 208
199 /** 209 /**
200 * Event manager 210 * Event manager
@@ -204,17 +214,17 @@ public final class LiteLoader implements FilenameFilter @@ -204,17 +214,17 @@ public final class LiteLoader implements FilenameFilter
204 /** 214 /**
205 * Plugin channel manager 215 * Plugin channel manager
206 */ 216 */
207 - private PluginChannels pluginChannels; 217 + private final PluginChannels pluginChannels = new PluginChannels();
208 218
209 /** 219 /**
210 * Permission Manager 220 * Permission Manager
211 */ 221 */
212 - private PermissionsManagerClient permissionsManager = PermissionsManagerClient.getInstance(); 222 + private final PermissionsManagerClient permissionsManager = PermissionsManagerClient.getInstance();
213 223
214 /** 224 /**
215 * Flag which keeps track of whether late initialisation has been done 225 * Flag which keeps track of whether late initialisation has been done
216 */ 226 */
217 - private boolean loaderStartupDone, loaderStartupComplete; 227 + private boolean preInitStarted, preInitCompleted, postInitStarted, startupComplete;
218 228
219 /** 229 /**
220 * True while initialising mods if we need to do a resource manager reload once the process is completed 230 * True while initialising mods if we need to do a resource manager reload once the process is completed
@@ -252,8 +262,31 @@ public final class LiteLoader implements FilenameFilter @@ -252,8 +262,31 @@ public final class LiteLoader implements FilenameFilter
252 */ 262 */
253 private Map<KeyBinding, Integer> storedModKeyBindings = new HashMap<KeyBinding, Integer>(); 263 private Map<KeyBinding, Integer> storedModKeyBindings = new HashMap<KeyBinding, Integer>();
254 264
  265 + /**
  266 + * True if liteloader should also search files ending with .zip
  267 + */
  268 + private boolean readZipFiles = false;
  269 +
  270 + /**
  271 + * True if the loader is allowed to load tweak classes from mod files
  272 + */
  273 + private final boolean loadTweaks;
  274 +
  275 + private boolean searchModsFolder = true;
  276 + private boolean searchProtectionDomain = true;
  277 + private boolean searchClassPath = true;
  278 +
  279 + /**
  280 + * Pre-init routine, called using reflection by the tweaker
  281 + *
  282 + * @param gameDirectory Game directory passed to the tweaker
  283 + * @param assetsDirectory Assets directory passed to the tweaker
  284 + * @param profile Launch profile name supplied with --version parameter
  285 + * @param modNameFilter List of mod names parsed from the command line
  286 + * @param classLoader LaunchClassLoader
  287 + */
255 @SuppressWarnings("unused") 288 @SuppressWarnings("unused")
256 - private static final void init(File gameDirectory, File assetsDirectory, String profile, List<String> modNameFilter, LaunchClassLoader classLoader) 289 + private static final void preInit(File gameDirectory, File assetsDirectory, String profile, List<String> modNameFilter, LaunchClassLoader classLoader, boolean loadTweaks)
257 { 290 {
258 if (LiteLoader.instance == null) 291 if (LiteLoader.instance == null)
259 { 292 {
@@ -262,8 +295,21 @@ public final class LiteLoader implements FilenameFilter @@ -262,8 +295,21 @@ public final class LiteLoader implements FilenameFilter
262 LiteLoader.profile = profile; 295 LiteLoader.profile = profile;
263 LiteLoader.classLoader = classLoader; 296 LiteLoader.classLoader = classLoader;
264 297
265 - LiteLoader.instance = new LiteLoader(profile, modNameFilter);  
266 - LiteLoader.instance.initLoader(); 298 + LiteLoader.instance = new LiteLoader(profile, modNameFilter, loadTweaks);
  299 + LiteLoader.instance.onPreInit();
  300 + }
  301 + }
  302 +
  303 + /**
  304 + * Post-init routine, initialises and loads mods enumerated in preInit
  305 + */
  306 + @SuppressWarnings("unused")
  307 + private static final void postInit()
  308 + {
  309 + if (LiteLoader.instance != null)
  310 + {
  311 + final Minecraft minecraft = Minecraft.getMinecraft();
  312 + LiteLoader.instance.onPostInit(minecraft);
267 } 313 }
268 } 314 }
269 315
@@ -272,15 +318,18 @@ public final class LiteLoader implements FilenameFilter @@ -272,15 +318,18 @@ public final class LiteLoader implements FilenameFilter
272 * @param profile 318 * @param profile
273 * @param modNameFilter 319 * @param modNameFilter
274 */ 320 */
275 - private LiteLoader(String profile, List<String> modNameFilter) 321 + private LiteLoader(String profile, List<String> modNameFilter, boolean loadTweaks)
276 { 322 {
  323 + // This valus is passed through from the tweaker, if we are being called pre-startup then this will be true
  324 + // since we are starting up early enough to load tweaks. At the moment we can't do this because if we start
  325 + // before a name transformer then all hell breaks loose later on. Need to split the mod enumeration into a separate
  326 + // class before this is likely to work as intended.
  327 + this.loadTweaks = loadTweaks;
  328 +
277 this.initPaths(); 329 this.initPaths();
278 330
279 this.enabledModsList = EnabledModsList.createFrom(this.enabledModsFile); 331 this.enabledModsList = EnabledModsList.createFrom(this.enabledModsFile);
280 this.enabledModsList.processModsList(profile, modNameFilter); 332 this.enabledModsList.processModsList(profile, modNameFilter);
281 -  
282 - this.pluginChannels = new PluginChannels(this);  
283 - this.events = new Events(this, this.minecraft, this.pluginChannels);  
284 } 333 }
285 334
286 /** 335 /**
@@ -322,60 +371,62 @@ public final class LiteLoader implements FilenameFilter @@ -322,60 +371,62 @@ public final class LiteLoader implements FilenameFilter
322 /** 371 /**
323 * Loader initialisation 372 * Loader initialisation
324 */ 373 */
325 - private void initLoader() 374 + private void onPreInit()
326 { 375 {
327 - if (this.loaderStartupDone) return;  
328 - this.loaderStartupDone = true; 376 + if (this.preInitStarted) return;
  377 + this.preInitStarted = true;
329 378
330 // Set up loader, initialises any reflection methods needed 379 // Set up loader, initialises any reflection methods needed
331 if (this.prepareLoader()) 380 if (this.prepareLoader())
332 { 381 {
333 - LiteLoader.getLogger().info(String.format("LiteLoader %s starting up...", VERSION.getLoaderVersion())); 382 + LiteLoader.logInfo("LiteLoader %s starting up...", VERSION.getLoaderVersion());
334 383
335 // Print the branding version if any was provided 384 // Print the branding version if any was provided
336 if (this.branding != null) 385 if (this.branding != null)
337 { 386 {
338 - LiteLoader.getLogger().info(String.format("Active Pack: %s", this.branding)); 387 + LiteLoader.logInfo("Active Pack: %s", this.branding);
339 } 388 }
340 389
341 - LiteLoader.getLogger().info(String.format("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase())); 390 + LiteLoader.logInfo("Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase());
342 391
343 - boolean searchMods = this.localProperties.getProperty("search.mods", "true").equalsIgnoreCase("true");  
344 - boolean searchProtectionDomain = this.localProperties.getProperty("search.jar", "true").equalsIgnoreCase("true");  
345 - boolean searchClassPath = this.localProperties.getProperty("search.classpath", "true").equalsIgnoreCase("true");  
346 -  
347 - if (!searchMods && !searchProtectionDomain && !searchClassPath)  
348 - {  
349 - LiteLoader.getLogger().warning("Invalid configuration, no search locations defined. Enabling all search locations.");  
350 -  
351 - this.localProperties.setProperty("search.mods", "true");  
352 - this.localProperties.setProperty("search.jar", "true");  
353 - this.localProperties.setProperty("search.classpath", "true");  
354 -  
355 - searchMods = true;  
356 - searchProtectionDomain = true;  
357 - searchClassPath = true;  
358 - } 392 + // Read the discovery settings from the properties
  393 + this.prepareDiscoverySettings();
359 394
360 // Examines the class path and mods folder and locates loadable mods 395 // Examines the class path and mods folder and locates loadable mods
361 - this.prepareMods(searchMods, searchProtectionDomain, searchClassPath);  
362 -  
363 - // Spawn mod instances  
364 - this.loadMods();  
365 -  
366 - // Initialises enumerated mods  
367 - this.initMods();  
368 -  
369 - // Initialises the required hooks for loaded mods  
370 - this.events.initHooks();  
371 - this.loaderStartupComplete = true;  
372 -  
373 - this.writeProperties();  
374 - this.enabledModsList.saveTo(this.enabledModsFile);  
375 - 396 + this.discoverMods();
  397 +
  398 + // Set the loader branding in ClientBrandRetriever using reflection
376 this.setBranding("LiteLoader"); 399 this.setBranding("LiteLoader");
  400 +
  401 + LiteLoader.logInfo("LiteLoader PreInit completed");
  402 + this.preInitCompleted = true;
377 } 403 }
378 } 404 }
  405 +
  406 + private void onPostInit(Minecraft minecraft)
  407 + {
  408 + if (!this.preInitCompleted || this.postInitStarted) return;
  409 + this.postInitStarted = true;
  410 +
  411 + // Cache local minecraft reference
  412 + this.minecraft = minecraft;
  413 +
  414 + // Create the event broker
  415 + this.events = new Events(this, this.minecraft, this.pluginChannels);
  416 +
  417 + // Spawn mod instances
  418 + this.loadMods();
  419 +
  420 + // Initialises enumerated mods
  421 + this.initMods();
  422 +
  423 + // Initialises the required hooks for loaded mods
  424 + this.events.initHooks();
  425 + this.startupComplete = true;
  426 +
  427 + this.enabledModsList.saveTo(this.enabledModsFile);
  428 + this.writeProperties();
  429 + }
379 430
380 /** 431 /**
381 * Set up reflection methods required by the loader 432 * Set up reflection methods required by the loader
@@ -424,16 +475,16 @@ public final class LiteLoader implements FilenameFilter @@ -424,16 +475,16 @@ public final class LiteLoader implements FilenameFilter
424 { 475 {
425 Formatter logFormatter = new LiteLoaderLogFormatter(); 476 Formatter logFormatter = new LiteLoaderLogFormatter();
426 477
427 - LiteLoader.getLogger().setUseParentHandlers(false); 478 + LiteLoader.logger.setUseParentHandlers(false);
428 LiteLoader.useStdOut = System.getProperty("liteloader.log", "stderr").equalsIgnoreCase("stdout") || this.localProperties.getProperty("log", "stderr").equalsIgnoreCase("stdout"); 479 LiteLoader.useStdOut = System.getProperty("liteloader.log", "stderr").equalsIgnoreCase("stdout") || this.localProperties.getProperty("log", "stderr").equalsIgnoreCase("stdout");
429 480
430 StreamHandler consoleHandler = useStdOut ? new com.mumfrey.liteloader.util.log.ConsoleHandler() : new java.util.logging.ConsoleHandler(); 481 StreamHandler consoleHandler = useStdOut ? new com.mumfrey.liteloader.util.log.ConsoleHandler() : new java.util.logging.ConsoleHandler();
431 consoleHandler.setFormatter(logFormatter); 482 consoleHandler.setFormatter(logFormatter);
432 - LiteLoader.getLogger().addHandler(consoleHandler); 483 + LiteLoader.logger.addHandler(consoleHandler);
433 484
434 FileHandler logFileHandler = new FileHandler(this.logFile.getAbsolutePath()); 485 FileHandler logFileHandler = new FileHandler(this.logFile.getAbsolutePath());
435 logFileHandler.setFormatter(logFormatter); 486 logFileHandler.setFormatter(logFormatter);
436 - LiteLoader.getLogger().addHandler(logFileHandler); 487 + LiteLoader.logger.addHandler(logFileHandler);
437 } 488 }
438 489
439 /** 490 /**
@@ -481,7 +532,32 @@ public final class LiteLoader implements FilenameFilter @@ -481,7 +532,32 @@ public final class LiteLoader implements FilenameFilter
481 catch (Exception ex) {} 532 catch (Exception ex) {}
482 } 533 }
483 } 534 }
484 - 535 +
  536 + /**
  537 + *
  538 + */
  539 + public void prepareDiscoverySettings()
  540 + {
  541 + this.readZipFiles = this.localProperties.getProperty("search.zips", "false").equalsIgnoreCase("true");
  542 + this.searchModsFolder = this.localProperties.getProperty("search.mods", "true").equalsIgnoreCase("true");
  543 + this.searchProtectionDomain = this.localProperties.getProperty("search.jar", "true").equalsIgnoreCase("true");
  544 + this.searchClassPath = this.localProperties.getProperty("search.classpath", "true").equalsIgnoreCase("true");
  545 +
  546 + if (!this.searchModsFolder && !this.searchProtectionDomain && !this.searchClassPath)
  547 + {
  548 + LiteLoader.logWarning("Invalid configuration, no search locations defined. Enabling all search locations.");
  549 +
  550 + this.searchModsFolder = true;
  551 + this.searchProtectionDomain = true;
  552 + this.searchClassPath = true;
  553 + }
  554 +
  555 + this.localProperties.setProperty("search.zips", String.valueOf(this.readZipFiles));
  556 + this.localProperties.setProperty("search.mods", String.valueOf(this.searchModsFolder));
  557 + this.localProperties.setProperty("search.jar", String.valueOf(this.searchProtectionDomain));
  558 + this.localProperties.setProperty("search.classpath", String.valueOf(this.searchClassPath));
  559 + }
  560 +
485 /** 561 /**
486 * Get the properties stream either from the jar or from the properties file 562 * Get the properties stream either from the jar or from the properties file
487 * in the minecraft folder 563 * in the minecraft folder
@@ -582,6 +658,16 @@ public final class LiteLoader implements FilenameFilter @@ -582,6 +658,16 @@ public final class LiteLoader implements FilenameFilter
582 } 658 }
583 659
584 /** 660 /**
  661 + * Get the tweak system classloader
  662 + *
  663 + * @return
  664 + */
  665 + public static LaunchClassLoader getClassLoader()
  666 + {
  667 + return LiteLoader.classLoader;
  668 + }
  669 +
  670 + /**
585 * Get the output stream which we are using for console output 671 * Get the output stream which we are using for console output
586 * 672 *
587 * @return 673 * @return
@@ -781,7 +867,7 @@ public final class LiteLoader implements FilenameFilter @@ -781,7 +867,7 @@ public final class LiteLoader implements FilenameFilter
781 @SuppressWarnings("unchecked") 867 @SuppressWarnings("unchecked")
782 public <T extends LiteMod> T getMod(String modName) throws InvalidActivityException, IllegalArgumentException 868 public <T extends LiteMod> T getMod(String modName) throws InvalidActivityException, IllegalArgumentException
783 { 869 {
784 - if (!this.loaderStartupComplete) 870 + if (!this.startupComplete)
785 { 871 {
786 throw new InvalidActivityException("Attempted to get a reference to a mod before loader startup is complete"); 872 throw new InvalidActivityException("Attempted to get a reference to a mod before loader startup is complete");
787 } 873 }
@@ -810,7 +896,7 @@ public final class LiteLoader implements FilenameFilter @@ -810,7 +896,7 @@ public final class LiteLoader implements FilenameFilter
810 @SuppressWarnings("unchecked") 896 @SuppressWarnings("unchecked")
811 public <T extends LiteMod> T getMod(Class<T> modClass) 897 public <T extends LiteMod> T getMod(Class<T> modClass)
812 { 898 {
813 - if (!this.loaderStartupComplete) 899 + if (!this.startupComplete)
814 { 900 {
815 throw new RuntimeException("Attempted to get a reference to a mod before loader startup is complete"); 901 throw new RuntimeException("Attempted to get a reference to a mod before loader startup is complete");
816 } 902 }
@@ -832,7 +918,7 @@ public final class LiteLoader implements FilenameFilter @@ -832,7 +918,7 @@ public final class LiteLoader implements FilenameFilter
832 */ 918 */
833 public boolean isModInstalled(String modName) 919 public boolean isModInstalled(String modName)
834 { 920 {
835 - if (!this.loaderStartupComplete || modName == null) return false; 921 + if (!this.startupComplete || modName == null) return false;
836 922
837 for (LiteMod mod : this.mods) 923 for (LiteMod mod : this.mods)
838 { 924 {
@@ -911,40 +997,40 @@ public final class LiteLoader implements FilenameFilter @@ -911,40 +997,40 @@ public final class LiteLoader implements FilenameFilter
911 * Enumerate the java class path and "mods" folder to find mod classes, then 997 * Enumerate the java class path and "mods" folder to find mod classes, then
912 * load the classes 998 * load the classes
913 */ 999 */
914 - private void prepareMods(boolean searchMods, boolean searchProtectionDomain, boolean searchClassPath) 1000 + private void discoverMods()
915 { 1001 {
916 // List of mod files in the "mods" folder 1002 // List of mod files in the "mods" folder
917 List<ModFile> modFiles = new LinkedList<ModFile>(); 1003 List<ModFile> modFiles = new LinkedList<ModFile>();
918 1004
919 - if (searchMods) 1005 + if (this.searchModsFolder)
920 { 1006 {
921 // Find and enumerate the "mods" folder 1007 // Find and enumerate the "mods" folder
922 - File modFolder = this.getModsFolder(); 1008 + File modFolder = LiteLoader.getModsFolder();
923 if (modFolder.exists() && modFolder.isDirectory()) 1009 if (modFolder.exists() && modFolder.isDirectory())
924 { 1010 {
925 - LiteLoader.getLogger().info("Mods folder found, searching " + modFolder.getPath()); 1011 + LiteLoader.logInfo("Mods folder found, searching %s", modFolder.getPath());
926 this.findModFiles(modFolder, modFiles); 1012 this.findModFiles(modFolder, modFiles);
927 - LiteLoader.getLogger().info("Found " + modFiles.size() + " mod file(s)"); 1013 + LiteLoader.logInfo("Found %d mod file(s)", modFiles.size());
928 } 1014 }
929 } 1015 }
930 1016
931 try 1017 try
932 { 1018 {
933 - LiteLoader.getLogger().info("Enumerating class path..."); 1019 + LiteLoader.logInfo("Enumerating class path...");
934 1020
935 String classPath = System.getProperty("java.class.path"); 1021 String classPath = System.getProperty("java.class.path");
936 String classPathSeparator = System.getProperty("path.separator"); 1022 String classPathSeparator = System.getProperty("path.separator");
937 String[] classPathEntries = classPath.split(classPathSeparator); 1023 String[] classPathEntries = classPath.split(classPathSeparator);
938 1024
939 - LiteLoader.getLogger().info(String.format("Class path separator=\"%s\"", classPathSeparator));  
940 - LiteLoader.getLogger().info(String.format("Class path entries=(\n classpathEntry=%s\n)", classPath.replace(classPathSeparator, "\n classpathEntry="))); 1025 + LiteLoader.logInfo("Class path separator=\"%s\"", classPathSeparator);
  1026 + LiteLoader.logInfo("Class path entries=(\n classpathEntry=%s\n)", classPath.replace(classPathSeparator, "\n classpathEntry="));
941 1027
942 - if (searchProtectionDomain || searchClassPath)  
943 - getLogger().info("Discovering mods on class path..."); 1028 + if (this.searchProtectionDomain || this.searchClassPath)
  1029 + LiteLoader.logInfo("Discovering mods on class path...");
944 1030
945 - this.findModClasses(modFiles, searchProtectionDomain, searchClassPath, classPathEntries); 1031 + this.findModClasses(modFiles, classPathEntries);
946 1032
947 - LiteLoader.getLogger().info("Mod class discovery completed"); 1033 + LiteLoader.logInfo("Mod class discovery completed");
948 } 1034 }
949 catch (Throwable th) 1035 catch (Throwable th)
950 { 1036 {
@@ -998,7 +1084,7 @@ public final class LiteLoader implements FilenameFilter @@ -998,7 +1084,7 @@ public final class LiteLoader implements FilenameFilter
998 } 1084 }
999 catch (Exception ex) 1085 catch (Exception ex)
1000 { 1086 {
1001 - LiteLoader.getLogger().warning("Error reading version data from " + modFile.getName()); 1087 + LiteLoader.logWarning("Error reading version data from %s", modFile.getName());
1002 } 1088 }
1003 finally 1089 finally
1004 { 1090 {
@@ -1017,7 +1103,7 @@ public final class LiteLoader implements FilenameFilter @@ -1017,7 +1103,7 @@ public final class LiteLoader implements FilenameFilter
1017 { 1103 {
1018 // if (!modFileInfo.isJson()) 1104 // if (!modFileInfo.isJson())
1019 // { 1105 // {
1020 -// logger.warning("Missing or invalid litemod.json reading mod file: " + modFile.getAbsolutePath()); 1106 +// LiteLoader.logWarning("Missing or invalid litemod.json reading mod file: %s", modFile.getAbsolutePath());
1021 // } 1107 // }
1022 1108
1023 if (!versionOrderingSets.containsKey(modFileInfo.getName())) 1109 if (!versionOrderingSets.containsKey(modFileInfo.getName()))
@@ -1025,11 +1111,12 @@ public final class LiteLoader implements FilenameFilter @@ -1025,11 +1111,12 @@ public final class LiteLoader implements FilenameFilter
1025 versionOrderingSets.put(modFileInfo.getModName(), new TreeSet<ModFile>()); 1111 versionOrderingSets.put(modFileInfo.getModName(), new TreeSet<ModFile>());
1026 } 1112 }
1027 1113
  1114 + LiteLoader.logInfo("Considering valid mod file: %s", modFileInfo.getAbsolutePath());
1028 versionOrderingSets.get(modFileInfo.getModName()).add(modFileInfo); 1115 versionOrderingSets.get(modFileInfo.getModName()).add(modFileInfo);
1029 } 1116 }
1030 else 1117 else
1031 { 1118 {
1032 - LiteLoader.getLogger().info("Not adding invalid or outdated mod file: " + modFile.getAbsolutePath()); 1119 + LiteLoader.logInfo("Not adding invalid or outdated mod file: %s", modFile.getAbsolutePath());
1033 } 1120 }
1034 } 1121 }
1035 } 1122 }
@@ -1039,7 +1126,7 @@ public final class LiteLoader implements FilenameFilter @@ -1039,7 +1126,7 @@ public final class LiteLoader implements FilenameFilter
1039 ZipEntry legacyVersion = modZip.getEntry("version.txt"); 1126 ZipEntry legacyVersion = modZip.getEntry("version.txt");
1040 if (legacyVersion != null) 1127 if (legacyVersion != null)
1041 { 1128 {
1042 - LiteLoader.getLogger().warning("version.txt is no longer supported, ignoring outdated mod file: " + modFile.getAbsolutePath()); 1129 + LiteLoader.logWarning("version.txt is no longer supported, ignoring outdated mod file: %s", modFile.getAbsolutePath());
1043 } 1130 }
1044 } 1131 }
1045 1132
@@ -1048,7 +1135,7 @@ public final class LiteLoader implements FilenameFilter @@ -1048,7 +1135,7 @@ public final class LiteLoader implements FilenameFilter
1048 catch (Exception ex) 1135 catch (Exception ex)
1049 { 1136 {
1050 ex.printStackTrace(System.err); 1137 ex.printStackTrace(System.err);
1051 - LiteLoader.getLogger().warning("Error enumerating '" + modFile.getAbsolutePath() + "': Invalid zip file or error reading file"); 1138 + LiteLoader.logInfo("Error enumerating '%s': Invalid zip file or error reading file", modFile.getAbsolutePath());
1052 } 1139 }
1053 } 1140 }
1054 1141
@@ -1059,16 +1146,31 @@ public final class LiteLoader implements FilenameFilter @@ -1059,16 +1146,31 @@ public final class LiteLoader implements FilenameFilter
1059 1146
1060 try 1147 try
1061 { 1148 {
  1149 + LiteLoader.logInfo("Adding newest valid mod file '%s' at revision %.4f: ", newestVersion.getAbsolutePath(), newestVersion.getRevision());
  1150 +
1062 LiteLoader.classLoader.addURL(newestVersion.toURI().toURL()); 1151 LiteLoader.classLoader.addURL(newestVersion.toURI().toURL());
1063 modFiles.add(newestVersion); 1152 modFiles.add(newestVersion);
1064 } 1153 }
1065 catch (Exception ex) 1154 catch (Exception ex)
1066 { 1155 {
1067 - LiteLoader.getLogger().warning("Error injecting '" + newestVersion.getAbsolutePath() + "' into classPath. The mod will not be loaded"); 1156 + LiteLoader.logWarning("Error injecting '%s' into classPath. The mod will not be loaded", newestVersion.getAbsolutePath());
  1157 + }
  1158 +
  1159 + // Tweak load functionality, currently not used
  1160 + if (this.loadTweaks)
  1161 + {
  1162 + try
  1163 + {
  1164 + this.addTweaksFrom(newestVersion);
  1165 + }
  1166 + catch (Throwable th)
  1167 + {
  1168 + LiteLoader.logWarning("Error adding tweaks from '%s'", newestVersion.getAbsolutePath());
  1169 + }
1068 } 1170 }
1069 } 1171 }
1070 } 1172 }
1071 - 1173 +
1072 /* 1174 /*
1073 * (non-Javadoc) 1175 * (non-Javadoc)
1074 * 1176 *
@@ -1077,16 +1179,71 @@ public final class LiteLoader implements FilenameFilter @@ -1077,16 +1179,71 @@ public final class LiteLoader implements FilenameFilter
1077 @Override 1179 @Override
1078 public boolean accept(File dir, String fileName) 1180 public boolean accept(File dir, String fileName)
1079 { 1181 {
1080 - return fileName.toLowerCase().endsWith(".litemod"); 1182 + fileName = fileName.toLowerCase();
  1183 + return fileName.endsWith(".litemod") || (this.readZipFiles && (fileName.endsWith(".zip") || fileName.endsWith(".jar")));
  1184 + }
  1185 +
  1186 + /**
  1187 + * @param modFile
  1188 + * @throws IOException
  1189 + */
  1190 + private void addTweaksFrom(ModFile modFile)
  1191 + {
  1192 + JarFile jar = null;
  1193 +
  1194 + LiteLoader.logInfo("Adding tweaks from file '%s'", modFile.getName());
  1195 + try
  1196 + {
  1197 + jar = new JarFile(modFile);
  1198 + Attributes manifestAttributes = jar.getManifest().getMainAttributes();
  1199 +
  1200 + String tweakClass = manifestAttributes.getValue("TweakClass");
  1201 + if (tweakClass != null)
  1202 + {
  1203 + LiteLoader.logInfo("Mod file '%s' provides tweakClass '%s', adding to Launch queue", modFile.getName(), tweakClass);
  1204 +
  1205 + if (LiteLoaderTweaker.addTweaker(modFile.toURI().toURL(), tweakClass))
  1206 + {
  1207 + LiteLoader.logInfo("tweakClass '%s' was successfully added", tweakClass);
  1208 + }
  1209 + }
  1210 +
  1211 + String classPath = manifestAttributes.getValue("Class-Path");
  1212 + if (classPath != null)
  1213 + {
  1214 + String[] classPathEntries = classPath.split(" ");
  1215 + for (String classPathEntry : classPathEntries)
  1216 + {
  1217 + File classPathJar = new File(LiteLoader.gameDirectory, classPathEntry);
  1218 + URL jarUrl = classPathJar.toURI().toURL();
  1219 +
  1220 + LiteLoader.logInfo("Adding Class-Path entry: %s", classPathEntry);
  1221 + LiteLoaderTweaker.addURLToParentClassLoader(jarUrl);
  1222 + LiteLoader.classLoader.addURL(jarUrl);
  1223 + }
  1224 + }
  1225 + }
  1226 + catch (Exception ex)
  1227 + {
  1228 + LiteLoader.logWarning("Error parsing tweak class manifest entry in '%s'", modFile.getAbsolutePath());
  1229 + }
  1230 + finally
  1231 + {
  1232 + try
  1233 + {
  1234 + if (jar != null) jar.close();
  1235 + }
  1236 + catch (IOException ex) {}
  1237 + }
1081 } 1238 }
1082 1239
1083 /** 1240 /**
1084 * Find mod classes in the class path and enumerated mod files list 1241 * Find mod classes in the class path and enumerated mod files list
1085 * @param classPathEntries Java class path split into string entries 1242 * @param classPathEntries Java class path split into string entries
1086 */ 1243 */
1087 - private void findModClasses(List<ModFile> modFiles, boolean searchProtectionDomain, boolean searchClassPath, String[] classPathEntries) 1244 + private void findModClasses(List<ModFile> modFiles, String[] classPathEntries)
1088 { 1245 {
1089 - if (searchProtectionDomain) 1246 + if (this.searchProtectionDomain)
1090 { 1247 {
1091 try 1248 try
1092 { 1249 {
@@ -1094,11 +1251,11 @@ public final class LiteLoader implements FilenameFilter @@ -1094,11 +1251,11 @@ public final class LiteLoader implements FilenameFilter
1094 } 1251 }
1095 catch (Throwable th) 1252 catch (Throwable th)
1096 { 1253 {
1097 - LiteLoader.getLogger().warning("Error loading from local class path: " + th.getMessage()); 1254 + LiteLoader.logWarning("Error loading from local class path: %s", th.getMessage());
1098 } 1255 }
1099 } 1256 }
1100 1257
1101 - if (searchClassPath) 1258 + if (this.searchClassPath)
1102 { 1259 {
1103 // Search through the class path and find mod classes 1260 // Search through the class path and find mod classes
1104 this.searchClassPath(classPathEntries); 1261 this.searchClassPath(classPathEntries);
@@ -1117,7 +1274,7 @@ public final class LiteLoader implements FilenameFilter @@ -1117,7 +1274,7 @@ public final class LiteLoader implements FilenameFilter
1117 @SuppressWarnings("unchecked") 1274 @SuppressWarnings("unchecked")
1118 private void searchProtectionDomain() throws MalformedURLException, URISyntaxException, UnsupportedEncodingException 1275 private void searchProtectionDomain() throws MalformedURLException, URISyntaxException, UnsupportedEncodingException
1119 { 1276 {
1120 - LiteLoader.getLogger().info("Searching protection domain code source..."); 1277 + LiteLoader.logInfo("Searching protection domain code source...");
1121 1278
1122 File packagePath = null; 1279 File packagePath = null;
1123 1280
@@ -1146,20 +1303,20 @@ public final class LiteLoader implements FilenameFilter @@ -1146,20 +1303,20 @@ public final class LiteLoader implements FilenameFilter
1146 1303
1147 if (packagePath != null) 1304 if (packagePath != null)
1148 { 1305 {
1149 - LinkedList<Class<?>> modClasses = getSubclassesFor(packagePath, Minecraft.class.getClassLoader(), LiteMod.class, "LiteMod"); 1306 + LinkedList<Class<?>> modClasses = getSubclassesFor(packagePath, LiteLoader.classLoader, LiteMod.class, "LiteMod");
1150 1307
1151 for (Class<?> mod : modClasses) 1308 for (Class<?> mod : modClasses)
1152 { 1309 {
1153 if (this.modsToLoad.containsKey(mod.getSimpleName())) 1310 if (this.modsToLoad.containsKey(mod.getSimpleName()))
1154 { 1311 {
1155 - LiteLoader.getLogger().warning("Mod name collision for mod with class '" + mod.getSimpleName() + "', maybe you have more than one copy?"); 1312 + LiteLoader.logWarning("Mod name collision for mod with class '%s', maybe you have more than one copy?", mod.getSimpleName());
1156 } 1313 }
1157 1314
1158 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod); 1315 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod);
1159 } 1316 }
1160 1317
1161 if (modClasses.size() > 0) 1318 if (modClasses.size() > 0)
1162 - LiteLoader.getLogger().info(String.format("Found %s potential matches", modClasses.size())); 1319 + LiteLoader.logInfo("Found %s potential matches", modClasses.size());
1163 } 1320 }
1164 } 1321 }
1165 1322
@@ -1172,16 +1329,16 @@ public final class LiteLoader implements FilenameFilter @@ -1172,16 +1329,16 @@ public final class LiteLoader implements FilenameFilter
1172 { 1329 {
1173 for (String classPathPart : classPathEntries) 1330 for (String classPathPart : classPathEntries)
1174 { 1331 {
1175 - LiteLoader.getLogger().info(String.format("Searching %s...", classPathPart)); 1332 + LiteLoader.logInfo("Searching %s...", classPathPart);
1176 1333
1177 File packagePath = new File(classPathPart); 1334 File packagePath = new File(classPathPart);
1178 - LinkedList<Class<?>> modClasses = getSubclassesFor(packagePath, Minecraft.class.getClassLoader(), LiteMod.class, "LiteMod"); 1335 + LinkedList<Class<?>> modClasses = getSubclassesFor(packagePath, LiteLoader.classLoader, LiteMod.class, "LiteMod");
1179 1336
1180 for (Class<?> mod : modClasses) 1337 for (Class<?> mod : modClasses)
1181 { 1338 {
1182 if (this.modsToLoad.containsKey(mod.getSimpleName())) 1339 if (this.modsToLoad.containsKey(mod.getSimpleName()))
1183 { 1340 {
1184 - LiteLoader.getLogger().warning("Mod name collision for mod with class '" + mod.getSimpleName() + "', maybe you have more than one copy?"); 1341 + LiteLoader.logWarning("Mod name collision for mod with class '%s', maybe you have more than one copy?", mod.getSimpleName());
1185 } 1342 }
1186 1343
1187 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod); 1344 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod);
@@ -1189,7 +1346,7 @@ public final class LiteLoader implements FilenameFilter @@ -1189,7 +1346,7 @@ public final class LiteLoader implements FilenameFilter
1189 } 1346 }
1190 1347
1191 if (modClasses.size() > 0) 1348 if (modClasses.size() > 0)
1192 - LiteLoader.getLogger().info(String.format("Found %s potential matches", modClasses.size())); 1349 + LiteLoader.logInfo("Found %s potential matches", modClasses.size());
1193 } 1350 }
1194 } 1351 }
1195 1352
@@ -1202,15 +1359,15 @@ public final class LiteLoader implements FilenameFilter @@ -1202,15 +1359,15 @@ public final class LiteLoader implements FilenameFilter
1202 { 1359 {
1203 for (ModFile modFile : modFiles) 1360 for (ModFile modFile : modFiles)
1204 { 1361 {
1205 - LiteLoader.getLogger().info(String.format("Searching %s...", modFile.getAbsolutePath())); 1362 + LiteLoader.logInfo("Searching %s...", modFile.getAbsolutePath());
1206 1363
1207 - LinkedList<Class<?>> modClasses = LiteLoader.getSubclassesFor(modFile, Minecraft.class.getClassLoader(), LiteMod.class, "LiteMod"); 1364 + LinkedList<Class<?>> modClasses = LiteLoader.getSubclassesFor(modFile, LiteLoader.classLoader, LiteMod.class, "LiteMod");
1208 1365
1209 for (Class<?> mod : modClasses) 1366 for (Class<?> mod : modClasses)
1210 { 1367 {
1211 if (this.modsToLoad.containsKey(mod.getSimpleName())) 1368 if (this.modsToLoad.containsKey(mod.getSimpleName()))
1212 { 1369 {
1213 - LiteLoader.getLogger().warning("Mod name collision for mod with class '" + mod.getSimpleName() + "', maybe you have more than one copy?"); 1370 + LiteLoader.logWarning("Mod name collision for mod with class '%s', maybe you have more than one copy?", mod.getSimpleName());
1214 } 1371 }
1215 1372
1216 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod); 1373 this.modsToLoad.put(mod.getSimpleName(), (Class<? extends LiteMod>)mod);
@@ -1218,7 +1375,7 @@ public final class LiteLoader implements FilenameFilter @@ -1218,7 +1375,7 @@ public final class LiteLoader implements FilenameFilter
1218 } 1375 }
1219 1376
1220 if (modClasses.size() > 0) 1377 if (modClasses.size() > 0)
1221 - LiteLoader.getLogger().info(String.format("Found %s potential matches", modClasses.size())); 1378 + LiteLoader.logInfo("Found %s potential matches", modClasses.size());
1222 } 1379 }
1223 } 1380 }
1224 1381
@@ -1231,29 +1388,31 @@ public final class LiteLoader implements FilenameFilter @@ -1231,29 +1388,31 @@ public final class LiteLoader implements FilenameFilter
1231 { 1388 {
1232 if (this.modsToLoad == null) 1389 if (this.modsToLoad == null)
1233 { 1390 {
1234 - LiteLoader.getLogger().info("Mod class discovery failed. Not loading any mods!"); 1391 + LiteLoader.logInfo("Mod class discovery failed. Not loading any mods!");
1235 return; 1392 return;
1236 } 1393 }
1237 1394
1238 - LiteLoader.getLogger().info("Discovered " + this.modsToLoad.size() + " total mod(s)"); 1395 + LiteLoader.logInfo("Discovered %d total mod(s)", this.modsToLoad.size());
1239 1396
1240 this.pendingResourceReload = false; 1397 this.pendingResourceReload = false;
1241 this.soundManagerReloadInhibitor = new SoundManagerReloadInhibitor((SimpleReloadableResourceManager)this.minecraft.getResourceManager(), this.minecraft.sndManager); 1398 this.soundManagerReloadInhibitor = new SoundManagerReloadInhibitor((SimpleReloadableResourceManager)this.minecraft.getResourceManager(), this.minecraft.sndManager);
1242 -// if (this.inhibitSoundManagerReload) this.soundManagerReloadInhibitor.inhibit(); 1399 + if (this.inhibitSoundManagerReload) this.soundManagerReloadInhibitor.inhibit();
1243 1400
1244 for (Class<? extends LiteMod> mod : this.modsToLoad.values()) 1401 for (Class<? extends LiteMod> mod : this.modsToLoad.values())
1245 { 1402 {
1246 try 1403 try
1247 { 1404 {
1248 String metaName = this.getModMetaName(mod); 1405 String metaName = this.getModMetaName(mod);
1249 - if (metaName == null || this.enabledModsList.isEnabled(this.profile, metaName)) 1406 + if (metaName == null || this.enabledModsList.isEnabled(LiteLoader.profile, metaName))
1250 { 1407 {
1251 - LiteLoader.getLogger().info(String.format("Loading mod from %s", mod.getName())); 1408 + LiteLoader.logInfo("Loading mod from %s", mod.getName());
1252 1409
1253 LiteMod newMod = mod.newInstance(); 1410 LiteMod newMod = mod.newInstance();
1254 1411
1255 this.mods.add(newMod); 1412 this.mods.add(newMod);
1256 - LiteLoader.getLogger().info(String.format("Successfully added mod %s version %s", newMod.getName(), newMod.getVersion())); 1413 + String modName = newMod.getName();
  1414 + if (modName == null && metaName != null) modName = metaName;
  1415 + LiteLoader.logInfo("Successfully added mod %s version %s", modName, newMod.getVersion());
1257 1416
1258 // Get the mod file and register it as a resource pack if it exists 1417 // Get the mod file and register it as a resource pack if it exists
1259 ModFile modFile = this.getModFile(mod); 1418 ModFile modFile = this.getModFile(mod);
@@ -1261,26 +1420,25 @@ public final class LiteLoader implements FilenameFilter @@ -1261,26 +1420,25 @@ public final class LiteLoader implements FilenameFilter
1261 { 1420 {
1262 this.disabledMods.remove(modFile); 1421 this.disabledMods.remove(modFile);
1263 1422
1264 - if (modFile.registerAsResourcePack(newMod.getName())) 1423 + if (modName != null && modFile.registerAsResourcePack(modName))
1265 { 1424 {
1266 - LiteLoader.getLogger().info(String.format("Successfully added \"%s\" to active resource pack set", modFile.getAbsolutePath())); 1425 + LiteLoader.logInfo("Successfully added \"%s\" to active resource pack set", modFile.getAbsolutePath());
1267 } 1426 }
1268 } 1427 }
1269 } 1428 }
1270 else 1429 else
1271 { 1430 {
1272 - LiteLoader.getLogger().info(String.format("Not loading mod %s, excluded by filter", metaName)); 1431 + LiteLoader.logInfo("Not loading mod %s, excluded by filter", metaName);
1273 this.disabledMods.add(this.getModFile(mod)); 1432 this.disabledMods.add(this.getModFile(mod));
1274 } 1433 }
1275 } 1434 }
1276 catch (Throwable th) 1435 catch (Throwable th)
1277 { 1436 {
1278 - LiteLoader.getLogger().warning(th.toString());  
1279 - th.printStackTrace(); 1437 + LiteLoader.getLogger().log(Level.WARNING, String.format("Error loading mod from %s", mod.getName()), th);
1280 } 1438 }
1281 } 1439 }
1282 } 1440 }
1283 - 1441 +
1284 /** 1442 /**
1285 * Initialise the mods which were loaded 1443 * Initialise the mods which were loaded
1286 */ 1444 */
@@ -1296,7 +1454,7 @@ public final class LiteLoader implements FilenameFilter @@ -1296,7 +1454,7 @@ public final class LiteLoader implements FilenameFilter
1296 1454
1297 try 1455 try
1298 { 1456 {
1299 - LiteLoader.getLogger().info("Initialising mod " + modName + " version " + mod.getVersion()); 1457 + LiteLoader.logInfo("Initialising mod %s version %s", modName, mod.getVersion());
1300 1458
1301 try 1459 try
1302 { 1460 {
@@ -1305,25 +1463,26 @@ public final class LiteLoader implements FilenameFilter @@ -1305,25 +1463,26 @@ public final class LiteLoader implements FilenameFilter
1305 1463
1306 if (LiteLoader.VERSION.getLoaderRevision() > lastModVersion.getLoaderRevision()) 1464 if (LiteLoader.VERSION.getLoaderRevision() > lastModVersion.getLoaderRevision())
1307 { 1465 {
1308 - LiteLoader.getLogger().info("Performing config upgrade for mod " + modName + ". Upgrading " + lastModVersion + " to " + LiteLoader.VERSION + "..."); 1466 + LiteLoader.logInfo("Performing config upgrade for mod %s. Upgrading %s to %s...", modName, lastModVersion, LiteLoader.VERSION);
1309 mod.upgradeSettings(VERSION.getMinecraftVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion)); 1467 mod.upgradeSettings(VERSION.getMinecraftVersion(), this.versionConfigFolder, this.inflectVersionedConfigPath(lastModVersion));
1310 1468
1311 this.storeLastKnownModRevision(modKey); 1469 this.storeLastKnownModRevision(modKey);
1312 - LiteLoader.getLogger().info("Config upgrade succeeded for mod " + modName); 1470 + LiteLoader.logInfo("Config upgrade succeeded for mod %s", modName);
1313 } 1471 }
1314 } 1472 }
1315 catch (Throwable th) 1473 catch (Throwable th)
1316 { 1474 {
1317 - LiteLoader.getLogger().warning("Error performing settings upgrade for " + modName + ". Settings may not be properly migrated"); 1475 + LiteLoader.logWarning("Error performing settings upgrade for %s. Settings may not be properly migrated", modName);
1318 } 1476 }
1319 1477
1320 - mod.init(this.modsFolder); 1478 + // pre-1.6.4_01 this was being called with the wrong path, I hope this doesn't break anything
  1479 + mod.init(this.commonConfigFolder);
1321 1480
1322 this.events.addListener(mod); 1481 this.events.addListener(mod);
1323 1482
1324 if (mod instanceof Permissible) 1483 if (mod instanceof Permissible)
1325 { 1484 {
1326 - permissionsManager.registerPermissible((Permissible)mod); 1485 + this.permissionsManager.registerPermissible((Permissible)mod);
1327 } 1486 }
1328 1487
1329 this.loadedMods.add(mod); 1488 this.loadedMods.add(mod);
@@ -1527,7 +1686,7 @@ public final class LiteLoader implements FilenameFilter @@ -1527,7 +1686,7 @@ public final class LiteLoader implements FilenameFilter
1527 public void onTick(float partialTicks, boolean inGame) 1686 public void onTick(float partialTicks, boolean inGame)
1528 { 1687 {
1529 // Tick the permissions manager 1688 // Tick the permissions manager
1530 - permissionsManager.onTick(this.minecraft, partialTicks, inGame); 1689 + this.permissionsManager.onTick(this.minecraft, partialTicks, inGame);
1531 1690
1532 this.checkAndStoreKeyBindings(); 1691 this.checkAndStoreKeyBindings();
1533 } 1692 }
@@ -1632,6 +1791,22 @@ public final class LiteLoader implements FilenameFilter @@ -1632,6 +1791,22 @@ public final class LiteLoader implements FilenameFilter
1632 } 1791 }
1633 } 1792 }
1634 1793
  1794 + private static void logInfo(String string, Object... args)
  1795 + {
  1796 + LiteLoader.getLogger().info(String.format(string, args));
  1797 + }
  1798 +
  1799 + private static void logWarning(String string, Object... args)
  1800 + {
  1801 + LiteLoader.getLogger().warning(String.format(string, args));
  1802 + }
  1803 +
  1804 + public static void populateCrashReport(CrashReport par1CrashReport)
  1805 + {
  1806 + par1CrashReport.getCategory().addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(par1CrashReport));
  1807 + par1CrashReport.getCategory().addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(par1CrashReport));
  1808 + }
  1809 +
1635 // ----------------------------------------------------------------------------------------------------------- 1810 // -----------------------------------------------------------------------------------------------------------
1636 // TODO Remove delegates below after 1.6.4 1811 // TODO Remove delegates below after 1.6.4
1637 // ----------------------------------------------------------------------------------------------------------- 1812 // -----------------------------------------------------------------------------------------------------------
java/com/mumfrey/liteloader/core/LiteLoaderVersion.java
@@ -7,20 +7,23 @@ import java.util.Set; @@ -7,20 +7,23 @@ import java.util.Set;
7 * LiteLoader version table 7 * LiteLoader version table
8 * 8 *
9 * @author Adam Mummery-Smith 9 * @author Adam Mummery-Smith
10 - * @version 1.6.4 10 + * @version 1.6.4_01
11 */ 11 */
12 public enum LiteLoaderVersion 12 public enum LiteLoaderVersion
13 { 13 {
14 LEGACY(0, "-", "-", "-"), 14 LEGACY(0, "-", "-", "-"),
15 - MC_1_5_2_R1(9, "1.5.2", "1.5.2", "1.5.2"),  
16 - MC_1_5_2_R2(10, "1.5.2", "1.5.2", "1.5.2"),  
17 - MC_1_6_1_R0(11, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"),  
18 - MC_1_6_2_R0(12, "1.6.2", "1.6.2", "1.6.2", "1.6.r2"),  
19 - MC_1_6_2_R1(13, "1.6.2", "1.6.2_02", "1.6.2", "1.6.r2"),  
20 - MC_1_6_2_R2(14, "1.6.2", "1.6.2_03", "1.6.2", "1.6.r2"),  
21 - MC_1_6_2_R3(15, "1.6.2", "1.6.2_04", "1.6.2", "1.6.r2"),  
22 - MC_1_6_3_R0(16, "1.6.3", "1.6.3", "1.6.3", "1.6.r3"),  
23 - MC_1_6_4_R0(17, "1.6.4", "1.6.4", "1.6.4", "1.6.r4"); 15 +
  16 + MC_1_5_2_R1(9, "1.5.2", "1.5.2", "1.5.2" ),
  17 + MC_1_6_1_R0(11, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"),
  18 + MC_1_6_1_R1(11, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"),
  19 + MC_1_6_2_R0(12, "1.6.2", "1.6.2", "1.6.2", "1.6.r2"),
  20 + MC_1_6_2_R1(12, "1.6.2", "1.6.2_01", "1.6.2", "1.6.r2"),
  21 + MC_1_6_2_R2(13, "1.6.2", "1.6.2_02", "1.6.2", "1.6.r2"),
  22 + MC_1_6_2_R3(14, "1.6.2", "1.6.2_03", "1.6.2", "1.6.r2"),
  23 + MC_1_6_2_R4(15, "1.6.2", "1.6.2_04", "1.6.2", "1.6.r2"),
  24 + MC_1_6_3_R0(16, "1.6.3", "1.6.3", "1.6.3", "1.6.r3"),
  25 + MC_1_6_4_R0(17, "1.6.4", "1.6.4", "1.6.4", "1.6.r4"),
  26 + MC_1_6_4_R1(18, "1.6.4", "1.6.4_01", "1.6.4", "1.6.r4");
24 27
25 private int revision; 28 private int revision;
26 29
java/com/mumfrey/liteloader/core/PluginChannels.java
@@ -26,11 +26,6 @@ public class PluginChannels @@ -26,11 +26,6 @@ public class PluginChannels
26 private static final String CHANNEL_UNREGISTER = "UNREGISTER"; 26 private static final String CHANNEL_UNREGISTER = "UNREGISTER";
27 27
28 /** 28 /**
29 - * Reference to the loader  
30 - */  
31 - private LiteLoader loader;  
32 -  
33 - /**  
34 * True if we have initialised the hook 29 * True if we have initialised the hook
35 */ 30 */
36 private boolean hookInitDone; 31 private boolean hookInitDone;
@@ -48,9 +43,8 @@ public class PluginChannels @@ -48,9 +43,8 @@ public class PluginChannels
48 /** 43 /**
49 * @param loader 44 * @param loader
50 */ 45 */
51 - public PluginChannels(LiteLoader loader) 46 + public PluginChannels()
52 { 47 {
53 - this.loader = loader;  
54 } 48 }
55 49
56 /** 50 /**
@@ -101,7 +95,7 @@ public class PluginChannels @@ -101,7 +95,7 @@ public class PluginChannels
101 { 95 {
102 try 96 try
103 { 97 {
104 - PermissionsManagerClient permissionsManager = this.loader.getPermissionsManager(); 98 + PermissionsManagerClient permissionsManager = LiteLoader.getPermissionsManager();
105 if (permissionsManager != null) 99 if (permissionsManager != null)
106 { 100 {
107 permissionsManager.onCustomPayload(customPayload.channel, customPayload.length, customPayload.data); 101 permissionsManager.onCustomPayload(customPayload.channel, customPayload.length, customPayload.data);
@@ -129,7 +123,7 @@ public class PluginChannels @@ -129,7 +123,7 @@ public class PluginChannels
129 this.pluginChannels.clear(); 123 this.pluginChannels.clear();
130 124
131 // Add the permissions manager channels 125 // Add the permissions manager channels
132 - this.addPluginChannelsFor(this.loader.getPermissionsManager()); 126 + this.addPluginChannelsFor(LiteLoader.getPermissionsManager());
133 127
134 // Enumerate mods for plugin channels 128 // Enumerate mods for plugin channels
135 for (PluginChannelListener pluginChannelListener : this.pluginChannelListeners) 129 for (PluginChannelListener pluginChannelListener : this.pluginChannelListeners)
java/com/mumfrey/liteloader/core/hooks/HookChat.java
@@ -54,7 +54,7 @@ public class HookChat extends Packet3Chat @@ -54,7 +54,7 @@ public class HookChat extends Packet3Chat
54 { 54 {
55 if (proxyClass != null) 55 if (proxyClass != null)
56 { 56 {
57 - proxyPacket = proxyClass.newInstance(); 57 + this.proxyPacket = proxyClass.newInstance();
58 } 58 }
59 } 59 }
60 catch (Exception ex) {} 60 catch (Exception ex) {}
@@ -72,11 +72,11 @@ public class HookChat extends Packet3Chat @@ -72,11 +72,11 @@ public class HookChat extends Packet3Chat
72 { 72 {
73 if (proxyClass != null) 73 if (proxyClass != null)
74 { 74 {
75 - proxyPacket = proxyClass.newInstance(); 75 + this.proxyPacket = proxyClass.newInstance();
76 76
77 - if (proxyPacket instanceof Packet3Chat) 77 + if (this.proxyPacket instanceof Packet3Chat)
78 { 78 {
79 - ((Packet3Chat)proxyPacket).message = this.message; 79 + ((Packet3Chat)this.proxyPacket).message = this.message;
80 } 80 }
81 } 81 }
82 } 82 }
@@ -86,10 +86,10 @@ public class HookChat extends Packet3Chat @@ -86,10 +86,10 @@ public class HookChat extends Packet3Chat
86 @Override 86 @Override
87 public void readPacketData(DataInput datainputstream) throws IOException 87 public void readPacketData(DataInput datainputstream) throws IOException
88 { 88 {
89 - if (proxyPacket != null) 89 + if (this.proxyPacket != null)
90 { 90 {
91 - proxyPacket.readPacketData(datainputstream);  
92 - this.message = ((Packet3Chat)proxyPacket).message; 91 + this.proxyPacket.readPacketData(datainputstream);
  92 + this.message = ((Packet3Chat)this.proxyPacket).message;
93 } 93 }
94 else 94 else
95 super.readPacketData(datainputstream); 95 super.readPacketData(datainputstream);
@@ -98,8 +98,8 @@ public class HookChat extends Packet3Chat @@ -98,8 +98,8 @@ public class HookChat extends Packet3Chat
98 @Override 98 @Override
99 public void writePacketData(DataOutput dataoutputstream) throws IOException 99 public void writePacketData(DataOutput dataoutputstream) throws IOException
100 { 100 {
101 - if (proxyPacket != null)  
102 - proxyPacket.writePacketData(dataoutputstream); 101 + if (this.proxyPacket != null)
  102 + this.proxyPacket.writePacketData(dataoutputstream);
103 else 103 else
104 super.writePacketData(dataoutputstream); 104 super.writePacketData(dataoutputstream);
105 } 105 }
@@ -109,8 +109,8 @@ public class HookChat extends Packet3Chat @@ -109,8 +109,8 @@ public class HookChat extends Packet3Chat
109 { 109 {
110 if (events == null || events.onChat(this)) 110 if (events == null || events.onChat(this))
111 { 111 {
112 - if (proxyPacket != null)  
113 - proxyPacket.processPacket(nethandler); 112 + if (this.proxyPacket != null)
  113 + this.proxyPacket.processPacket(nethandler);
114 else 114 else
115 super.processPacket(nethandler); 115 super.processPacket(nethandler);
116 } 116 }
@@ -119,8 +119,8 @@ public class HookChat extends Packet3Chat @@ -119,8 +119,8 @@ public class HookChat extends Packet3Chat
119 @Override 119 @Override
120 public int getPacketSize() 120 public int getPacketSize()
121 { 121 {
122 - if (proxyPacket != null)  
123 - return proxyPacket.getPacketSize(); 122 + if (this.proxyPacket != null)
  123 + return this.proxyPacket.getPacketSize();
124 124
125 return super.getPacketSize(); 125 return super.getPacketSize();
126 } 126 }
java/com/mumfrey/liteloader/core/hooks/HookPluginChannels.java
@@ -43,7 +43,7 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -43,7 +43,7 @@ public class HookPluginChannels extends Packet250CustomPayload
43 { 43 {
44 if (HookPluginChannels.proxyClass != null) 44 if (HookPluginChannels.proxyClass != null)
45 { 45 {
46 - proxyPacket = HookPluginChannels.proxyClass.newInstance(); 46 + this.proxyPacket = HookPluginChannels.proxyClass.newInstance();
47 } 47 }
48 } 48 }
49 catch (Exception ex) {} 49 catch (Exception ex) {}
@@ -57,13 +57,13 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -57,13 +57,13 @@ public class HookPluginChannels extends Packet250CustomPayload
57 { 57 {
58 if (HookPluginChannels.proxyClass != null) 58 if (HookPluginChannels.proxyClass != null)
59 { 59 {
60 - proxyPacket = HookPluginChannels.proxyClass.newInstance(); 60 + this.proxyPacket = HookPluginChannels.proxyClass.newInstance();
61 61
62 - if (proxyPacket instanceof Packet250CustomPayload) 62 + if (this.proxyPacket instanceof Packet250CustomPayload)
63 { 63 {
64 - ((Packet250CustomPayload)proxyPacket).channel = this.channel;  
65 - ((Packet250CustomPayload)proxyPacket).data = this.data;  
66 - ((Packet250CustomPayload)proxyPacket).length = this.length; 64 + ((Packet250CustomPayload)this.proxyPacket).channel = this.channel;
  65 + ((Packet250CustomPayload)this.proxyPacket).data = this.data;
  66 + ((Packet250CustomPayload)this.proxyPacket).length = this.length;
67 } 67 }
68 } 68 }
69 } 69 }
@@ -74,12 +74,12 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -74,12 +74,12 @@ public class HookPluginChannels extends Packet250CustomPayload
74 @Override 74 @Override
75 public void readPacketData(DataInput datainputstream) throws IOException 75 public void readPacketData(DataInput datainputstream) throws IOException
76 { 76 {
77 - if (proxyPacket != null) 77 + if (this.proxyPacket != null)
78 { 78 {
79 - proxyPacket.readPacketData(datainputstream);  
80 - this.channel = ((Packet250CustomPayload)proxyPacket).channel;  
81 - this.length = ((Packet250CustomPayload)proxyPacket).length;  
82 - this.data = ((Packet250CustomPayload)proxyPacket).data; 79 + this.proxyPacket.readPacketData(datainputstream);
  80 + this.channel = ((Packet250CustomPayload)this.proxyPacket).channel;
  81 + this.length = ((Packet250CustomPayload)this.proxyPacket).length;
  82 + this.data = ((Packet250CustomPayload)this.proxyPacket).data;
83 } 83 }
84 else 84 else
85 super.readPacketData(datainputstream); 85 super.readPacketData(datainputstream);
@@ -88,8 +88,8 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -88,8 +88,8 @@ public class HookPluginChannels extends Packet250CustomPayload
88 @Override 88 @Override
89 public void writePacketData(DataOutput dataoutputstream) throws IOException 89 public void writePacketData(DataOutput dataoutputstream) throws IOException
90 { 90 {
91 - if (proxyPacket != null)  
92 - proxyPacket.writePacketData(dataoutputstream); 91 + if (this.proxyPacket != null)
  92 + this.proxyPacket.writePacketData(dataoutputstream);
93 else 93 else
94 super.writePacketData(dataoutputstream); 94 super.writePacketData(dataoutputstream);
95 } 95 }
@@ -97,8 +97,8 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -97,8 +97,8 @@ public class HookPluginChannels extends Packet250CustomPayload
97 @Override 97 @Override
98 public void processPacket(NetHandler nethandler) 98 public void processPacket(NetHandler nethandler)
99 { 99 {
100 - if (proxyPacket != null)  
101 - proxyPacket.processPacket(nethandler); 100 + if (this.proxyPacket != null)
  101 + this.proxyPacket.processPacket(nethandler);
102 else 102 else
103 super.processPacket(nethandler); 103 super.processPacket(nethandler);
104 104
@@ -111,8 +111,8 @@ public class HookPluginChannels extends Packet250CustomPayload @@ -111,8 +111,8 @@ public class HookPluginChannels extends Packet250CustomPayload
111 @Override 111 @Override
112 public int getPacketSize() 112 public int getPacketSize()
113 { 113 {
114 - if (proxyPacket != null)  
115 - return proxyPacket.getPacketSize(); 114 + if (this.proxyPacket != null)
  115 + return this.proxyPacket.getPacketSize();
116 116
117 return super.getPacketSize(); 117 return super.getPacketSize();
118 } 118 }
java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java
1 package com.mumfrey.liteloader.launch; 1 package com.mumfrey.liteloader.launch;
2 2
3 -import java.io.File;  
4 -import java.lang.reflect.Method;  
5 -import java.util.List;  
6 -import java.util.logging.Level;  
7 -import java.util.logging.Logger;  
8 -  
9 import net.minecraft.launchwrapper.IClassTransformer; 3 import net.minecraft.launchwrapper.IClassTransformer;
10 -import net.minecraft.launchwrapper.LaunchClassLoader;  
11 4
12 public class LiteLoaderTransformer implements IClassTransformer 5 public class LiteLoaderTransformer implements IClassTransformer
13 { 6 {
@@ -15,37 +8,17 @@ public class LiteLoaderTransformer implements IClassTransformer @@ -15,37 +8,17 @@ public class LiteLoaderTransformer implements IClassTransformer
15 8
16 // TODO Obfuscation 1.6.4 9 // TODO Obfuscation 1.6.4
17 private static final String classMappingRenderLightningBoltObf = "bha"; 10 private static final String classMappingRenderLightningBoltObf = "bha";
18 -  
19 - private static Logger logger = Logger.getLogger("liteloader");  
20 -  
21 - public static LaunchClassLoader launchClassLoader;  
22 -  
23 - public static List<String> modsToLoad;  
24 -  
25 - public static File gameDirectory;  
26 -  
27 - public static File assetsDirectory;  
28 11
29 - public static String profile; 12 + private static boolean postInit = false;
30 13
31 @Override 14 @Override
32 public byte[] transform(String name, String transformedName, byte[] basicClass) 15 public byte[] transform(String name, String transformedName, byte[] basicClass)
33 { 16 {
34 - if (classMappingRenderLightningBolt.equals(name) || classMappingRenderLightningBoltObf.equals(name)) 17 + if ((classMappingRenderLightningBolt.equals(name) || classMappingRenderLightningBoltObf.equals(name)) && !LiteLoaderTransformer.postInit)
35 { 18 {
36 - logger.info("Beginning LiteLoader Init...");  
37 -  
38 - try  
39 - {  
40 - Class<?> loaderClass = Class.forName("com.mumfrey.liteloader.core.LiteLoader", false, LiteLoaderTransformer.launchClassLoader);  
41 - Method mInit = loaderClass.getDeclaredMethod("init", File.class, File.class, String.class, List.class, LaunchClassLoader.class);  
42 - mInit.setAccessible(true);  
43 - mInit.invoke(null, LiteLoaderTransformer.gameDirectory, LiteLoaderTransformer.assetsDirectory, LiteLoaderTransformer.profile, LiteLoaderTransformer.modsToLoad, LiteLoaderTransformer.launchClassLoader);  
44 - }  
45 - catch (Throwable th)  
46 - {  
47 - logger.log(Level.SEVERE, String.format("Error initialising LiteLoader: %s", th.getMessage()), th);  
48 - } 19 + LiteLoaderTransformer.postInit = true;
  20 + LiteLoaderTweaker.preInitLoader(); // This is here at the moment, it will move later
  21 + LiteLoaderTweaker.postInitLoader();
49 } 22 }
50 23
51 return basicClass; 24 return basicClass;
java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java
1 package com.mumfrey.liteloader.launch; 1 package com.mumfrey.liteloader.launch;
2 2
3 import java.io.File; 3 import java.io.File;
  4 +import java.lang.reflect.Method;
  5 +import java.net.URL;
  6 +import java.net.URLClassLoader;
4 import java.util.ArrayList; 7 import java.util.ArrayList;
5 import java.util.HashMap; 8 import java.util.HashMap;
6 import java.util.List; 9 import java.util.List;
7 import java.util.Map; 10 import java.util.Map;
8 import java.util.Map.Entry; 11 import java.util.Map.Entry;
  12 +import java.util.logging.Level;
  13 +import java.util.logging.Logger;
9 14
10 import joptsimple.ArgumentAcceptingOptionSpec; 15 import joptsimple.ArgumentAcceptingOptionSpec;
11 import joptsimple.NonOptionArgumentSpec; 16 import joptsimple.NonOptionArgumentSpec;
@@ -22,12 +27,18 @@ import net.minecraft.launchwrapper.LaunchClassLoader; @@ -22,12 +27,18 @@ import net.minecraft.launchwrapper.LaunchClassLoader;
22 public class LiteLoaderTweaker implements ITweaker 27 public class LiteLoaderTweaker implements ITweaker
23 { 28 {
24 public static final String VERSION = "1.6.4"; 29 public static final String VERSION = "1.6.4";
25 -  
26 - private File gameDirectory;  
27 30
28 - private File assetsDirectory; 31 + private static Logger logger = Logger.getLogger("liteloader");
  32 +
  33 + private static boolean preInit = true;
  34 +
  35 + private static File gameDirectory;
  36 +
  37 + private static File assetsDirectory;
29 38
30 - private String profile; 39 + private static String profile;
  40 +
  41 + private static List<String> modsToLoad;
31 42
32 private List<String> singularLaunchArgs = new ArrayList<String>(); 43 private List<String> singularLaunchArgs = new ArrayList<String>();
33 44
@@ -42,13 +53,9 @@ public class LiteLoaderTweaker implements ITweaker @@ -42,13 +53,9 @@ public class LiteLoaderTweaker implements ITweaker
42 @Override 53 @Override
43 public void acceptOptions(List<String> args, File gameDirectory, File assetsDirectory, String profile) 54 public void acceptOptions(List<String> args, File gameDirectory, File assetsDirectory, String profile)
44 { 55 {
45 - this.gameDirectory = gameDirectory;  
46 - this.assetsDirectory = assetsDirectory;  
47 - this.profile = profile;  
48 -  
49 - LiteLoaderTransformer.gameDirectory = gameDirectory;  
50 - LiteLoaderTransformer.assetsDirectory = assetsDirectory;  
51 - LiteLoaderTransformer.profile = profile != null ? profile : VERSION; 56 + LiteLoaderTweaker.gameDirectory = gameDirectory;
  57 + LiteLoaderTweaker.assetsDirectory = assetsDirectory;
  58 + LiteLoaderTweaker.profile = profile;
52 59
53 OptionParser optionParser = new OptionParser(); 60 OptionParser optionParser = new OptionParser();
54 this.modsOption = optionParser.accepts("mods", "Comma-separated list of mods to load").withRequiredArg().ofType(String.class).withValuesSeparatedBy(','); 61 this.modsOption = optionParser.accepts("mods", "Comma-separated list of mods to load").withRequiredArg().ofType(String.class).withValuesSeparatedBy(',');
@@ -74,8 +81,10 @@ public class LiteLoaderTweaker implements ITweaker @@ -74,8 +81,10 @@ public class LiteLoaderTweaker implements ITweaker
74 81
75 if (this.parsedOptions.has(this.modsOption)) 82 if (this.parsedOptions.has(this.modsOption))
76 { 83 {
77 - LiteLoaderTransformer.modsToLoad = this.modsOption.values(this.parsedOptions); 84 + LiteLoaderTweaker.modsToLoad = this.modsOption.values(this.parsedOptions);
78 } 85 }
  86 +
  87 +// LiteLoaderTweaker.preInitLoader(); // for future version with tweak support
79 } 88 }
80 89
81 /** 90 /**
@@ -85,7 +94,7 @@ public class LiteLoaderTweaker implements ITweaker @@ -85,7 +94,7 @@ public class LiteLoaderTweaker implements ITweaker
85 public void provideRequiredArgs(File gameDirectory, File assetsDirectory) 94 public void provideRequiredArgs(File gameDirectory, File assetsDirectory)
86 { 95 {
87 if (!this.launchArgs.containsKey("--version")) 96 if (!this.launchArgs.containsKey("--version"))
88 - this.addClassifiedArg("--version", this.VERSION); 97 + this.addClassifiedArg("--version", LiteLoaderTweaker.VERSION);
89 98
90 if (!this.launchArgs.containsKey("--gameDir") && gameDirectory != null) 99 if (!this.launchArgs.containsKey("--gameDir") && gameDirectory != null)
91 this.addClassifiedArg("--gameDir", gameDirectory.getAbsolutePath()); 100 this.addClassifiedArg("--gameDir", gameDirectory.getAbsolutePath());
@@ -128,7 +137,7 @@ public class LiteLoaderTweaker implements ITweaker @@ -128,7 +137,7 @@ public class LiteLoaderTweaker implements ITweaker
128 @Override 137 @Override
129 public void injectIntoClassLoader(LaunchClassLoader classLoader) 138 public void injectIntoClassLoader(LaunchClassLoader classLoader)
130 { 139 {
131 - LiteLoaderTransformer.launchClassLoader = classLoader; 140 + LiteLoaderTweaker.logger.info("Injecting LiteLoader Class Transformer");
132 classLoader.registerTransformer(LiteLoaderTransformer.class.getName()); 141 classLoader.registerTransformer(LiteLoaderTransformer.class.getName());
133 } 142 }
134 143
@@ -143,8 +152,8 @@ public class LiteLoaderTweaker implements ITweaker @@ -143,8 +152,8 @@ public class LiteLoaderTweaker implements ITweaker
143 { 152 {
144 List<String> args = new ArrayList<String>(); 153 List<String> args = new ArrayList<String>();
145 154
146 - for (String unClassifiedArg : this.singularLaunchArgs)  
147 - args.add(unClassifiedArg); 155 + for (String singularArg : this.singularLaunchArgs)
  156 + args.add(singularArg);
148 157
149 for (Entry<String, String> launchArg : this.launchArgs.entrySet()) 158 for (Entry<String, String> launchArg : this.launchArgs.entrySet())
150 { 159 {
@@ -160,16 +169,109 @@ public class LiteLoaderTweaker implements ITweaker @@ -160,16 +169,109 @@ public class LiteLoaderTweaker implements ITweaker
160 169
161 public File getGameDirectory() 170 public File getGameDirectory()
162 { 171 {
163 - return this.gameDirectory; 172 + return LiteLoaderTweaker.gameDirectory;
164 } 173 }
165 174
166 public File getAssetsDirectory() 175 public File getAssetsDirectory()
167 { 176 {
168 - return this.assetsDirectory; 177 + return LiteLoaderTweaker.assetsDirectory;
169 } 178 }
170 179
171 public String getProfile() 180 public String getProfile()
172 { 181 {
173 - return this.profile; 182 + return LiteLoaderTweaker.profile;
  183 + }
  184 +
  185 + public static boolean addTweaker(URL tweakSource, String tweakClass)
  186 + {
  187 + if (LiteLoaderTweaker.preInit)
  188 + {
  189 + @SuppressWarnings("unchecked")
  190 + List<String> tweakers = (List<String>)Launch.blackboard.get("TweakClasses");
  191 + if (tweakers != null)
  192 + {
  193 + if (LiteLoaderTweaker.addURLToParentClassLoader(tweakSource))
  194 + {
  195 + tweakers.add(tweakClass);
  196 + return true;
  197 + }
  198 + }
  199 + }
  200 + else
  201 + {
  202 + LiteLoaderTweaker.logger.warning(String.format("Failed to add tweak class %s from %s because preInit is already complete", tweakClass, tweakSource));
  203 + }
  204 +
  205 + return false;
  206 + }
  207 +
  208 + /**
  209 + * Do the first stage of loader startup, which enumerates mod sources and finds tweakers
  210 + */
  211 + protected static void preInitLoader()
  212 + {
  213 + if (!LiteLoaderTweaker.preInit) throw new IllegalStateException("Attempt to perform LiteLoader PreInit but PreInit was already completed");
  214 + LiteLoaderTweaker.logger.info("Beginning LiteLoader PreInit...");
  215 +
  216 + try
  217 + {
  218 + Class<?> loaderClass = Class.forName("com.mumfrey.liteloader.core.LiteLoader", false, Launch.classLoader);
  219 + Method mPreInit = loaderClass.getDeclaredMethod("preInit", File.class, File.class, String.class, List.class, LaunchClassLoader.class, Boolean.TYPE);
  220 + mPreInit.setAccessible(true);
  221 + mPreInit.invoke(null, LiteLoaderTweaker.gameDirectory, LiteLoaderTweaker.assetsDirectory, LiteLoaderTweaker.profile, LiteLoaderTweaker.modsToLoad, Launch.classLoader, false);
  222 +
  223 + LiteLoaderTweaker.preInit = false;
  224 + }
  225 + catch (Throwable th)
  226 + {
  227 + LiteLoaderTweaker.logger.log(Level.SEVERE, String.format("Error during LiteLoader PreInit: %s", th.getMessage()), th);
  228 + }
  229 + }
  230 +
  231 + /**
  232 + * Do the second stage of loader startup
  233 + */
  234 + protected static void postInitLoader()
  235 + {
  236 + if (LiteLoaderTweaker.preInit) throw new IllegalStateException("Attempt to perform LiteLoader PostInit but PreInit was not completed");
  237 + LiteLoaderTweaker.logger.info("Beginning LiteLoader PostInit...");
  238 +
  239 + try
  240 + {
  241 + Class<?> loaderClass = Class.forName("com.mumfrey.liteloader.core.LiteLoader", false, Launch.classLoader);
  242 + Method mPostInit = loaderClass.getDeclaredMethod("postInit");
  243 + mPostInit.setAccessible(true);
  244 + mPostInit.invoke(null);
  245 + }
  246 + catch (Throwable th)
  247 + {
  248 + th.printStackTrace(System.out);
  249 + LiteLoaderTweaker.logger.log(Level.SEVERE, String.format("Error during LiteLoader PostInit: %s", th.getMessage()), th);
  250 + }
  251 + }
  252 +
  253 + /**
  254 + * @param url URL to add
  255 + */
  256 + public static boolean addURLToParentClassLoader(URL url)
  257 + {
  258 + if (LiteLoaderTweaker.preInit)
  259 + {
  260 + try
  261 + {
  262 + URLClassLoader classLoader = (URLClassLoader)Launch.class.getClassLoader();
  263 + Method mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
  264 + mAddUrl.setAccessible(true);
  265 + mAddUrl.invoke(classLoader, url);
  266 +
  267 + return true;
  268 + }
  269 + catch (Exception ex)
  270 + {
  271 + LiteLoaderTweaker.logger.log(Level.WARNING, String.format("addURLToParentClassLoader failed: %s", ex.getMessage()), ex);
  272 + }
  273 + }
  274 +
  275 + return false;
174 } 276 }
175 -} 277 +}
176 \ No newline at end of file 278 \ No newline at end of file
java/com/mumfrey/liteloader/permissions/PermissionsManagerClient.java
@@ -383,7 +383,7 @@ public class PermissionsManagerClient implements PermissionsManager, PluginChann @@ -383,7 +383,7 @@ public class PermissionsManagerClient implements PermissionsManager, PluginChann
383 */ 383 */
384 public boolean getModPermission(Permissible mod, String permission) 384 public boolean getModPermission(Permissible mod, String permission)
385 { 385 {
386 - if (mod == null) mod = this.allMods; 386 + if (mod == null) mod = PermissionsManagerClient.allMods;
387 permission = formatModPermission(mod.getPermissibleModName(), permission); 387 permission = formatModPermission(mod.getPermissibleModName(), permission);
388 Permissions permissions = this.getPermissions(mod); 388 Permissions permissions = this.getPermissions(mod);
389 389
java/com/mumfrey/liteloader/util/PrivateFields.java
@@ -114,7 +114,7 @@ public class PrivateFields&lt;P, T&gt; @@ -114,7 +114,7 @@ public class PrivateFields&lt;P, T&gt;
114 Field modifiers = Field.class.getDeclaredField("modifiers"); 114 Field modifiers = Field.class.getDeclaredField("modifiers");
115 modifiers.setAccessible(true); 115 modifiers.setAccessible(true);
116 116
117 - Field field = this.parentClass.getDeclaredField(fieldName); 117 + Field field = this.parentClass.getDeclaredField(this.fieldName);
118 modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); 118 modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
119 field.setAccessible(true); 119 field.setAccessible(true);
120 field.set(instance, value); 120 field.set(instance, value);
java/net/minecraft/src/CallableJVMFlags.java
@@ -6,8 +6,7 @@ import java.util.Iterator; @@ -6,8 +6,7 @@ import java.util.Iterator;
6 import java.util.List; 6 import java.util.List;
7 import java.util.concurrent.Callable; 7 import java.util.concurrent.Callable;
8 8
9 -import com.mumfrey.liteloader.core.CallableLiteLoaderBrand;  
10 -import com.mumfrey.liteloader.core.CallableLiteLoaderMods; 9 +import com.mumfrey.liteloader.core.LiteLoader;
11 10
12 class CallableJVMFlags implements Callable<String> 11 class CallableJVMFlags implements Callable<String>
13 { 12 {
@@ -17,8 +16,7 @@ class CallableJVMFlags implements Callable&lt;String&gt; @@ -17,8 +16,7 @@ class CallableJVMFlags implements Callable&lt;String&gt;
17 CallableJVMFlags(CrashReport par1CrashReport) 16 CallableJVMFlags(CrashReport par1CrashReport)
18 { 17 {
19 this.theCrashReport = par1CrashReport; 18 this.theCrashReport = par1CrashReport;
20 - par1CrashReport.getCategory().addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(par1CrashReport));  
21 - par1CrashReport.getCategory().addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(par1CrashReport)); 19 + LiteLoader.populateCrashReport(par1CrashReport);
22 } 20 }
23 21
24 /** 22 /**
lib/launchwrapper-1.7.jar renamed to lib/launchwrapper-1.8.jar
No preview for this file type