fix: no need to apply patches only once

This commit is contained in:
ftbsc 2023-02-15 22:29:56 +01:00
parent 4f7baa6f87
commit b484c6ddcd
2 changed files with 12 additions and 16 deletions

View file

@ -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.
Not documented yet, but should be possible by messing in a similar way with the version json files.

View file

@ -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<IInjector> injectors = new ArrayList<>();
private Set<IInjector> 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<IInjector> 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;
}
}