From b484c6ddcd1161526982ffbf0c3dcc091be8067a Mon Sep 17 00:00:00 2001 From: ftbsc Date: Wed, 15 Feb 2023 22:29:56 +0100 Subject: [PATCH] fix: no need to apply patches only once --- README.md | 19 ++++++++++--------- .../java/ftbsc/lll/loader/LilleroLoader.java | 9 ++------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 37352d2..e11fd8f 100644 --- a/README.md +++ b/README.md @@ -36,24 +36,25 @@ Edit your target instance and go into "Versions". Select "Forge", click "Customi { "downloads": { "artifact": { - "sha1": "2af308a2026453c4bfe814b42bb71cb579c32a40", - "size": 1502, - "url": "https://maven.fantabos.co/ftbsc/lll/0.0.5/lll-0.0.5.jar" + "sha1": "7d94cad0cc7e787fe9a2197e60058bd67b74f471", + "size": 13076, + "url": "https://maven.fantabos.co/ftbsc/lll/0.1.2/lll-0.1.2.jar" } }, - "name": "ftbsc:lll:0.0.5" + "name": "ftbsc:lll:0.1.2" }, { "downloads": { "artifact": { - "sha1": "fe23393f61060cacdc2a767ad82057006a923007", - "size": 4568, - "url": "https://maven.fantabos.co/ftbsc/lll/loader/0.0.7/loader-0.0.7.jar" + "sha1": "a11968731cb3400535bde46b387b8e7f9375bb5b", + "size": 4779, + "url": "https://maven.fantabos.co/ftbsc/lll/loader/0.1.2/loader-0.1.2.jar" } }, - "name": "ftbsc.lll:loader:0.0.7" + "name": "ftbsc.lll:loader:0.1.2" }, + ``` ### Vanilla launcher -Not documented yet, but should be possible by messing in a similar way with the version json files. \ No newline at end of file +Not documented yet, but should be possible by messing in a similar way with the version json files. diff --git a/src/main/java/ftbsc/lll/loader/LilleroLoader.java b/src/main/java/ftbsc/lll/loader/LilleroLoader.java index 1db8544..1a881df 100644 --- a/src/main/java/ftbsc/lll/loader/LilleroLoader.java +++ b/src/main/java/ftbsc/lll/loader/LilleroLoader.java @@ -19,11 +19,9 @@ 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 { @@ -36,7 +34,6 @@ public class LilleroLoader implements ILaunchPluginService { public static final String NAME = "lll-loader"; private List injectors = new ArrayList<>(); - private Set applied = new HashSet<>(); public LilleroLoader() { LOGGER.info(INIT, "Patch Loader initialized"); @@ -90,7 +87,7 @@ public class LilleroLoader implements ILaunchPluginService { // 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 (!this.applied.contains(inj) && inj.targetClass().equals(classType.getClassName())) { + if (inj.targetClass().equals(classType.getClassName())) { LOGGER.info(HANDLER, "Marked class {} as handled by {}", classType.getClassName(), LilleroLoader.NAME); return YAY; } @@ -105,7 +102,6 @@ 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 relevantInjectors = this.injectors.stream() - .filter(i -> !this.applied.contains(i)) .filter(i -> i.targetClass().equals(classType.getClassName())) .collect(Collectors.toList()); boolean modified = false; @@ -118,7 +114,6 @@ 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()); @@ -127,6 +122,6 @@ public class LilleroLoader implements ILaunchPluginService { } } - return modified ? ComputeFlags.COMPUTE_FRAMES : ComputeFlags.NO_REWRITE; + return modified ? ComputeFlags.COMPUTE_FRAMES | ComputeFlags.COMPUTE_MAXS : ComputeFlags.NO_REWRITE; } }