diff options
-rw-r--r-- | build.gradle | 2 | ||||
-rw-r--r-- | src/main/java/ftbsc/lll/loader/LilleroLoader.java | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/build.gradle b/build.gradle index ea5792f..2f4a891 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'org.apache.logging.log4j:log4j-core:2.15.0' implementation 'org.ow2.asm:asm-commons:9.4' implementation 'cpw.mods:modlauncher:8.1.3' - implementation 'ftbsc:lll:0.0.5' + implementation 'ftbsc:lll:0.1.1' } // jar { diff --git a/src/main/java/ftbsc/lll/loader/LilleroLoader.java b/src/main/java/ftbsc/lll/loader/LilleroLoader.java index 7f14cd8..1db8544 100644 --- a/src/main/java/ftbsc/lll/loader/LilleroLoader.java +++ b/src/main/java/ftbsc/lll/loader/LilleroLoader.java @@ -19,9 +19,11 @@ import java.net.URLClassLoader; import java.nio.file.Path; import java.util.ArrayList; import java.util.EnumSet; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.ServiceLoader; +import java.util.Set; import java.util.stream.Collectors; public class LilleroLoader implements ILaunchPluginService { @@ -34,6 +36,7 @@ public class LilleroLoader implements ILaunchPluginService { public static final String NAME = "lll-loader"; private List<IInjector> injectors = new ArrayList<>(); + private Set<IInjector> applied = new HashSet<>(); public LilleroLoader() { LOGGER.info(INIT, "Patch Loader initialized"); @@ -85,9 +88,10 @@ public class LilleroLoader implements ILaunchPluginService { public EnumSet<Phase> handlesClass(Type classType, final boolean isEmpty, final String reason) { if (isEmpty) return NAY; // TODO can I make a set of target classes to make this faster + LOGGER.debug(HANDLER, "Inspecting class {}", classType.getClassName()); for (IInjector inj : this.injectors) { - if (inj.targetClass().equals(classType.getClassName())) { - LOGGER.debug(HANDLER, "Marked class {} as handled by {}", classType.getClassName(), LilleroLoader.NAME); + if (!this.applied.contains(inj) && inj.targetClass().equals(classType.getClassName())) { + LOGGER.info(HANDLER, "Marked class {} as handled by {}", classType.getClassName(), LilleroLoader.NAME); return YAY; } } @@ -101,6 +105,7 @@ public class LilleroLoader implements ILaunchPluginService { public int processClassWithFlags(Phase phase, ClassNode classNode, Type classType, String reason) { LOGGER.debug(PATCHER, "Processing class {} in phase {} of {}", classType.getClassName(), phase.name(), reason); List<IInjector> relevantInjectors = this.injectors.stream() + .filter(i -> !this.applied.contains(i)) .filter(i -> i.targetClass().equals(classType.getClassName())) .collect(Collectors.toList()); boolean modified = false; @@ -113,6 +118,7 @@ public class LilleroLoader implements ILaunchPluginService { LOGGER.info(PATCHER, "Patching {}.{} with {} ({})", classType.getClassName(), method.name, inj.name(), inj.reason()); try { inj.inject(classNode, method); + this.applied.add(inj); modified = true; } catch (InjectionException e) { LOGGER.error(PATCHER, "Error applying patch '{}' : {}", inj.name(), e.toString()); |