Transform objects now use an interface

This commit is contained in:
Giovanni Ruddy Gazivoda
2019-04-18 22:59:00 -04:00
parent a8df0c7c0a
commit 09d2b056f1
4 changed files with 24 additions and 14 deletions

View File

@@ -1,22 +1,15 @@
package net.runelite.client.rs.bytecode.transformers; package net.runelite.client.rs.bytecode.transformers;
import javassist.CannotCompileException;
import javassist.CtClass; import javassist.CtClass;
import javassist.CtMethod; import javassist.CtMethod;
import javassist.CtNewMethod; import javassist.CtNewMethod;
import javassist.NotFoundException; import javassist.NotFoundException;
import net.runelite.client.rs.bytecode.ByteCodePatcher; import net.runelite.client.rs.bytecode.ByteCodePatcher;
import net.runelite.client.rs.bytecode.ByteCodeUtils;
import java.io.File; public class ActorTransform implements Transform {
import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
public class ActorTransform {
public CtClass ct = null; public CtClass ct = null;
@Override
public void modify(Class actor) { public void modify(Class actor) {
try { try {
ct = ByteCodePatcher.classPool.get(actor.getName()); ct = ByteCodePatcher.classPool.get(actor.getName());
@@ -28,6 +21,9 @@ public class ActorTransform {
} }
} }
@Override
public void transform() { }
public void transformGetAnimation() { public void transformGetAnimation() {
try { try {
CtMethod protectedAnimation = ct.getDeclaredMethod("1protect$getRsAnimation"); CtMethod protectedAnimation = ct.getDeclaredMethod("1protect$getRsAnimation");

View File

@@ -5,9 +5,10 @@ import javassist.CtMethod;
import javassist.CtNewMethod; import javassist.CtNewMethod;
import net.runelite.client.rs.bytecode.ByteCodePatcher; import net.runelite.client.rs.bytecode.ByteCodePatcher;
public class PlayerTransform { public class PlayerTransform implements Transform {
public CtClass ct = null; public CtClass ct = null;
@Override
public void modify(Class player) { public void modify(Class player) {
try { try {
ct = ByteCodePatcher.classPool.get(player.getName()); ct = ByteCodePatcher.classPool.get(player.getName());
@@ -19,6 +20,9 @@ public class PlayerTransform {
} }
} }
@Override
public void transform(){}
public void transformProtectedGetSkullIcon() { public void transformProtectedGetSkullIcon() {
CtMethod protectedGetSkullIcon; CtMethod protectedGetSkullIcon;
try { try {

View File

@@ -4,22 +4,23 @@ import javassist.CtClass;
import javassist.CtMethod; import javassist.CtMethod;
import javassist.CtNewMethod; import javassist.CtNewMethod;
import net.runelite.client.rs.bytecode.ByteCodePatcher; import net.runelite.client.rs.bytecode.ByteCodePatcher;
import net.runelite.client.rs.bytecode.ByteCodeUtils;
public class ProjectileTransform { public class ProjectileTransform implements Transform {
public CtClass ct = null; public CtClass ct = null;
@Override
public void modify(Class projectile) { public void modify(Class projectile) {
try { try {
ct = ByteCodePatcher.classPool.get(projectile.getName()); ct = ByteCodePatcher.classPool.get(projectile.getName());
transformProjectileMoved(); transform();
ByteCodePatcher.modifiedClasses.add(ct); ByteCodePatcher.modifiedClasses.add(ct);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
public void transformProjectileMoved() { @Override
public void transform() {
CtMethod getAnimation; CtMethod getAnimation;
try { try {
getAnimation = ct.getDeclaredMethod("projectileMoved", new CtClass[]{CtClass.intType, CtClass.intType, CtClass.intType, CtClass.intType}); getAnimation = ct.getDeclaredMethod("projectileMoved", new CtClass[]{CtClass.intType, CtClass.intType, CtClass.intType, CtClass.intType});
@@ -37,4 +38,5 @@ public class ProjectileTransform {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@@ -0,0 +1,8 @@
package net.runelite.client.rs.bytecode.transformers;
public interface Transform {
void modify(Class clazz);
void transform();
}