Commit 08134e70a77c136322f89efeeb7c8b0bc3a0cf49

Authored by Mumfrey
1 parent 7347bfef

Fix injection of mixin-containing mod files into classpath

src/main/java/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java
... ... @@ -596,30 +596,12 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
596 596 if (this.environment.addCascadedTweaker(tweakClass, tweakPriority))
597 597 {
598 598 LiteLoaderLogger.info(Verbosity.REDUCED, "tweakClass '%s' was successfully added", tweakClass);
599   - container.injectIntoClassPath(this.classLoader, true);
600   -
601 599 if (container.isExternalJar())
602 600 {
603 601 this.containers.registerInjectedTweak(container);
604 602 }
605 603  
606   - String[] classPathEntries = container.getClassPathEntries();
607   - if (classPathEntries != null)
608   - {
609   - for (String classPathEntry : classPathEntries)
610   - {
611   - try
612   - {
613   - File classPathJar = new File(this.environment.getGameDirectory(), classPathEntry);
614   - URL classPathJarUrl = classPathJar.toURI().toURL();
615   -
616   - LiteLoaderLogger.info("Adding Class-Path entry: %s", classPathEntry);
617   - LiteLoaderTweaker.addURLToParentClassLoader(classPathJarUrl);
618   - this.classLoader.addURL(classPathJarUrl);
619   - }
620   - catch (MalformedURLException ex) {}
621   - }
622   - }
  604 + this.injectTweakContainer(container);
623 605 }
624 606 }
625 607 catch (MalformedURLException ex)
... ... @@ -650,28 +632,62 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
650 632  
651 633 private void addMixinsFrom(MixinContainer<File> container)
652 634 {
653   - for (String config : container.getMixinConfigs())
  635 + try
654 636 {
655   - if (config.endsWith(".json"))
656   - {
657   - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering mixin config %s for %s", config, container.getName());
658   - MixinEnvironment.getDefaultEnvironment().addConfiguration(config);
659   - }
660   - else if (config.contains(".json@"))
  637 + for (String config : container.getMixinConfigs())
661 638 {
662   - int pos = config.indexOf(".json@");
663   - String phaseName = config.substring(pos + 6);
664   - config = config.substring(0, pos + 5);
665   - Phase phase = Phase.forName(phaseName);
666   - if (phase != null)
  639 + if (config.endsWith(".json"))
667 640 {
668 641 LiteLoaderLogger.info(Verbosity.REDUCED, "Registering mixin config %s for %s", config, container.getName());
669   - MixinEnvironment.getEnvironment(phase).addConfiguration(config);
  642 + MixinEnvironment.getDefaultEnvironment().addConfiguration(config);
  643 + this.injectContainerRecursive(container);
  644 + }
  645 + else if (config.contains(".json@"))
  646 + {
  647 + int pos = config.indexOf(".json@");
  648 + String phaseName = config.substring(pos + 6);
  649 + config = config.substring(0, pos + 5);
  650 + Phase phase = Phase.forName(phaseName);
  651 + if (phase != null)
  652 + {
  653 + LiteLoaderLogger.info(Verbosity.REDUCED, "Registering mixin config %s for %s", config, container.getName());
  654 + MixinEnvironment.getEnvironment(phase).addConfiguration(config);
  655 + this.injectContainerRecursive(container);
  656 + }
670 657 }
671 658 }
672 659 }
  660 + catch (MalformedURLException ex)
  661 + {
  662 + }
673 663 }
674 664  
  665 + protected void injectTweakContainer(TweakContainer<File> container) throws MalformedURLException
  666 + {
  667 + if (!container.injectIntoClassPath(this.classLoader, true))
  668 + {
  669 + return;
  670 + }
  671 +
  672 + String[] classPathEntries = container.getClassPathEntries();
  673 + if (classPathEntries != null)
  674 + {
  675 + for (String classPathEntry : classPathEntries)
  676 + {
  677 + try
  678 + {
  679 + File classPathJar = new File(this.environment.getGameDirectory(), classPathEntry);
  680 + URL classPathJarUrl = classPathJar.toURI().toURL();
  681 +
  682 + LiteLoaderLogger.info("Adding Class-Path entry: %s", classPathEntry);
  683 + LiteLoaderTweaker.addURLToParentClassLoader(classPathJarUrl);
  684 + this.classLoader.addURL(classPathJarUrl);
  685 + }
  686 + catch (MalformedURLException ex) {}
  687 + }
  688 + }
  689 + }
  690 +
675 691 /**
676 692 * @param container
677 693 */
... ...