Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1879 from Lucwousin/inj-stuff
Browse files Browse the repository at this point in the history
Project: move injector to another repository
  • Loading branch information
Owain94 authored Nov 4, 2019
2 parents 103b82b + c2fd19f commit afc48ee
Show file tree
Hide file tree
Showing 85 changed files with 1,914 additions and 7,948 deletions.
32 changes: 17 additions & 15 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,13 @@ import org.ajoberstar.grgit.Grgit
buildscript {
repositories {
maven(url = "https://plugins.gradle.org/m2/")
maven(url = "https://raw.githubusercontent.com/open-osrs/hosting/master")
mavenLocal()
}
dependencies {
classpath(Plugins.grgitPlugin)
classpath(Plugins.versionsPlugin)
classpath(Plugins.injectorPlugin)
}
}

Expand All @@ -57,7 +60,9 @@ fun isNonStable(version: String): Boolean {
}

allprojects {
apply<JavaLibraryPlugin>()
apply<MavenPlugin>()
apply<MavenPublishPlugin>()

group = "com.openosrs"
version = ProjectVersions.rlVersion
Expand All @@ -66,16 +71,23 @@ allprojects {
project.extra["gitCommitShort"] = localGitCommitShort

project.extra["rootPath"] = rootDir.toString().replace("\\", "/")
project.extra["injectedClassesPath"] = "${rootDir}/injector-plugin/out/injected-client/"
}

subprojects {
apply<JavaLibraryPlugin>()
apply<MavenPlugin>()
apply<MavenPublishPlugin>()
apply(plugin = Plugins.testLogger.first)

if (this.name != "rs-client") apply(plugin = "checkstyle")
if (this.name != "runescape-client") {
apply(plugin = "checkstyle")
configure<CheckstyleExtension> {
sourceSets = setOf(project.sourceSets.main.get())
configFile = file("${rootDir}/checkstyle/checkstyle.xml")
configProperties = mapOf("suppressionFile" to file("${rootDir}/checkstyle/suppressions.xml"))
maxWarnings = 0
toolVersion = "6.4.1"
isShowViolations = true
isIgnoreFailures = false
}
}

repositories {
mavenLocal()
Expand All @@ -90,16 +102,6 @@ subprojects {
}
}

configure<CheckstyleExtension> {
sourceSets = setOf(project.sourceSets.main.get())
configFile = file("${rootDir}/checkstyle/checkstyle.xml")
configProperties = mapOf("suppressionFile" to file("${rootDir}/checkstyle/suppressions.xml"))
maxWarnings = 0
toolVersion = "6.4.1"
isShowViolations = true
isIgnoreFailures = false
}

configure<PublishingExtension> {
repositories {
maven {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ object ProjectVersions {
object Plugins {
val grgitPlugin = "org.ajoberstar:grgit:2.3.0"
val versionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.27.0"

val injectorPlugin = "com.openosrs:injector-plugin:1.0.0"
val testLogger = Pair("com.adarshr.test-logger", "2.0.0")
val versions = Pair("com.github.ben-manes.versions", "0.27.0")
val buildScan = Pair("com.gradle.build-scan", "3.0")
Expand Down
7 changes: 4 additions & 3 deletions deobfuscator/deobfuscator.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ dependencies {
deobjars(group = "net.runelite.rs", name = "vanilla", version = ProjectVersions.rsversion.toString())
deobjars(project(":runescape-client"))

implementation(Libraries.gson)
implementation(Libraries.guava)
implementation(Libraries.fernflower)
implementation(Libraries.annotations)
implementation(Libraries.asmAll)
implementation(Libraries.asmUtil)
implementation(Libraries.fernflower)
implementation(Libraries.gson)
implementation(Libraries.guava)
implementation(Libraries.slf4jApi)
implementation(project(":runelite-api"))
implementation(project(":runescape-api"))
Expand Down
17 changes: 17 additions & 0 deletions deobfuscator/src/main/java/net/runelite/asm/Annotated.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package net.runelite.asm;

import java.util.Iterator;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import org.jetbrains.annotations.NotNull;

public interface Annotated extends Iterable<Annotation>
{
Annotations getAnnotations();

@NotNull
default Iterator<Annotation> iterator()
{
return getAnnotations().iterator();
}
}
8 changes: 3 additions & 5 deletions deobfuscator/src/main/java/net/runelite/asm/ClassFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,12 @@
import net.runelite.asm.pool.Class;
import net.runelite.asm.signature.Signature;
import static net.runelite.deob.DeobAnnotations.*;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public class ClassFile
public class ClassFile implements Annotated, Named
{
private ClassGroup group;

Expand Down Expand Up @@ -100,10 +99,9 @@ public void accept(ClassVisitor visitor)
visitor.visit(version, access, name.getName(), null, super_class.getName(), ints);
visitor.visitSource(source, null);

for (Annotation annotation : annotations.getAnnotations())
for (Annotation annotation : annotations)
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
}

for (Field field : fields)
Expand Down
18 changes: 17 additions & 1 deletion deobfuscator/src/main/java/net/runelite/asm/ClassGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.signature.Signature;
import static net.runelite.deob.DeobAnnotations.*;
import org.jetbrains.annotations.NotNull;

public class ClassGroup
public class ClassGroup implements Iterable<ClassFile>
{
private final List<ClassFile> classes = new ArrayList<>(); // to keep order
private final Map<String, ClassFile> classMap = new HashMap<>();
Expand Down Expand Up @@ -156,4 +159,17 @@ public ClassFile findObfuscatedName(String name)

return findClass(name);
}

@NotNull
@Override
public Iterator<ClassFile> iterator()
{
return this.classes.iterator();
}

@Override
public void forEach(Consumer<? super ClassFile> action)
{
this.classes.forEach(action);
}
}
9 changes: 3 additions & 6 deletions deobfuscator/src/main/java/net/runelite/asm/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.deob.DeobAnnotations;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes;

import static org.objectweb.asm.Opcodes.ACC_PRIVATE;
import static org.objectweb.asm.Opcodes.ACC_PROTECTED;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;

public class Field
public class Field implements Annotated, Named
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;

Expand All @@ -53,15 +51,14 @@ public Field(ClassFile classFile, String name, Type type)
this.name = name;
this.type = type;

annotations = new Annotations();
this.annotations = new Annotations();
}

public void accept(FieldVisitor visitor)
{
for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
}

visitor.visitEnd();
Expand Down
10 changes: 9 additions & 1 deletion deobfuscator/src/main/java/net/runelite/asm/Interfaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
package net.runelite.asm;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import net.runelite.asm.pool.Class;
import net.runelite.deob.DeobAnnotations;
import org.jetbrains.annotations.NotNull;

public class Interfaces
public class Interfaces implements Iterable<Class>
{
private final ClassFile classFile;

Expand Down Expand Up @@ -107,4 +109,10 @@ public List<String> getIntfNames()

return names;
}

@NotNull
public Iterator<Class> iterator()
{
return this.interfaces.iterator();
}
}
6 changes: 2 additions & 4 deletions deobfuscator/src/main/java/net/runelite/asm/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import net.runelite.asm.attributes.code.instruction.types.LVTInstruction;
import net.runelite.asm.signature.Signature;
import net.runelite.deob.DeobAnnotations;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
import static org.objectweb.asm.Opcodes.ACC_FINAL;
Expand All @@ -47,7 +46,7 @@
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ACC_SYNCHRONIZED;

public class Method
public class Method implements Annotated, Named
{
public static final int ACCESS_MODIFIERS = ACC_PUBLIC | ACC_PRIVATE | ACC_PROTECTED;

Expand Down Expand Up @@ -92,8 +91,7 @@ public void accept(MethodVisitor visitor)

for (Annotation annotation : annotations.getAnnotations())
{
AnnotationVisitor av = visitor.visitAnnotation(annotation.getType().toString(), true);
annotation.accept(av);
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
}

if (code != null)
Expand Down
6 changes: 6 additions & 0 deletions deobfuscator/src/main/java/net/runelite/asm/Named.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package net.runelite.asm;

public interface Named
{
String getName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,24 @@
package net.runelite.asm.attributes;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.annotation.SimpleElement;
import org.jetbrains.annotations.NotNull;

public class Annotations
public class Annotations implements Iterable<Annotation>
{
private final List<Annotation> annotations = new ArrayList<>();

public List<Annotation> getAnnotations()
{
return annotations;
}

public void addAnnotation(Annotation annotation)
{
annotations.add(annotation);
Expand All @@ -55,7 +58,7 @@ public void clearAnnotations()
{
annotations.clear();
}

public Annotation find(Type type)
{
for (Annotation a : annotations)
Expand All @@ -68,18 +71,22 @@ public int size()
{
return annotations.size();
}

public Annotation addAnnotation(Type type, String name, Object value)
{
Annotation annotation = new Annotation(this);
annotation.setType(type);
Annotation annotation = new Annotation(type);
addAnnotation(annotation);

Element element = new Element(annotation);
element.setName(name);
element.setValue(value);

Element element = new SimpleElement(name, value);
annotation.addElement(element);

return annotation;
}

@NotNull
@Override
public Iterator<Annotation> iterator()
{
return this.annotations.iterator();
}
}
Loading

0 comments on commit afc48ee

Please sign in to comment.