Commit 1012613a5bac1f67f4619624abe30cdb8e6dff8f

Authored by Mumfrey
1 parent 1c6b9c78

fix some dependency check issues, possibly fixes #78

java/client/com/mumfrey/liteloader/client/PacketEventsClient.java
... ... @@ -204,10 +204,10 @@ public class PacketEventsClient extends PacketEvents
204 204 @Override
205 205 protected void handlePacket(PacketEventInfo<Packet> e, INetHandler netHandler, S02PacketChat packet)
206 206 {
207   - if (packet.func_148915_c() == null)
  207 + if (packet.getChatComponent() == null)
208 208 return;
209 209  
210   - IChatComponent originalChat = packet.func_148915_c();
  210 + IChatComponent originalChat = packet.getChatComponent();
211 211 IChatComponent chat = originalChat;
212 212 String message = chat.getFormattedText();
213 213  
... ...
java/common/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java
... ... @@ -6,9 +6,11 @@ import java.net.URL;
6 6 import java.util.ArrayList;
7 7 import java.util.Collection;
8 8 import java.util.Collections;
  9 +import java.util.Deque;
9 10 import java.util.HashMap;
10 11 import java.util.HashSet;
11 12 import java.util.LinkedHashSet;
  13 +import java.util.LinkedList;
12 14 import java.util.List;
13 15 import java.util.Map;
14 16 import java.util.Set;
... ... @@ -29,6 +31,7 @@ import com.mumfrey.liteloader.core.api.DefaultClassValidator;
29 31 import com.mumfrey.liteloader.core.api.DefaultEnumeratorPlugin;
30 32 import com.mumfrey.liteloader.core.event.HandlerList;
31 33 import com.mumfrey.liteloader.interfaces.FastIterableDeque;
  34 +import com.mumfrey.liteloader.interfaces.Injectable;
32 35 import com.mumfrey.liteloader.interfaces.Loadable;
33 36 import com.mumfrey.liteloader.interfaces.LoadableMod;
34 37 import com.mumfrey.liteloader.interfaces.LoaderEnumerator;
... ... @@ -386,6 +389,8 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
386 389 LiteLoaderLogger.warning(th, "Enumerator Module %s encountered an error whilst enumerating", module.getClass().getName());
387 390 }
388 391 }
  392 +
  393 + this.checkDependencies();
389 394 }
390 395  
391 396 private void injectDiscoveredTweaks()
... ... @@ -469,29 +474,24 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
469 474 {
470 475 this.checkState(EnumeratorState.DISCOVER, "registerModContainer");
471 476  
472   - if (container != null)
  477 + if (container == null)
473 478 {
474   - if (!this.checkEnabled(container))
475   - {
476   - this.registerDisabledContainer(container, DisabledReason.USER_DISABLED);
477   - return false;
478   - }
479   -
480   - if (!this.checkDependencies(container))
481   - {
482   - this.registerDisabledContainer(container, DisabledReason.MISSING_DEPENDENCY);
483   - return false;
484   - }
485   -
486   - if (!this.checkAPIRequirements(container))
487   - {
488   - this.registerDisabledContainer(container, DisabledReason.MISSING_API);
489   - return false;
490   - }
491   -
492   - this.registerEnabledContainer(container);
  479 + return true;
493 480 }
494 481  
  482 + if (!this.checkEnabled(container))
  483 + {
  484 + this.registerDisabledContainer(container, DisabledReason.USER_DISABLED);
  485 + return false;
  486 + }
  487 +
  488 + if (!this.checkAPIRequirements(container))
  489 + {
  490 + this.registerDisabledContainer(container, DisabledReason.MISSING_API);
  491 + return false;
  492 + }
  493 +
  494 + this.registerEnabledContainer(container);
495 495 return true;
496 496 }
497 497  
... ... @@ -616,7 +616,7 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
616 616 if (transformerManager != null && transformerManager.injectTransformer(classTransformerClass))
617 617 {
618 618 LiteLoaderLogger.info(Verbosity.REDUCED, "classTransformer '%s' was successfully added", classTransformerClass);
619   - container.injectIntoClassPath(this.classLoader, true);
  619 + this.injectContainerRecursive(container);
620 620 }
621 621 }
622 622 }
... ... @@ -625,6 +625,25 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
625 625 }
626 626 }
627 627  
  628 + /**
  629 + * @param container
  630 + */
  631 + private void injectContainerRecursive(Injectable container) throws MalformedURLException
  632 + {
  633 + if (container.injectIntoClassPath(this.classLoader, true) && container instanceof LoadableMod)
  634 + {
  635 + LoadableMod<?> file = (LoadableMod<?>)container;
  636 + for (String dependency : file.getDependencies())
  637 + {
  638 + LoadableMod<?> dependencyContainer = this.containers.getEnabledContainer(dependency);
  639 + if (dependencyContainer != null)
  640 + {
  641 + this.injectContainerRecursive(dependencyContainer);
  642 + }
  643 + }
  644 + }
  645 + }
  646 +
628 647 /* (non-Javadoc)
629 648 * @see com.mumfrey.liteloader.core.PluggableEnumerator#registerMods(com.mumfrey.liteloader.core.LoadableMod, boolean)
630 649 */
... ... @@ -707,6 +726,29 @@ public class LiteLoaderEnumerator implements LoaderEnumerator
707 726 return true;
708 727 }
709 728  
  729 + /**
  730 + * Check dependencies of enabled containers
  731 + */
  732 + private void checkDependencies()
  733 + {
  734 + Collection<? extends LoadableMod<?>> enabledContainers = this.containers.getEnabledContainers();
  735 + Deque<LoadableMod<?>> containers = new LinkedList<LoadableMod<?>>(enabledContainers);
  736 +
  737 + while (containers.size() > 0)
  738 + {
  739 + LoadableMod<?> container = containers.pop();
  740 + if (!this.checkDependencies(container))
  741 + {
  742 + this.registerDisabledContainer(container, DisabledReason.MISSING_DEPENDENCY);
  743 +
  744 + // Iterate so that a container disabled by a failed dependency check will also
  745 + // disable any containers which depend upon it
  746 + containers.clear();
  747 + containers.addAll(enabledContainers);
  748 + }
  749 + }
  750 + }
  751 +
710 752 @Override
711 753 public boolean checkDependencies(LoadableMod<?> container)
712 754 {
... ...