Commit 303ac2af790baa4f0da6882716017b569ac34193

Authored by Mumfrey
1 parent d19241ae

convert observer list in LiteLoaderMods to HandlerList

java/common/com/mumfrey/liteloader/core/LiteLoaderMods.java
... ... @@ -15,6 +15,8 @@ import net.minecraft.client.resources.IResourcePack;
15 15 import com.mumfrey.liteloader.LiteMod;
16 16 import com.mumfrey.liteloader.api.ModLoadObserver;
17 17 import com.mumfrey.liteloader.common.LoadingProgress;
  18 +import com.mumfrey.liteloader.core.event.HandlerList;
  19 +import com.mumfrey.liteloader.interfaces.FastIterableDeque;
18 20 import com.mumfrey.liteloader.interfaces.Loadable;
19 21 import com.mumfrey.liteloader.interfaces.LoadableMod;
20 22 import com.mumfrey.liteloader.interfaces.LoaderEnumerator;
... ... @@ -64,7 +66,7 @@ public class LiteLoaderMods
64 66 /**
65 67 * Mod load observers
66 68 */
67   - private List<ModLoadObserver> observers;
  69 + private FastIterableDeque<ModLoadObserver> observers = new HandlerList<ModLoadObserver>(ModLoadObserver.class);
68 70  
69 71 /**
70 72 * List of loaded mods, for crash reporting
... ... @@ -104,7 +106,7 @@ public class LiteLoaderMods
104 106  
105 107 void init(List<ModLoadObserver> observers)
106 108 {
107   - this.observers = observers;
  109 + this.observers.addAll(observers);
108 110 this.disabledMods.addAll(this.enumerator.getDisabledContainers());
109 111 }
110 112  
... ... @@ -500,10 +502,7 @@ public class LiteLoaderMods
500 502 */
501 503 void onModLoaded(Mod mod)
502 504 {
503   - for (ModLoadObserver observer : this.observers)
504   - {
505   - observer.onModLoaded(mod.getMod());
506   - }
  505 + this.observers.all().onModLoaded(mod.getMod());
507 506  
508 507 this.allMods.add(mod);
509 508 this.initMods.add(mod);
... ... @@ -532,10 +531,7 @@ public class LiteLoaderMods
532 531 this.disabledMods.add(new NonMod(container, false));
533 532 }
534 533  
535   - for (ModLoadObserver observer : this.observers)
536   - {
537   - observer.onModLoadFailed(container, identifier, reason, th);
538   - }
  534 + this.observers.all().onModLoadFailed(container, identifier, reason, th);
539 535 }
540 536  
541 537 /**
... ... @@ -591,10 +587,7 @@ public class LiteLoaderMods
591 587 */
592 588 private void onPreInitMod(LiteMod instance)
593 589 {
594   - for (ModLoadObserver observer : this.observers)
595   - {
596   - observer.onPreInitMod(instance);
597   - }
  590 + this.observers.all().onPreInitMod(instance);
598 591  
599 592 // register mod config panel if configurable
600 593 this.configManager.registerMod(instance);
... ... @@ -617,10 +610,7 @@ public class LiteLoaderMods
617 610 */
618 611 private void onPostInitMod(LiteMod instance)
619 612 {
620   - for (ModLoadObserver observer : this.observers)
621   - {
622   - observer.onPostInitMod(instance);
623   - }
  613 + this.observers.all().onPostInitMod(instance);
624 614  
625 615 // add the mod to all relevant listener queues
626 616 LiteLoader.getInterfaceManager().offer(instance);
... ... @@ -646,10 +636,7 @@ public class LiteLoaderMods
646 636  
647 637 LiteLoaderLogger.info("Performing config upgrade for mod %s. Upgrading %s to %s...", instance.getName(), lastModVersion, LiteLoaderVersion.CURRENT);
648 638  
649   - for (ModLoadObserver observer : this.observers)
650   - {
651   - observer.onMigrateModConfig(instance, newConfigPath, oldConfigPath);
652   - }
  639 + this.observers.all().onMigrateModConfig(instance, newConfigPath, oldConfigPath);
653 640  
654 641 // Migrate versioned config if any is present
655 642 this.configManager.migrateModConfig(instance, newConfigPath, oldConfigPath);
... ...