Changed the PatchManager to update automatically
This was really needed, I think the code could be improved but it'd need a different approach from the PatchManager as well, so that's for another time.
This commit is contained in:
parent
9568251ef6
commit
d9f9d27d22
|
@ -19,8 +19,7 @@ import java.lang.reflect.Method;
|
||||||
* 4/4/2019 @ 11:49 PM.
|
* 4/4/2019 @ 11:49 PM.
|
||||||
*/
|
*/
|
||||||
public final class SeppukuClassTransformer implements IClassTransformer {
|
public final class SeppukuClassTransformer implements IClassTransformer {
|
||||||
|
public static PatchManager PATCH_MANAGER = null;
|
||||||
private static final PatchManager PATCH_MANAGER = new PatchManager(PatchManager.Environment.IDE);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every time a class is loaded we can intercept it and modify the bytecode
|
* Every time a class is loaded we can intercept it and modify the bytecode
|
||||||
|
@ -32,6 +31,9 @@ public final class SeppukuClassTransformer implements IClassTransformer {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
public byte[] transform(String name, String transformedName, byte[] basicClass) {
|
||||||
|
if (PATCH_MANAGER == null)
|
||||||
|
return basicClass;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
//find a patch based on the class name
|
//find a patch based on the class name
|
||||||
final ClassPatch patch = PATCH_MANAGER.findClassPatch(name);
|
final ClassPatch patch = PATCH_MANAGER.findClassPatch(name);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.rigamortis.seppuku.impl.fml.core;
|
package me.rigamortis.seppuku.impl.fml.core;
|
||||||
|
|
||||||
|
import me.rigamortis.seppuku.impl.management.PatchManager;
|
||||||
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
import net.minecraftforge.fml.relauncher.IFMLLoadingPlugin;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -33,11 +34,13 @@ public final class SeppukuLoadingPlugin implements IFMLLoadingPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectData(Map<String, Object> data) {
|
public void injectData(Map<String, Object> data) {
|
||||||
|
final boolean runtimeDeobfuscationEnabled =
|
||||||
|
(boolean) data.getOrDefault("runtimeDeobfuscationEnabled", false);
|
||||||
|
SeppukuClassTransformer.PATCH_MANAGER = new PatchManager(!runtimeDeobfuscationEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAccessTransformerClass() {
|
public String getAccessTransformerClass() {
|
||||||
return SeppukuAccessTransformer.class.getName();
|
return SeppukuAccessTransformer.class.getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ public final class PatchManager {
|
||||||
|
|
||||||
private Environment env;
|
private Environment env;
|
||||||
|
|
||||||
public PatchManager(Environment env) {
|
public PatchManager(final boolean devEnv) {
|
||||||
//set our environment for mappings
|
//set our environment for mappings
|
||||||
this.setEnv(env);
|
this.setEnv(devEnv ? Environment.IDE : Environment.RELEASE);
|
||||||
|
|
||||||
//add internal patches
|
//add internal patches
|
||||||
this.patchList.add(new MinecraftPatch());
|
this.patchList.add(new MinecraftPatch());
|
||||||
|
|
Loading…
Reference in New Issue