Open-source multiplayer game server compatible with the RuneScape client
https://www.openrs2.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.9 KiB
59 lines
1.9 KiB
package dev.openrs2.deob.transform;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
import dev.openrs2.asm.Transformer;
|
|
import dev.openrs2.deob.annotation.OriginalClass;
|
|
import dev.openrs2.deob.annotation.OriginalMember;
|
|
import org.objectweb.asm.Type;
|
|
import org.objectweb.asm.tree.AnnotationNode;
|
|
import org.objectweb.asm.tree.ClassNode;
|
|
import org.objectweb.asm.tree.FieldNode;
|
|
import org.objectweb.asm.tree.MethodNode;
|
|
|
|
public final class OriginalNameTransformer extends Transformer {
|
|
private static AnnotationNode createOriginalClassAnnotation(String name) {
|
|
var annotation = new AnnotationNode(Type.getDescriptor(OriginalClass.class));
|
|
annotation.values = List.of("value", name);
|
|
return annotation;
|
|
}
|
|
|
|
private static AnnotationNode createOriginalMemberAnnotation(String owner, String name, String desc) {
|
|
var annotation = new AnnotationNode(Type.getDescriptor(OriginalMember.class));
|
|
annotation.values = List.of(
|
|
"owner", owner,
|
|
"name", name,
|
|
"descriptor", desc
|
|
);
|
|
return annotation;
|
|
}
|
|
|
|
@Override
|
|
public void transformClass(ClassNode clazz) {
|
|
if (clazz.invisibleAnnotations == null) {
|
|
clazz.invisibleAnnotations = new ArrayList<>();
|
|
}
|
|
clazz.invisibleAnnotations.add(createOriginalClassAnnotation(clazz.name));
|
|
}
|
|
|
|
@Override
|
|
public void transformField(ClassNode clazz, FieldNode field) {
|
|
if (field.invisibleAnnotations == null) {
|
|
field.invisibleAnnotations = new ArrayList<>();
|
|
}
|
|
field.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, field.name, field.desc));
|
|
}
|
|
|
|
@Override
|
|
public void transformMethod(ClassNode clazz, MethodNode method) {
|
|
if (method.name.equals("<init>") || method.name.equals("<clinit>")) {
|
|
return;
|
|
}
|
|
|
|
if (method.invisibleAnnotations == null) {
|
|
method.invisibleAnnotations = new ArrayList<>();
|
|
}
|
|
method.invisibleAnnotations.add(createOriginalMemberAnnotation(clazz.name, method.name, method.desc));
|
|
}
|
|
}
|
|
|