mirror of
https://github.com/zaaarf/lillero-loader.git
synced 2024-11-21 20:44:48 +01:00
fix: no need to apply patches only once
This commit is contained in:
parent
4f7baa6f87
commit
b484c6ddcd
2 changed files with 12 additions and 16 deletions
19
README.md
19
README.md
|
@ -36,24 +36,25 @@ Edit your target instance and go into "Versions". Select "Forge", click "Customi
|
||||||
{
|
{
|
||||||
"downloads": {
|
"downloads": {
|
||||||
"artifact": {
|
"artifact": {
|
||||||
"sha1": "2af308a2026453c4bfe814b42bb71cb579c32a40",
|
"sha1": "7d94cad0cc7e787fe9a2197e60058bd67b74f471",
|
||||||
"size": 1502,
|
"size": 13076,
|
||||||
"url": "https://maven.fantabos.co/ftbsc/lll/0.0.5/lll-0.0.5.jar"
|
"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": {
|
"downloads": {
|
||||||
"artifact": {
|
"artifact": {
|
||||||
"sha1": "fe23393f61060cacdc2a767ad82057006a923007",
|
"sha1": "a11968731cb3400535bde46b387b8e7f9375bb5b",
|
||||||
"size": 4568,
|
"size": 4779,
|
||||||
"url": "https://maven.fantabos.co/ftbsc/lll/loader/0.0.7/loader-0.0.7.jar"
|
"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
|
### 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.
|
||||||
|
|
|
@ -19,11 +19,9 @@ import java.net.URLClassLoader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class LilleroLoader implements ILaunchPluginService {
|
public class LilleroLoader implements ILaunchPluginService {
|
||||||
|
@ -36,7 +34,6 @@ public class LilleroLoader implements ILaunchPluginService {
|
||||||
public static final String NAME = "lll-loader";
|
public static final String NAME = "lll-loader";
|
||||||
|
|
||||||
private List<IInjector> injectors = new ArrayList<>();
|
private List<IInjector> injectors = new ArrayList<>();
|
||||||
private Set<IInjector> applied = new HashSet<>();
|
|
||||||
|
|
||||||
public LilleroLoader() {
|
public LilleroLoader() {
|
||||||
LOGGER.info(INIT, "Patch Loader initialized");
|
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
|
// TODO can I make a set of target classes to make this faster
|
||||||
LOGGER.debug(HANDLER, "Inspecting class {}", classType.getClassName());
|
LOGGER.debug(HANDLER, "Inspecting class {}", classType.getClassName());
|
||||||
for (IInjector inj : this.injectors) {
|
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);
|
LOGGER.info(HANDLER, "Marked class {} as handled by {}", classType.getClassName(), LilleroLoader.NAME);
|
||||||
return YAY;
|
return YAY;
|
||||||
}
|
}
|
||||||
|
@ -105,7 +102,6 @@ public class LilleroLoader implements ILaunchPluginService {
|
||||||
public int processClassWithFlags(Phase phase, ClassNode classNode, Type classType, String reason) {
|
public int processClassWithFlags(Phase phase, ClassNode classNode, Type classType, String reason) {
|
||||||
LOGGER.debug(PATCHER, "Processing class {} in phase {} of {}", classType.getClassName(), phase.name(), reason);
|
LOGGER.debug(PATCHER, "Processing class {} in phase {} of {}", classType.getClassName(), phase.name(), reason);
|
||||||
List<IInjector> relevantInjectors = this.injectors.stream()
|
List<IInjector> relevantInjectors = this.injectors.stream()
|
||||||
.filter(i -> !this.applied.contains(i))
|
|
||||||
.filter(i -> i.targetClass().equals(classType.getClassName()))
|
.filter(i -> i.targetClass().equals(classType.getClassName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
boolean modified = false;
|
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());
|
LOGGER.info(PATCHER, "Patching {}.{} with {} ({})", classType.getClassName(), method.name, inj.name(), inj.reason());
|
||||||
try {
|
try {
|
||||||
inj.inject(classNode, method);
|
inj.inject(classNode, method);
|
||||||
this.applied.add(inj);
|
|
||||||
modified = true;
|
modified = true;
|
||||||
} catch (InjectionException e) {
|
} catch (InjectionException e) {
|
||||||
LOGGER.error(PATCHER, "Error applying patch '{}' : {}", inj.name(), e.toString());
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue