Merge branch 'master' into widget

This commit is contained in:
Kyle
2020-08-14 23:43:10 +01:00
committed by GitHub
506 changed files with 5591 additions and 5340 deletions
+12
View File
@@ -0,0 +1,12 @@
name: Release Drafter
on: repository_dispatch
jobs:
update_draft_release:
runs-on: ubuntu-latest
steps:
- uses: ThatGamerBlue/release-drafter@v5.7.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+14 -5
View File
@@ -29,19 +29,19 @@ import org.ajoberstar.grgit.Grgit
buildscript { buildscript {
repositories { repositories {
gradlePluginPortal() gradlePluginPortal()
mavenLocal() maven(url = "https://repo.openosrs.com/repository/maven/")
maven(url = "https://raw.githubusercontent.com/open-osrs/hosting/master") maven(url = "https://raw.githubusercontent.com/open-osrs/hosting/master")
} }
dependencies { dependencies {
classpath("org.ajoberstar.grgit:grgit-core:4.0.2") classpath("org.ajoberstar.grgit:grgit-core:4.0.2")
classpath("com.github.ben-manes:gradle-versions-plugin:0.28.0") classpath("com.github.ben-manes:gradle-versions-plugin:0.29.0")
classpath("com.openosrs:injector-plugin:1.1.2") classpath("com.openosrs:injector-plugin:1.1.5")
} }
} }
plugins { plugins {
id("com.adarshr.test-logger") version "2.0.0" apply false id("com.adarshr.test-logger") version "2.1.0" apply false
id("com.github.ben-manes.versions") version "0.28.0" id("com.github.ben-manes.versions") version "0.29.0"
id("se.patrikerdes.use-latest-versions") version "0.2.14" id("se.patrikerdes.use-latest-versions") version "0.2.14"
id("org.ajoberstar.grgit") version "4.0.2" id("org.ajoberstar.grgit") version "4.0.2"
id("com.simonharrer.modernizer") version "2.1.0-1" apply false id("com.simonharrer.modernizer") version "2.1.0-1" apply false
@@ -169,6 +169,13 @@ subprojects {
withSourcesJar() withSourcesJar()
} }
withType<AbstractArchiveTask> {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = 493
fileMode = 420
}
withType<JavaCompile> { withType<JavaCompile> {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
@@ -195,6 +202,8 @@ subprojects {
} }
} }
} }
configurations["compileOnly"].extendsFrom(configurations["annotationProcessor"])
} }
application { application {
@@ -15,6 +15,7 @@ class BootstrapPlugin : Plugin<Project> {
bootstrapDependencies(project(":runescape-api")) bootstrapDependencies(project(":runescape-api"))
bootstrapDependencies(project(":http-api")) bootstrapDependencies(project(":http-api"))
bootstrapDependencies(project(":injected-client")) bootstrapDependencies(project(":injected-client"))
bootstrapDependencies(project(":runelite-client"))
} }
tasks.register<BootstrapTask>("bootstrapStaging", "staging") tasks.register<BootstrapTask>("bootstrapStaging", "staging")
+2 -2
View File
@@ -25,9 +25,9 @@
object ProjectVersions { object ProjectVersions {
const val launcherVersion = "2.2.0" const val launcherVersion = "2.2.0"
const val rlVersion = "1.6.21" const val rlVersion = "1.6.24"
const val openosrsVersion = "3.3.9" const val openosrsVersion = "3.4.2"
const val rsversion = 190 const val rsversion = 190
const val cacheversion = 165 const val cacheversion = 165
+2 -1
View File
@@ -41,7 +41,8 @@ dependencies {
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6")
implementation(group = "com.google.guava", name = "guava", version = "29.0-jre") implementation(group = "com.google.guava", name = "guava", version = "29.0-jre")
implementation(group = "commons-cli", name = "commons-cli", version = "1.4") implementation(group = "commons-cli", name = "commons-cli", version = "1.4")
implementation(group = "io.netty", name = "netty-buffer", version = "4.1.50.Final") implementation(group = "io.netty", name = "netty-buffer", version = "4.1.51.Final")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.8.0")
implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.8-1") implementation(group = "org.antlr", name = "antlr4-runtime", version = "4.8-1")
implementation(group = "org.apache.commons", name = "commons-compress", version = "1.20") implementation(group = "org.apache.commons", name = "commons-compress", version = "1.20")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30")
@@ -31,13 +31,13 @@ public class HealthBarDefinition
{ {
public int id; public int id;
public int field3276; public int field3276;
public int field3277; public int field3277 = 255;
public int field3278; public int field3278 = 255;
public int field3283; public int field3283 = -1;
public int field3272; public int field3272 = 1;
public int field3275; public int field3275 = 70;
public int healthBarFrontSpriteId; public int healthBarFrontSpriteId = -1;
public int healthBarBackSpriteId; public int healthBarBackSpriteId = -1;
public int healthScale; public int healthScale = 30;
public int healthBarPadding; public int healthBarPadding = 0;
} }
@@ -98,9 +98,10 @@ public class RegionLoader
Region region = new Region(i); Region region = new Region(i);
region.loadTerrain(mapDef); region.loadTerrain(mapDef);
int[] keys = keyManager.getKeys(i); Integer[] keysTmp = keyManager.getKeys(i);
if (keys != null) if (keysTmp != null)
{ {
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
try try
{ {
data = land.decompress(storage.loadArchive(land), keys); data = land.decompress(storage.loadArchive(land), keys);
@@ -24,8 +24,11 @@
*/ */
package net.runelite.cache.util; package net.runelite.cache.util;
import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import net.runelite.http.api.RuneLiteAPI;
import net.runelite.http.api.xtea.XteaClient;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -33,14 +36,25 @@ public class XteaKeyManager
{ {
private static final Logger logger = LoggerFactory.getLogger(XteaKeyManager.class); private static final Logger logger = LoggerFactory.getLogger(XteaKeyManager.class);
private final Map<Integer, int[]> keys = new HashMap<>(); private Map<Integer, Integer[]> keys = new HashMap<>();
public void loadKeys() public void loadKeys()
{ {
XteaClient xteaClient = new XteaClient(RuneLiteAPI.CLIENT);
try
{
keys = xteaClient.get();
}
catch (IOException e)
{
e.printStackTrace();
}
logger.info("Loaded {} keys", keys.size());
} }
public int[] getKeys(int region) public Integer[] getKeys(int region)
{ {
return keys.get(region); return keys.get(region);
} }
+6 -4
View File
@@ -76,7 +76,7 @@ public class MapDumperTest
for (int i = 0; i < MAX_REGIONS; i++) for (int i = 0; i < MAX_REGIONS; i++)
{ {
int[] keys = keyManager.getKeys(i); Integer[] keysTmp = keyManager.getKeys(i);
int x = i >> 8; int x = i >> 8;
int y = i & 0xFF; int y = i & 0xFF;
@@ -95,8 +95,9 @@ public class MapDumperTest
Files.write(data, new File(outDir, "m" + x + "_" + y + ".dat")); Files.write(data, new File(outDir, "m" + x + "_" + y + ".dat"));
if (keys != null) if (keysTmp != null)
{ {
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
try try
{ {
data = land.decompress(storage.loadArchive(land), keys); data = land.decompress(storage.loadArchive(land), keys);
@@ -142,9 +143,10 @@ public class MapDumperTest
MapDefinition mapDef = new MapLoader().load(x, y, data); MapDefinition mapDef = new MapLoader().load(x, y, data);
LocationsDefinition locDef = null; LocationsDefinition locDef = null;
int[] keys = keyManager.getKeys(i); Integer[] keysTmp = keyManager.getKeys(i);
if (keys != null) if (keysTmp != null)
{ {
int[] keys = {keysTmp[0], keysTmp[1], keysTmp[2], keysTmp[3]};
try try
{ {
data = land.decompress(storage.loadArchive(land), keys); data = land.decompress(storage.loadArchive(land), keys);
+6 -3
View File
@@ -35,7 +35,9 @@ dependencies {
deobjars(group = "net.runelite.rs", name = "vanilla", version = ProjectVersions.rsversion.toString()) deobjars(group = "net.runelite.rs", name = "vanilla", version = ProjectVersions.rsversion.toString())
deobjars(project(":runescape-client")) deobjars(project(":runescape-client"))
implementation(group = "org.jetbrains", name = "annotations", version = "19.0.0") annotationProcessor(group = "org.projectlombok", name = "lombok", version = "1.18.12")
implementation(group = "org.jetbrains", name = "annotations", version = "20.0.0")
implementation(group = "org.ow2.asm", name = "asm", version = "8.0.1") implementation(group = "org.ow2.asm", name = "asm", version = "8.0.1")
implementation(group = "org.ow2.asm", name = "asm-util", version = "8.0.1") implementation(group = "org.ow2.asm", name = "asm-util", version = "8.0.1")
implementation(group = "net.runelite", name = "fernflower", version = "07082019") implementation(group = "net.runelite", name = "fernflower", version = "07082019")
@@ -49,7 +51,7 @@ dependencies {
testImplementation(deobjars) testImplementation(deobjars)
testImplementation(group = "junit", name = "junit", version = "4.13") testImplementation(group = "junit", name = "junit", version = "4.13")
testImplementation(group = "org.mockito", name = "mockito-core", version = "3.3.3") testImplementation(group = "org.mockito", name = "mockito-core", version = "3.4.6")
} }
tasks { tasks {
@@ -90,7 +92,7 @@ tasks {
filter(ReplaceTokens::class, "tokens" to tokens) filter(ReplaceTokens::class, "tokens" to tokens)
filteringCharset = "UTF-8" filteringCharset = "UTF-8"
} }
// TODO: Enable assertions on all 3
register<JavaExec>("Downloader.main()") { register<JavaExec>("Downloader.main()") {
group = "gamepack" group = "gamepack"
@@ -103,6 +105,7 @@ tasks {
classpath = project.sourceSets.main.get().runtimeClasspath classpath = project.sourceSets.main.get().runtimeClasspath
main = "net.runelite.deob.Deob" main = "net.runelite.deob.Deob"
args = listOf(tokens["vanilla.jar"], "$buildDir/libs/deobfuscated-$version.jar")
} }
register<JavaExec>("UpdateMappings.main()") { register<JavaExec>("UpdateMappings.main()") {
@@ -1,17 +0,0 @@
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();
}
}
@@ -0,0 +1,217 @@
/*
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Opcodes;
/**
* Note: this class has a natural ordering that is inconsistent with equals.
*/
public class Annotation extends AnnotationVisitor implements Comparable<Annotation>
{
/**
* Name:Value pairs in this annotation. Uses a tree map to make order reproducible.
*
* Data can be any of the following:
* - Primitive values
* - Strings
* - Class objects
* - Enum constants (not implemented)
* - Arrays of any of the above (use {@link ArrayList}
* - Other Annotations
*/
private final TreeMap<String, Object> data = new TreeMap<>();
private final Type type;
/**
* Unused for now but here for easy implementation later if anyone wants to
*/
private final boolean visible;
public Annotation(Type type)
{
this(type, true);
}
public Annotation(Type type, Object val)
{
this(type);
this.setElement(val);
}
public Annotation(Type type, boolean visible)
{
super(Opcodes.ASM5);
this.type = type;
this.visible = visible;
}
public Type getType()
{
return type;
}
public void addElement(String name, Object value)
{
if (data.put(name, value) != null)
throw new IllegalStateException("The annotation already contains a value mapped to " + name);
}
public void addElement(Object value)
{
addElement("value", value);
}
public void setElement(String name, Object value)
{
data.put(name, value);
}
public void setElement(Object value)
{
setElement("value", value);
}
public Object remove(String name)
{
return data.remove(name);
}
public Object get(String name)
{
return data.get(name);
}
public Object getValue()
{
return get("value");
}
public String getValueString()
{
return (String) getValue();
}
public int size()
{
return data.size();
}
@Override
public void visit(String name, Object value)
{
data.put(name, value);
}
@Override
public AnnotationVisitor visitAnnotation(String name, String descriptor)
{
final var annotation = new Annotation(new Type(descriptor));
data.put(name, annotation);
return annotation;
}
@Override
public AnnotationVisitor visitArray(String name)
{
final var lst = new ArrayList<>();
data.put(name, lst);
return new AnnotationVisitor(Opcodes.ASM5)
{
@Override
public void visit(String name, Object value)
{
lst.add(value);
}
@Override
public AnnotationVisitor visitAnnotation(String name, String descriptor)
{
Annotation annotation = new Annotation(new Type(descriptor));
lst.add(annotation);
return annotation;
}
};
}
public void accept(AnnotationVisitor visitor)
{
if (visitor == null)
return;
for (var entry : data.entrySet())
accept(visitor, entry.getKey(), entry.getValue());
visitor.visitEnd();
}
private static void accept(AnnotationVisitor visitor, final String name, final Object value)
{
if (visitor == null)
return;
if (value instanceof Annotation)
{
Annotation annotation = (Annotation) value;
annotation.accept(visitor.visitAnnotation(name, annotation.getType().toString()));
}
else if (value instanceof List)
{
AnnotationVisitor arr = visitor.visitArray(name);
List<?> arrayValue = (List<?>) value;
for (Object o : arrayValue)
{
accept(arr, null, o);
}
arr.visitEnd();
}
else
{
visitor.visit(name, value);
}
}
@Override
public int compareTo(@NotNull Annotation that)
{
return this.type.toString().compareTo(that.type.toString());
}
@Override
public String toString()
{
StringBuilder str = new StringBuilder('@' + type.toAsmString().replace('/', '.') + '(');
for (Map.Entry<String, Object> e : data.entrySet())
str.append(e.getKey()).append('=').append(e.getValue().toString());
str.append(')');
return str.toString();
}
}
@@ -25,9 +25,11 @@
package net.runelite.asm; package net.runelite.asm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import net.runelite.asm.attributes.Annotations; import java.util.Map;
import net.runelite.asm.attributes.annotation.Annotation; import lombok.Getter;
import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.pool.Class; import net.runelite.asm.pool.Class;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import static net.runelite.deob.DeobAnnotations.*; import static net.runelite.deob.DeobAnnotations.*;
@@ -51,14 +53,14 @@ public class ClassFile implements Annotated, Named
private final Interfaces interfaces; private final Interfaces interfaces;
private final List<Field> fields = new ArrayList<>(); private final List<Field> fields = new ArrayList<>();
private final List<Method> methods = new ArrayList<>(); private final List<Method> methods = new ArrayList<>();
private final Annotations annotations; @Getter
private final Map<Type, Annotation> annotations = new LinkedHashMap<>();
public ClassFile(ClassGroup group) public ClassFile(ClassGroup group)
{ {
this.group = group; this.group = group;
interfaces = new Interfaces(this); interfaces = new Interfaces(this);
annotations = new Annotations();
} }
public ClassFile() public ClassFile()
@@ -99,7 +101,7 @@ public class ClassFile implements Annotated, Named
visitor.visit(version, access, name.getName(), null, super_class.getName(), ints); visitor.visit(version, access, name.getName(), null, super_class.getName(), ints);
visitor.visitSource(source, null); visitor.visitSource(source, null);
for (Annotation annotation : annotations) for (Annotation annotation : annotations.values())
{ {
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true)); annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
} }
@@ -170,11 +172,6 @@ public class ClassFile implements Annotated, Named
methods.remove(method); methods.remove(method);
} }
public Annotations getAnnotations()
{
return annotations;
}
public String getName() public String getName()
{ {
return name.getName(); return name.getName();
@@ -312,7 +309,7 @@ public class ClassFile implements Annotated, Named
for (Method m : methods) for (Method m : methods)
{ {
if (m.isStatic() && if (m.isStatic() &&
name.equals(getObfuscatedName(m.getAnnotations())) && name.equals(getObfuscatedName(m)) &&
type.equals(getObfuscatedSignature(m))) type.equals(getObfuscatedSignature(m)))
{ {
return m; return m;
@@ -151,7 +151,7 @@ public class ClassGroup implements Iterable<ClassFile>
{ {
for (ClassFile cf : classes) for (ClassFile cf : classes)
{ {
if (name.equals(getObfuscatedName(cf.getAnnotations()))) if (name.equals(getObfuscatedName(cf)))
{ {
return cf; return cf;
} }
@@ -24,8 +24,10 @@
*/ */
package net.runelite.asm; package net.runelite.asm;
import net.runelite.asm.attributes.Annotations; import java.util.LinkedHashMap;
import net.runelite.asm.attributes.annotation.Annotation; import java.util.Map;
import lombok.Getter;
import net.runelite.asm.attributes.Annotated;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.Opcodes; import org.objectweb.asm.Opcodes;
@@ -43,20 +45,19 @@ public class Field implements Annotated, Named
private String name; private String name;
private Type type; private Type type;
private Object value; // ConstantValue private Object value; // ConstantValue
private final Annotations annotations; @Getter
private final Map<Type, Annotation> annotations = new LinkedHashMap<>();
public Field(ClassFile classFile, String name, Type type) public Field(ClassFile classFile, String name, Type type)
{ {
this.classFile = classFile; this.classFile = classFile;
this.name = name; this.name = name;
this.type = type; this.type = type;
this.annotations = new Annotations();
} }
public void accept(FieldVisitor visitor) public void accept(FieldVisitor visitor)
{ {
for (Annotation annotation : annotations.getAnnotations()) for (Annotation annotation : annotations.values())
{ {
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true)); annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
} }
@@ -150,15 +151,10 @@ public class Field implements Annotated, Named
this.value = value; this.value = value;
} }
public Annotations getAnnotations()
{
return annotations;
}
public net.runelite.asm.pool.Field getPoolField() public net.runelite.asm.pool.Field getPoolField()
{ {
return new net.runelite.asm.pool.Field( return new net.runelite.asm.pool.Field(
new net.runelite.asm.pool.Class(classFile.getName()), classFile.getPoolClass(),
this.getName(), this.getName(),
this.getType() this.getType()
); );
@@ -98,7 +98,7 @@ public class Interfaces implements Iterable<Class>
final List<String> names = new ArrayList<>(); final List<String> names = new ArrayList<>();
for (ClassFile c : getMyInterfaces()) for (ClassFile c : getMyInterfaces())
{ {
String name = DeobAnnotations.getObfuscatedName(c.getAnnotations()); String name = DeobAnnotations.getObfuscatedName(c);
if (name == null) if (name == null)
{ {
continue; continue;
@@ -25,11 +25,13 @@
package net.runelite.asm; package net.runelite.asm;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import net.runelite.asm.attributes.Annotations; import java.util.Map;
import lombok.Getter;
import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.Exceptions; import net.runelite.asm.attributes.Exceptions;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.LocalVariable; import net.runelite.asm.attributes.code.LocalVariable;
import net.runelite.asm.attributes.code.Parameter; import net.runelite.asm.attributes.code.Parameter;
@@ -55,8 +57,9 @@ public class Method implements Annotated, Named
private int accessFlags; private int accessFlags;
private String name; private String name;
private Signature arguments; private Signature arguments;
private Exceptions exceptions; private final Exceptions exceptions;
private Annotations annotations; @Getter
private final Map<Type, Annotation> annotations = new LinkedHashMap<>();
private List<Parameter> parameters; private List<Parameter> parameters;
private Code code; private Code code;
@@ -66,7 +69,6 @@ public class Method implements Annotated, Named
this.name = name; this.name = name;
this.arguments = signature; this.arguments = signature;
exceptions = new Exceptions(); exceptions = new Exceptions();
annotations = new Annotations();
parameters = new ArrayList<>(); parameters = new ArrayList<>();
} }
@@ -89,7 +91,7 @@ public class Method implements Annotated, Named
visitor.visitParameter(p.getName(), p.getAccess()); visitor.visitParameter(p.getName(), p.getAccess());
} }
for (Annotation annotation : annotations.getAnnotations()) for (Annotation annotation : annotations.values())
{ {
annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true)); annotation.accept(visitor.visitAnnotation(annotation.getType().toString(), true));
} }
@@ -277,11 +279,6 @@ public class Method implements Annotated, Named
this.code = code; this.code = code;
} }
public Annotations getAnnotations()
{
return annotations;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Instruction & LVTInstruction> List<T> findLVTInstructionsForVariable(int index) public <T extends Instruction & LVTInstruction> List<T> findLVTInstructionsForVariable(int index)
{ {
@@ -313,7 +310,7 @@ public class Method implements Annotated, Named
public net.runelite.asm.pool.Method getPoolMethod() public net.runelite.asm.pool.Method getPoolMethod()
{ {
return new net.runelite.asm.pool.Method( return new net.runelite.asm.pool.Method(
new net.runelite.asm.pool.Class(classFile.getName()), classFile.getPoolClass(),
name, name,
arguments arguments
); );
@@ -0,0 +1,51 @@
package net.runelite.asm.attributes;
import java.util.Map;
import net.runelite.asm.Annotation;
import net.runelite.asm.Type;
/**
* Objects implementing this only have to implement getAnnotations.
*/
public interface Annotated
{
Map<Type, Annotation> getAnnotations();
default Annotation findAnnotation(Type type, boolean createNew)
{
if (createNew)
return getAnnotations().computeIfAbsent(type, Annotation::new);
else
return getAnnotations().get(type);
}
default Annotation findAnnotation(Type type)
{
return findAnnotation(type, false);
}
default void addAnnotation(Annotation annotation)
{
if (getAnnotations().put(annotation.getType(), annotation) != null)
throw new IllegalStateException("Annotation with type " + annotation.getType() + " already exists");
}
default void addAnnotation(Type type)
{
if (getAnnotations().put(type, new Annotation(type)) != null)
throw new IllegalStateException("Annotation with type " + type + " already exists");
}
default void addAnnotation(Type type, Object val)
{
getAnnotations().put(type, new Annotation(type, val));
}
default void addAnnotation(Type type, String key, Object val)
{
final var a = new Annotation(type);
a.setElement(key, val);
if (getAnnotations().put(type, a) != null)
throw new IllegalStateException("Annotation with type " + type + " already exists");
}
}
@@ -1,91 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
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 implements Iterable<Annotation>
{
private final List<Annotation> annotations = new ArrayList<>();
public List<Annotation> getAnnotations()
{
return annotations;
}
public void addAnnotation(Annotation annotation)
{
annotations.add(annotation);
}
public void removeAnnotation(Annotation annotation)
{
annotations.remove(annotation);
}
public void clearAnnotations()
{
annotations.clear();
}
public Annotation find(Type type)
{
for (Annotation a : annotations)
if (a.getType().equals(type))
return a;
return null;
}
public int size()
{
return annotations.size();
}
public Annotation addAnnotation(Type type, String name, Object value)
{
Annotation annotation = new Annotation(type);
addAnnotation(annotation);
Element element = new SimpleElement(name, value);
annotation.addElement(element);
return annotation;
}
@NotNull
@Override
public Iterator<Annotation> iterator()
{
return this.annotations.iterator();
}
}
@@ -1,99 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.attributes.annotation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.runelite.asm.Type;
import org.jetbrains.annotations.NotNull;
import org.objectweb.asm.AnnotationVisitor;
public class Annotation extends Element<List<Element>> implements Iterable<Element>
{
private final Type type;
public Annotation(Type type)
{
this.value = new ArrayList<>();
this.type = type;
}
public Annotation(String name, Type type)
{
this.value = new ArrayList<>();
this.name = name;
this.type = type;
}
public Type getType()
{
return type;
}
public List<Element> getElements()
{
return value;
}
public Element getElement()
{
return value.get(0);
}
public void addElement(Element element)
{
value.add(element);
}
@Override
public final void setValue(List<Element> value)
{
throw new UnsupportedOperationException();
}
public void accept(AnnotationVisitor visitor)
{
if (visitor == null)
{
return;
}
for (Element element : this)
{
accept(visitor, element.name, element.value);
}
visitor.visitEnd();
}
@NotNull
@Override
public Iterator<Element> iterator()
{
return this.value.iterator();
}
}
@@ -1,42 +0,0 @@
package net.runelite.asm.attributes.annotation;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
public class ArrayElement extends Element<List> implements Iterable<Object>
{
public ArrayElement(String name)
{
this.name = name;
this.value = new ArrayList<>();
}
@SuppressWarnings("unchecked")
public void addValue(Object value)
{
this.value.add(value);
}
@Override
public final void setValue(List value)
{
throw new UnsupportedOperationException();
}
@NotNull
@Override
@SuppressWarnings("unchecked")
public Iterator<Object> iterator()
{
return this.value.iterator();
}
@SuppressWarnings("unchecked")
public Stream<Object> stream()
{
return this.value.stream();
}
}
@@ -1,15 +0,0 @@
package net.runelite.asm.attributes.annotation;
public class SimpleElement extends Element<Object>
{
public SimpleElement(Object value)
{
this.value = value;
}
public SimpleElement(String name, Object value)
{
this.name = name;
this.value = value;
}
}
@@ -204,6 +204,18 @@ public class Execution
this.addFrame(f); this.addFrame(f);
} }
public void addMethods(Iterable<Method> methods)
{
for (Method m : methods)
{
if (m.getCode() == null)
continue;
Frame f = new Frame(this, m);
f.initialize();
this.addFrame(f);
}
}
public void run() public void run()
{ {
assert !paused; assert !paused;
@@ -28,20 +28,17 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.runelite.asm.Type; import net.runelite.asm.Type;
public class Signature public class Signature
{ {
private static Pattern paramRetPattern = Pattern.compile("\\((.*)\\)(.*)"), private static final Pattern RLAPITORSAPI = Pattern.compile("net/runelite/(rs/)?api/(RS)?");
paramsPattern = Pattern.compile("(\\[*(?:B|C|Z|S|I|J|F|D|(?:L[^;]*;)))");
private final List<Type> arguments; private final List<Type> arguments;
private final Type rv; private final Type rv;
private Signature(List<Type> arguments, Type rv) public Signature(List<Type> arguments, Type rv)
{ {
this.arguments = new ArrayList<>(arguments); this.arguments = new ArrayList<>(arguments);
this.rv = rv; this.rv = rv;
@@ -49,23 +46,12 @@ public class Signature
public Signature(String str) public Signature(String str)
{ {
Matcher m = paramRetPattern.matcher(str); final int rvStart = str.indexOf(')');
if (!m.find()) if (rvStart == -1)
{ throw new IllegalArgumentException("Descriptor has no return value!");
throw new IllegalArgumentException("Signature has no arguments");
}
String args = m.group(1), ret = m.group(2); rv = new Type(str.substring(rvStart + 1));
arguments = findArgs(str, new ArrayList<>(), str.indexOf('(') + 1, rvStart);
m = paramsPattern.matcher(args);
arguments = new ArrayList<>();
while (m.find())
{
String arg = m.group(1);
arguments.add(new Type(arg));
}
rv = new Type(ret);
} }
public Signature(Signature other) public Signature(Signature other)
@@ -74,6 +60,21 @@ public class Signature
rv = other.rv; rv = other.rv;
} }
private static List<Type> findArgs(final String str, final List<Type> ret, final int from, final int to)
{
if (from >= to) return ret;
int i = from;
while (str.charAt(i) == '[') ++i;
if (str.charAt(i) == 'L')
i = str.indexOf(';', i);
ret.add(new Type(str.substring(from, ++i)));
return findArgs(str, ret, i, to);
}
@Override @Override
public boolean equals(Object other) public boolean equals(Object other)
{ {
@@ -82,17 +83,13 @@ public class Signature
return false; return false;
} }
Signature a = (Signature) other; return this.toString().equals(other.toString());
return arguments.equals(a.arguments) && rv.equals(a.rv);
} }
@Override @Override
public int hashCode() public int hashCode()
{ {
int hash = 5; return this.toString().hashCode();
hash = 97 * hash + Objects.hashCode(this.arguments);
hash = 97 * hash + Objects.hashCode(this.rv);
return hash;
} }
@Override @Override
@@ -176,6 +173,6 @@ public class Signature
public Signature rsApiToRsClient() public Signature rsApiToRsClient()
{ {
return new Signature(this.toString().replaceAll("net/runelite/(rs/)?api/(RS)?", "")); return new Signature(RLAPITORSAPI.matcher(this.toString()).replaceAll(""));
} }
} }
@@ -1,83 +0,0 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.asm.visitors;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.ArrayElement;
import net.runelite.asm.attributes.annotation.SimpleElement;
import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Opcodes;
public class AnnotationElementVisitor extends AnnotationVisitor
{
private final Annotation annotation;
AnnotationElementVisitor(Annotation annotation)
{
super(Opcodes.ASM5);
this.annotation = annotation;
}
@Override
public void visit(String name, Object value)
{
SimpleElement element = new SimpleElement(name, value);
annotation.addElement(element);
}
@Override
public AnnotationVisitor visitArray(String name)
{
ArrayElement element = new ArrayElement(name);
this.annotation.addElement(element);
return new AnnotationVisitor(Opcodes.ASM5)
{
@Override
public void visit(String name, Object value)
{
element.addValue(value);
}
@Override
public AnnotationVisitor visitAnnotation(String name, String descriptor)
{
Annotation annotation = new Annotation(name, new Type(descriptor));
element.addValue(annotation);
return new AnnotationElementVisitor(annotation);
}
};
}
@Override
public AnnotationVisitor visitAnnotation(String name, String descriptor)
{
Annotation annotation = new Annotation(name, new Type(descriptor));
this.annotation.addElement(annotation);
return new AnnotationElementVisitor(annotation);
}
}
@@ -27,7 +27,7 @@ package net.runelite.asm.visitors;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.Annotation;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.Attribute; import org.objectweb.asm.Attribute;
import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.FieldVisitor;
@@ -51,9 +51,9 @@ public class ClassFieldVisitor extends FieldVisitor
@Override @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{ {
Annotation element = new Annotation(new Type(desc)); Annotation annotation = new Annotation(new Type(desc), visible);
this.field.getAnnotations().addAnnotation(element); this.field.addAnnotation(annotation);
return new AnnotationElementVisitor(element); return annotation;
} }
@Override @Override
@@ -27,7 +27,7 @@ package net.runelite.asm.visitors;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.Annotation;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import org.objectweb.asm.AnnotationVisitor; import org.objectweb.asm.AnnotationVisitor;
import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassVisitor;
@@ -71,9 +71,8 @@ public class ClassFileVisitor extends ClassVisitor
public AnnotationVisitor visitAnnotation(String desc, boolean visible) public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{ {
Annotation annotation = new Annotation(new Type(desc)); Annotation annotation = new Annotation(new Type(desc));
classFile.getAnnotations().addAnnotation(annotation); classFile.addAnnotation(annotation);
return annotation;
return new AnnotationElementVisitor(annotation);
} }
@Override @Override
@@ -32,7 +32,7 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.code.Exceptions; import net.runelite.asm.attributes.code.Exceptions;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType; import net.runelite.asm.attributes.code.InstructionType;
@@ -108,9 +108,9 @@ public class CodeVisitor extends MethodVisitor
@Override @Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) public AnnotationVisitor visitAnnotation(String desc, boolean visible)
{ {
Annotation element = new Annotation(new Type(desc)); Annotation annotation = new Annotation(new Type(desc), visible);
this.method.getAnnotations().addAnnotation(element); this.method.addAnnotation(annotation);
return new AnnotationElementVisitor(element); return annotation;
} }
@Override @Override
@@ -37,7 +37,6 @@ import net.runelite.deob.deobfuscators.Lvt;
import net.runelite.deob.deobfuscators.Order; import net.runelite.deob.deobfuscators.Order;
import net.runelite.deob.deobfuscators.RenameUnique; import net.runelite.deob.deobfuscators.RenameUnique;
import net.runelite.deob.deobfuscators.RuntimeExceptions; import net.runelite.deob.deobfuscators.RuntimeExceptions;
import net.runelite.deob.deobfuscators.StaticShouldBeInstance;
import net.runelite.deob.deobfuscators.UnreachedCode; import net.runelite.deob.deobfuscators.UnreachedCode;
import net.runelite.deob.deobfuscators.UnusedClass; import net.runelite.deob.deobfuscators.UnusedClass;
import net.runelite.deob.deobfuscators.UnusedFields; import net.runelite.deob.deobfuscators.UnusedFields;
@@ -80,68 +79,63 @@ public class Deob
ClassGroup group = JarUtil.loadJar(new File(args[0])); ClassGroup group = JarUtil.loadJar(new File(args[0]));
run(group, new StaticShouldBeInstance()); // remove except RuntimeException
run(group, new RuntimeExceptions());
if (args.length <= 2 || !args[2].equals("rl")) run(group, new ControlFlowDeobfuscator());
{
// remove except RuntimeException
run(group, new RuntimeExceptions());
run(group, new ControlFlowDeobfuscator()); run(group, new RenameUnique());
run(group, new RenameUnique()); // remove unused methods - this leaves Code with no instructions,
// which is not valid, so unused methods is run after
run(group, new UnreachedCode());
run(group, new UnusedMethods());
// remove unused methods - this leaves Code with no instructions, // remove illegal state exceptions, frees up some parameters
// which is not valid, so unused methods is run after run(group, new IllegalStateExceptions());
run(group, new UnreachedCode());
run(group, new UnusedMethods());
// remove illegal state exceptions, frees up some parameters // remove constant logically dead parameters
run(group, new IllegalStateExceptions()); run(group, new ConstantParameter());
// remove constant logically dead parameters // remove unhit blocks
run(group, new ConstantParameter()); run(group, new UnreachedCode());
run(group, new UnusedMethods());
// remove unhit blocks // remove unused parameters
run(group, new UnreachedCode()); run(group, new UnusedParameters());
run(group, new UnusedMethods());
// remove unused parameters // remove unused fields
run(group, new UnusedParameters()); run(group, new UnusedFields());
// remove unused fields run(group, new FieldInliner());
run(group, new UnusedFields());
run(group, new FieldInliner()); // order uses class name order for sorting fields/methods,
// so run it before removing classes below
run(group, new Order());
// order uses class name order for sorting fields/methods, run(group, new UnusedClass());
// so run it before removing classes below
run(group, new Order());
run(group, new UnusedClass()); runMath(group);
runMath(group); run(group, new ExprArgOrder());
run(group, new ExprArgOrder()); run(group, new Lvt());
run(group, new Lvt()); run(group, new CastNull());
run(group, new CastNull()); run(group, new EnumDeobfuscator());
run(group, new EnumDeobfuscator()); new OpcodesTransformer().transform(group);
//run(group, new PacketHandlerOrder());
//run(group, new PacketWriteDeobfuscator());
new OpcodesTransformer().transform(group); run(group, new MenuActionDeobfuscator());
//run(group, new PacketHandlerOrder());
//run(group, new PacketWriteDeobfuscator());
run(group, new MenuActionDeobfuscator()); new GetPathTransformer().transform(group);
new ClientErrorTransformer().transform(group);
new GetPathTransformer().transform(group); new ReflectionTransformer().transform(group);
new ClientErrorTransformer().transform(group); //new MaxMemoryTransformer().transform(group);
new ReflectionTransformer().transform(group); //new RuneliteBufferTransformer().transform(group);
//new MaxMemoryTransformer().transform(group);
//new RuneliteBufferTransformer().transform(group);
}
JarUtil.saveJar(group, new File(args[1])); JarUtil.saveJar(group, new File(args[1]));
@@ -24,15 +24,15 @@
*/ */
package net.runelite.deob; package net.runelite.deob;
import java.util.List; import javax.annotation.Nullable;
import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import org.jetbrains.annotations.NotNull;
public class DeobAnnotations public class DeobAnnotations
{ {
@@ -41,98 +41,77 @@ public class DeobAnnotations
public static final Type IMPLEMENTS = new Type("Lnet/runelite/mapping/Implements;"); public static final Type IMPLEMENTS = new Type("Lnet/runelite/mapping/Implements;");
public static final Type OBFUSCATED_GETTER = new Type("Lnet/runelite/mapping/ObfuscatedGetter;"); public static final Type OBFUSCATED_GETTER = new Type("Lnet/runelite/mapping/ObfuscatedGetter;");
public static final Type OBFUSCATED_SIGNATURE = new Type("Lnet/runelite/mapping/ObfuscatedSignature;"); public static final Type OBFUSCATED_SIGNATURE = new Type("Lnet/runelite/mapping/ObfuscatedSignature;");
public static final Type HOOK = new Type("Lnet/runelite/mapping/Hook;");
public static Signature getObfuscatedSignature(Method m) public static Signature getObfuscatedSignature(Method m)
{ {
String str = getAnnotationValue(m.getAnnotations(), OBFUSCATED_SIGNATURE); Object val = get(m, OBFUSCATED_SIGNATURE, "descriptor");
if (str == null) if (val == null)
{
return null; return null;
}
return new Signature(str); return new Signature((String) val);
} }
public static Type getObfuscatedType(Field f) public static Type getObfuscatedType(Field f)
{ {
String str = getAnnotationValue(f.getAnnotations(), OBFUSCATED_SIGNATURE); Object val = get(f, OBFUSCATED_SIGNATURE, "descriptor");
if (str == null) if (val == null)
{
return null; return null;
}
return new Type(str); return new Type((String) val);
} }
public static String getObfuscatedName(Annotations an) @Nullable
public static String getObfuscatedName(@NotNull Annotated an)
{ {
return getAnnotationValue(an, OBFUSCATED_NAME); return getStringValue(an, OBFUSCATED_NAME);
} }
public static String getExportedName(Annotations an) @Nullable
public static String getExportedName(@NotNull Annotated an)
{ {
return getAnnotationValue(an, EXPORT); return getStringValue(an, EXPORT);
} }
public static String getImplements(ClassFile cf) @Nullable
public static String getImplements(@NotNull ClassFile cf)
{ {
return getAnnotationValue(cf.getAnnotations(), IMPLEMENTS); return getStringValue(cf, IMPLEMENTS);
} }
public static Number getObfuscatedGetter(Field field) @Nullable
public static Number getObfuscatedGetter(@NotNull Field field)
{ {
if (field == null || field.getAnnotations() == null) final var a = field.findAnnotation(OBFUSCATED_GETTER);
{
return null;
}
Annotation an = field.getAnnotations().find(OBFUSCATED_GETTER);
if (an == null)
{
return null;
}
return (Number) an.getElement().getValue();
}
public static String getDecoder(Method method)
{
if (method == null || method.getAnnotations() == null)
{
return null;
}
Annotation an = method.getAnnotations().find(OBFUSCATED_SIGNATURE);
if (an == null)
{
return null;
}
List<Element> elements = an.getElements();
if (elements == null || elements.size() < 2)
{
return null;
}
return (String) elements.get(1).getValue();
}
public static String getAnnotationValue(Annotations an, Type type)
{
if (an == null)
{
return null;
}
Annotation a = an.find(type);
if (a == null) if (a == null)
{
return null; return null;
}
return a.getElement().getString(); if (field.getType().equals(Type.INT))
return (Integer) a.get("intValue");
if (field.getType().equals(Type.LONG))
return (Long) a.get("longValue"); // very long v
throw new IllegalArgumentException("Field with getter but not a long or an int?");
}
@Nullable
public static String getDecoder(@NotNull Method method)
{
Annotation a = method.findAnnotation(OBFUSCATED_SIGNATURE);
return a == null ? null : (String) a.get("garbageValue");
}
@Nullable
public static Object get(Annotated an, Type type, String name)
{
final var a = an.findAnnotation(type);
return a == null ? null : a.get(name);
}
@Nullable
public static String getStringValue(Annotated an, Type type)
{
final var a = an.findAnnotation(type);
return a == null ? null : a.getValueString();
} }
} }
@@ -24,7 +24,6 @@
*/ */
package net.runelite.deob.deobfuscators; package net.runelite.deob.deobfuscators;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -32,7 +31,7 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.execution.Execution; import net.runelite.asm.execution.Execution;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import net.runelite.deob.Deobfuscator; import net.runelite.deob.Deobfuscator;
@@ -64,7 +63,7 @@ public class Order implements Deobfuscator
for (int i = 0; i < group.getClasses().size(); i++) for (int i = 0; i < group.getClasses().size(); i++)
{ {
ClassFile cf = group.getClasses().get(i); ClassFile cf = group.getClasses().get(i);
String className = DeobAnnotations.getObfuscatedName(cf.getAnnotations()); String className = DeobAnnotations.getObfuscatedName(cf);
nameIndices.put(className, i); nameIndices.put(className, i);
} }
@@ -73,7 +72,7 @@ public class Order implements Deobfuscator
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
List<Method> m = cf.getMethods(); List<Method> m = cf.getMethods();
Collections.sort(m, this::compareMethod); m.sort(this::compare);
sortedMethods += m.size(); sortedMethods += m.size();
@@ -81,7 +80,7 @@ public class Order implements Deobfuscator
if (!cf.isEnum()) if (!cf.isEnum())
{ {
List<Field> f = cf.getFields(); List<Field> f = cf.getFields();
Collections.sort(f, this::compareFields); f.sort(this::compare);
sortedFields += f.size(); sortedFields += f.size();
} }
@@ -91,47 +90,27 @@ public class Order implements Deobfuscator
} }
// static fields, member fields, clinit, init, methods, static methods // static fields, member fields, clinit, init, methods, static methods
private int compareMethod(Method m1, Method m2) private int compare(Annotated a, Annotated b)
{ {
int i1 = getType(m1), i2 = getType(m2); int i1 = getType(a), i2 = getType(b);
if (i1 != i2) if (i1 != i2)
{ {
return Integer.compare(i1, i2); return Integer.compare(i1, i2);
} }
int nameIdx1 = getNameIdx(m1.getAnnotations()); int nameIdx1 = getNameIdx(a);
int nameIdx2 = getNameIdx(m2.getAnnotations()); int nameIdx2 = getNameIdx(b);
if (nameIdx1 != nameIdx2) if (nameIdx1 != nameIdx2)
{ {
return Integer.compare(nameIdx1, nameIdx2); return Integer.compare(nameIdx1, nameIdx2);
} }
return compareOrder(m1, m2); return compareOrder(a, b);
} }
private int compareFields(Field f1, Field f2) private int getNameIdx(Annotated annotations)
{
int i1 = getType(f1), i2 = getType(f2);
if (i1 != i2)
{
return Integer.compare(i1, i2);
}
int nameIdx1 = getNameIdx(f1.getAnnotations());
int nameIdx2 = getNameIdx(f2.getAnnotations());
if (nameIdx1 != nameIdx2)
{
return Integer.compare(nameIdx1, nameIdx2);
}
return compareOrder(f1, f2);
}
private int getNameIdx(Annotations annotations)
{ {
String name = DeobAnnotations.getObfuscatedName(annotations); String name = DeobAnnotations.getObfuscatedName(annotations);
@@ -140,6 +119,15 @@ public class Order implements Deobfuscator
return nameIdx != null ? nameIdx : -1; return nameIdx != null ? nameIdx : -1;
} }
private int getType(Annotated a)
{
if (a instanceof Method)
return getType((Method) a);
else if (a instanceof Field)
return getType((Field) a);
throw new RuntimeException("kys");
}
private int getType(Method m) private int getType(Method m)
{ {
if (m.getName().equals("<clinit>")) if (m.getName().equals("<clinit>"))
@@ -151,7 +151,7 @@ public class PacketHandlerOrder implements Deobfuscator
// check if the invoke is on buffer/packetbuffer classes // check if the invoke is on buffer/packetbuffer classes
boolean matches = ii.getMethods().stream() boolean matches = ii.getMethods().stream()
.filter(m -> m.getDescriptor().size() == 0) .filter(m -> m.getDescriptor().size() == 0)
.map(method -> method.getClassFile()) .map(Method::getClassFile)
.anyMatch(cf -> cf == bf.getBuffer() || cf == bf.getPacketBuffer()); .anyMatch(cf -> cf == bf.getBuffer() || cf == bf.getPacketBuffer());
if (matches) if (matches)
{ {
@@ -269,7 +269,7 @@ public class PacketHandlerOrder implements Deobfuscator
logger.warn("Unable to differentiate {} from {}", p1, p2); logger.warn("Unable to differentiate {} from {}", p1, p2);
return 0; return 0;
}) })
.map(s -> s.clone()) .map(PacketHandler::clone)
.collect(Collectors.toList()); .collect(Collectors.toList());
assert sortedHandlers.size() == handlers.getHandlers().size(); assert sortedHandlers.size() == handlers.getHandlers().size();
@@ -277,7 +277,7 @@ public class PacketHandlerOrder implements Deobfuscator
for (PacketHandler handler : sortedHandlers) for (PacketHandler handler : sortedHandlers)
{ {
handler.sortedReads = new ArrayList<>(handler.reads); handler.sortedReads = new ArrayList<>(handler.reads);
Collections.sort(handler.sortedReads, (PacketRead p1, PacketRead p2) -> handler.sortedReads.sort((PacketRead p1, PacketRead p2) ->
{ {
LVTInstruction l1 = (LVTInstruction) p1.getStore(); LVTInstruction l1 = (LVTInstruction) p1.getStore();
LVTInstruction l2 = (LVTInstruction) p2.getStore(); LVTInstruction l2 = (LVTInstruction) p2.getStore();
@@ -350,7 +350,7 @@ public class PacketHandlerOrder implements Deobfuscator
// Find unique methods // Find unique methods
List<Method> methods = unsortedHandlers.stream() List<Method> methods = unsortedHandlers.stream()
.map(ph -> ph.getMethod()) .map(PacketHandler::getMethod)
.distinct() .distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -439,10 +439,6 @@ public class PacketHandlerOrder implements Deobfuscator
} }
List<Instruction> follow = follow(instructions, handler.getStart(), afterRead); List<Instruction> follow = follow(instructions, handler.getStart(), afterRead);
if (follow == null)
{
continue;
}
for (Instruction i : follow) for (Instruction i : follow)
{ {
@@ -559,11 +555,11 @@ public class PacketHandlerOrder implements Deobfuscator
private int compareReads(List<PacketRead> r1, List<PacketRead> r2) private int compareReads(List<PacketRead> r1, List<PacketRead> r2)
{ {
List<Type> t1 = r1.stream() List<Type> t1 = r1.stream()
.map(pr -> pr.getType()) .map(PacketRead::getType)
.sorted(this::compareType) .sorted(this::compareType)
.collect(Collectors.toList()); .collect(Collectors.toList());
List<Type> t2 = r2.stream() List<Type> t2 = r2.stream()
.map(pr -> pr.getType()) .map(PacketRead::getType)
.sorted(this::compareType) .sorted(this::compareType)
.collect(Collectors.toList()); .collect(Collectors.toList());
if (t1.size() != t2.size()) if (t1.size() != t2.size())
@@ -38,50 +38,33 @@ import net.runelite.deob.util.NameMappings;
public class RenameUnique implements Deobfuscator public class RenameUnique implements Deobfuscator
{ {
private Renamer renamer;
private void generateClassNames(NameMappings map, ClassGroup group) private void generateClassNames(NameMappings map, ClassGroup group)
{ {
int i = 0; int i = 0;
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ if (cf.getName().length() <= Deob.OBFUSCATED_NAME_MAX_LEN)
if (cf.getName().length() > Deob.OBFUSCATED_NAME_MAX_LEN) map.map(cf.getPoolClass(), "class" + i++);
{ map.setClasses(i);
continue;
}
map.map(cf.getPoolClass(), "class" + i++);
}
} }
private void generateFieldNames(NameMappings map, ClassGroup group) private void generateFieldNames(NameMappings map, ClassGroup group)
{ {
int i = 0; int i = 0;
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
for (Field field : cf.getFields()) for (Field field : cf.getFields())
{ if (Deob.isObfuscated(field.getName()) && !field.getName().equals(DeobAnnotations.getExportedName(field)))
if (!Deob.isObfuscated(field.getName()) || field.getName().equals(DeobAnnotations.getExportedName(field.getAnnotations()))) map.map(field.getPoolField(), "field" + i++);
{ map.setFields(i);
continue;
}
map.map(field.getPoolField(), "field" + i++);
}
} }
private void generateMethodNames(NameMappings map, ClassGroup group) private void generateMethodNames(NameMappings map, ClassGroup group)
{ {
int i = 0; int i = 0;
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
for (Method method : cf.getMethods()) for (Method method : cf.getMethods())
{ {
if (!Deob.isObfuscated(method.getName()) || method.getName().equals(DeobAnnotations.getExportedName(method.getAnnotations()))) if (!Deob.isObfuscated(method.getName()) || method.getName().equals(DeobAnnotations.getExportedName(method)))
{
continue; continue;
}
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(method); List<Method> virtualMethods = VirtualMethods.getVirtualMethods(method);
assert !virtualMethods.isEmpty(); assert !virtualMethods.isEmpty();
@@ -95,6 +78,7 @@ public class RenameUnique implements Deobfuscator
for (Method m : virtualMethods) for (Method m : virtualMethods)
map.map(m.getPoolMethod(), name); map.map(m.getPoolMethod(), name);
} }
map.setMethods(i);
} }
@Override @Override
@@ -109,7 +93,7 @@ public class RenameUnique implements Deobfuscator
this.generateFieldNames(mappings, group); this.generateFieldNames(mappings, group);
this.generateMethodNames(mappings, group); this.generateMethodNames(mappings, group);
renamer = new Renamer(mappings); Renamer renamer = new Renamer(mappings);
renamer.run(group); renamer.run(group);
} }
} }
@@ -31,9 +31,10 @@ import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Interfaces; import net.runelite.asm.Interfaces;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Named;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.code.Exceptions; import net.runelite.asm.attributes.code.Exceptions;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.LocalVariable; import net.runelite.asm.attributes.code.LocalVariable;
@@ -45,6 +46,8 @@ import net.runelite.deob.Deobfuscator;
import net.runelite.deob.util.NameMappings; import net.runelite.deob.util.NameMappings;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static net.runelite.deob.DeobAnnotations.OBFUSCATED_NAME;
import static net.runelite.deob.DeobAnnotations.OBFUSCATED_SIGNATURE;
public class Renamer implements Deobfuscator public class Renamer implements Deobfuscator
{ {
@@ -134,12 +137,7 @@ public class Renamer implements Deobfuscator
if (!method.getDescriptor().equals(newSignature)) if (!method.getDescriptor().equals(newSignature))
{ {
//Signature was updated. Annotate it method.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement( "descriptor", method.getDescriptor().toString());
if (method.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE) == null)
{
//Signature was not previously renamed
method.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, "signature", method.getDescriptor().toString());
}
} }
method.setDescriptor(newSignature); method.setDescriptor(newSignature);
@@ -156,21 +154,13 @@ public class Renamer implements Deobfuscator
{ {
if (field.getType().getInternalName().equals(cf.getName())) if (field.getType().getInternalName().equals(cf.getName()))
{ {
if (field.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE) == null) field.findAnnotation(OBFUSCATED_SIGNATURE, true).setElement("descriptor", field.getType().toString());
{
//Signature was updated. Annotate it
field.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, "signature", field.getType().toString());
}
field.setType(Type.getType("L" + name + ";", field.getType().getDimensions())); field.setType(Type.getType("L" + name + ";", field.getType().getDimensions()));
} }
} }
} }
if (cf.getAnnotations().find(DeobAnnotations.OBFUSCATED_NAME) == null) addObfuscatedName(cf);
{
cf.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_NAME, "value", cf.getName());
}
group.renameClass(cf, name); group.renameClass(cf, name);
} }
@@ -178,22 +168,13 @@ public class Renamer implements Deobfuscator
private void regeneratePool(ClassGroup group) private void regeneratePool(ClassGroup group)
{ {
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{
for (Method m : cf.getMethods()) for (Method m : cf.getMethods())
{ if (m.getCode() != null)
Code c = m.getCode(); m.getCode().getInstructions()
if (c == null) .regeneratePool();
{
continue;
}
c.getInstructions().regeneratePool();
}
}
} }
@Override @Override
@SuppressWarnings("unchecked")
public void run(ClassGroup group) public void run(ClassGroup group)
{ {
group.buildClassGraph(); group.buildClassGraph();
@@ -212,12 +193,9 @@ public class Renamer implements Deobfuscator
continue; continue;
} }
if (field.getAnnotations().find(DeobAnnotations.OBFUSCATED_NAME) == null) addObfuscatedName(field);
{
field.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_NAME, "value", field.getName());
}
assert DeobAnnotations.getExportedName(field.getAnnotations()) == null || DeobAnnotations.getExportedName(field.getAnnotations()).equals(newName) : "Tried changing field name to something other than the exported name!"; assert DeobAnnotations.getExportedName(field) == null || newName.equals(DeobAnnotations.getExportedName(field)) : "Tried changing field name to something other than the exported name!";
field.setName(newName); field.setName(newName);
++fields; ++fields;
@@ -232,15 +210,6 @@ public class Renamer implements Deobfuscator
String newName = mappings.get(method.getPoolMethod()); String newName = mappings.get(method.getPoolMethod());
String[] newParams = mappings.getP(method.getPoolMethod()); String[] newParams = mappings.getP(method.getPoolMethod());
// rename on obfuscated signature
Annotation an = method.getAnnotations().find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (an != null)
{
Signature obfuscatedSig = new Signature(an.getElement().getString());
Signature updatedSig = renameSignature(obfuscatedSig);
an.getElement().setValue(updatedSig.toString());
}
if (newName == null) if (newName == null)
{ {
continue; continue;
@@ -279,10 +248,7 @@ public class Renamer implements Deobfuscator
++parameters; ++parameters;
} }
if (m.getAnnotations().find(DeobAnnotations.OBFUSCATED_NAME) == null) addObfuscatedName(m);
{
m.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_NAME, "value", m.getName());
}
m.setName(newName); m.setName(newName);
} }
@@ -308,35 +274,8 @@ public class Renamer implements Deobfuscator
logger.info("Renamed {} classes, {} fields, {} methods, and {} parameters", classes, fields, methods, parameters); logger.info("Renamed {} classes, {} fields, {} methods, and {} parameters", classes, fields, methods, parameters);
} }
private Type renameType(Type t) private static <T extends Annotated & Named> void addObfuscatedName(T object)
{ {
if (t.isPrimitive()) object.findAnnotation(OBFUSCATED_NAME, true).setElement(object.getName());
{
return t;
}
String className = t.getInternalName();
String newName = mappings.get(new net.runelite.asm.pool.Class(className));
if (newName == null)
{
return t;
}
Type type = Type.getType("L" + newName + ";", t.getDimensions());
logger.debug("Renamed {} -> {}", t, type);
return type;
}
private Signature renameSignature(Signature s)
{
Signature.Builder builder = new Signature.Builder()
.setReturnType(renameType(s.getReturnValue()));
for (Type t : s.getArguments())
{
builder.addArgument(renameType(t));
}
return builder.build();
} }
} }
@@ -1,171 +0,0 @@
package net.runelite.deob.deobfuscators;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field;
import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.instruction.types.ReturnInstruction;
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
import net.runelite.asm.pool.Method;
import net.runelite.asm.signature.Signature;
import net.runelite.deob.Deobfuscator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class StaticShouldBeInstance implements Deobfuscator
{
private static final Logger logger = LoggerFactory.getLogger(StaticShouldBeInstance.class);
private static Map<Method, Method> methods = new HashMap<>();
public void run(ClassGroup group)
{
int replacedCalls = 0;
int removedInstructions = 0;
int removedMethods = 0;
int removedAnnotations = 0;
List<net.runelite.asm.Method> obfuscatedMethods = new ArrayList<>();
for (ClassFile cf : group.getClasses())
{
// Remove unused annotations
Annotations a = cf.getAnnotations();
removedAnnotations += a.getAnnotations().size();
a.clearAnnotations();
Type type = new Type('L' + cf.getClassName() + ';');
obfuscatedMethods.clear();
for (net.runelite.asm.Method m : cf.getMethods())
{
// Remove unused annotations
a = m.getAnnotations();
removedAnnotations += a.size();
a.clearAnnotations();
if (m.isStatic() && m.getCode() != null)
{
if (checkIfObf(m, type, cf))
{
removedMethods++;
obfuscatedMethods.add(m);
}
}
}
for (net.runelite.asm.Method m : obfuscatedMethods)
{
Signature sig = m.getDescriptor();
Signature.Builder builder = new Signature.Builder();
builder.setReturnType(sig.getReturnValue());
if (sig.getArguments().size() > 1)
{
builder.addArguments(sig.getArguments().subList(1, sig.getArguments().size()));
}
Signature toFind = builder.build();
net.runelite.asm.Method notStatic = cf.findMethod(m.getName(), toFind);
net.runelite.asm.pool.Method oldPool = m.getPoolMethod();
cf.removeMethod(notStatic);
m.setDescriptor(toFind);
m.setStatic(false);
Code c = m.getCode();
Instructions ins = c.getInstructions();
int startLength = ins.getInstructions().size();
ListIterator<Instruction> it = ins.getInstructions().listIterator();
assert it.hasNext();
Instruction i = it.next();
while (!(i instanceof ReturnInstruction))
{
it.remove();
i = it.next();
}
it.remove();
net.runelite.asm.pool.Method newPool = m.getPoolMethod();
methods.put(oldPool, newPool);
removedInstructions += startLength - ins.getInstructions().size();
}
for (Field fi : cf.getFields())
{
a = fi.getAnnotations();
if (a.find(new Type("Ljavax/inject/Inject;")) == null)
{
removedAnnotations += a.size();
a.clearAnnotations();
}
else
{
logger.info("Class {}, field {} has inject", cf.getClassName(), fi.getName());
}
}
}
for (ClassFile cf : group.getClasses())
{
for (net.runelite.asm.Method m : cf.getMethods())
{
if (m.getCode() == null)
{
continue;
}
Instructions ins = m.getCode().getInstructions();
List<Instruction> instructions = ins.getInstructions();
for (int i1 = 0, instructionsSize = instructions.size(); i1 < instructionsSize; i1++)
{
Instruction i = instructions.get(i1);
if (!(i instanceof InvokeStatic))
{
continue;
}
if (methods.containsKey(((InvokeStatic) i).getMethod()))
{
InvokeVirtual invoke = new InvokeVirtual(ins, methods.get(((InvokeStatic) i).getMethod()));
ins.replace(i, invoke);
replacedCalls++;
}
}
}
}
logger.info("Made {} methods not static, removed {} instructions, replaced {} invokes, and removed {} annotations", removedMethods, removedInstructions, replacedCalls, removedAnnotations);
}
private static boolean checkIfObf(net.runelite.asm.Method m, Type type, ClassFile cf)
{
Signature sig = m.getDescriptor();
if (sig.getArguments().size() < 1 || !sig.getTypeOfArg(0).equals(type))
{
return false;
}
Signature.Builder builder = new Signature.Builder();
builder.setReturnType(sig.getReturnValue());
if (sig.getArguments().size() > 1)
{
builder.addArguments(sig.getArguments().subList(1, sig.getArguments().size()));
}
Signature toFind = builder.build();
net.runelite.asm.Method notStatic = cf.findMethod(m.getName(), toFind);
return notStatic != null;
}
}
@@ -97,22 +97,22 @@ public class UnusedParameters implements Deobfuscator
private boolean shouldRemove(Method m, int parameter) private boolean shouldRemove(Method m, int parameter)
{ {
Signature obSig = DeobAnnotations.getObfuscatedSignature(m); final var a = m.findAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obSig == null) if (a == null)
{
return false; return false;
} final var str = a.get("descriptor");
return parameter + 1 == obSig.size(); return parameter + 1 == new Signature((String) str).size();
} }
private int processUnused(Execution execution, ClassGroup group) private int processUnused(Execution execution, ClassGroup group)
{ {
int count = 0; int count = 0;
for (List<Method> m : unused.keySet()) for (Map.Entry<List<Method>, Collection<Integer>> entry : unused.entrySet())
{ {
Collection<Integer> u = unused.get(m); List<Method> m = entry.getKey();
Collection<Integer> u = entry.getValue();
int offset = m.size() == 1 && m.get(0).isStatic() ? 0 : 1; int offset = m.size() == 1 && m.get(0).isStatic() ? 0 : 1;
@@ -188,7 +188,7 @@ public class UnusedParameters implements Deobfuscator
} }
} }
List<Integer> l = new ArrayList<>(list); List<Integer> l = new ArrayList<>(list != null ? list : new ArrayList<>()); // i know
Collections.sort(l); Collections.sort(l);
Collections.reverse(l); Collections.reverse(l);
return l; return l;
@@ -218,7 +218,7 @@ public class UnusedParameters implements Deobfuscator
InvokeInstruction ii = (InvokeInstruction) i; InvokeInstruction ii = (InvokeInstruction) i;
if (!ii.getMethods().stream().anyMatch(me -> methods.contains(me))) if (ii.getMethods().stream().noneMatch(methods::contains))
{ {
continue; continue;
} }
@@ -227,20 +227,17 @@ public class UnusedParameters implements Deobfuscator
Collection<InstructionContext> ics = invokes.get(i); Collection<InstructionContext> ics = invokes.get(i);
assert ics != null; assert ics != null;
if (ics != null) for (InstructionContext ins : ics)
{ {
for (InstructionContext ins : ics) int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter
StackContext sctx = ins.getPops().get(pops);
if (sctx.getPushed().getInstruction().getInstructions() == null)
{ {
int pops = signature.size() - paramIndex - 1; // index from top of stack of parameter. 0 is the last parameter continue;
StackContext sctx = ins.getPops().get(pops);
if (sctx.getPushed().getInstruction().getInstructions() == null)
{
continue;
}
ins.removeStack(pops); // remove parameter from stack
} }
ins.removeStack(pops); // remove parameter from stack
} }
} }
} }
@@ -286,25 +283,20 @@ public class UnusedParameters implements Deobfuscator
public void run(ClassGroup group) public void run(ClassGroup group)
{ {
int i; int i;
int pnum = 1;
do
{
group.buildClassGraph();
invokes.clear(); group.buildClassGraph();
this.buildUnused(group);
Execution execution = new Execution(group); invokes.clear();
execution.addExecutionVisitor(ictx -> visit(ictx)); this.buildUnused(group);
execution.populateInitialMethods();
execution.run();
i = this.processUnused(execution, group); Execution execution = new Execution(group);
execution.addExecutionVisitor(this::visit);
execution.populateInitialMethods();
execution.run();
count += i; i = this.processUnused(execution, group);
break;
} count += i;
while (i > 0);
logger.info("Removed {} unused parameters", count); logger.info("Removed {} unused parameters", count);
} }
@@ -783,7 +783,7 @@ public class ModArith implements Deobfuscator
String ename = pair.getType() == Long.class String ename = pair.getType() == Long.class
? "longValue" ? "longValue"
: "intValue"; : "intValue";
f.getAnnotations().addAnnotation(DeobAnnotations.OBFUSCATED_GETTER, ename, pair.getter); f.addAnnotation(DeobAnnotations.OBFUSCATED_GETTER, ename, pair.getter);
} }
} }
} }
@@ -26,8 +26,13 @@ package net.runelite.deob.deobfuscators.cfg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import lombok.Getter;
import lombok.Setter;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Label;
@Getter
@Setter
public class Block public class Block
{ {
private int id = -1; private int id = -1;
@@ -36,64 +41,44 @@ public class Block
/** /**
* blocks which jump here * blocks which jump here
*/ */
private final List<Block> prev = new ArrayList<>(); private final List<Block> preds = new ArrayList<>();
/** /**
* blocks which this jumps to * blocks which this jumps to
*/ */
private final List<Block> next = new ArrayList<>(); private final List<Block> succs = new ArrayList<>();
/** /**
* block which flows directly into this block * block which flows directly into this block
*/ */
private Block flowsFrom; private Block pred;
/** /**
* block which this directly flows into * block which this directly flows into
*/ */
private Block flowsInto; private Block succ;
/** /**
* instructions in this block * instructions in this block
*/ */
private final List<Instruction> instructions = new ArrayList<>(); private final List<Instruction> instructions = new ArrayList<>();
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public boolean isJumptarget()
{
return jumptarget;
}
public void setJumptarget(boolean jumptarget)
{
this.jumptarget = jumptarget;
}
@Override @Override
public String toString() public String toString()
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Block ID ").append(id).append("\n"); sb.append("Block ID ").append(id).append("\n");
if (flowsFrom != null) if (pred != null)
{ {
sb.append(" flows from ").append(flowsFrom.id).append("\n"); sb.append(" flows from ").append(pred.id).append("\n");
} }
for (Instruction i : instructions) for (Instruction i : instructions)
{ {
sb.append(" ").append(i.toString()).append("\n"); sb.append(" ").append(i.toString()).append("\n");
} }
if (flowsInto != null) if (succ != null)
{ {
sb.append(" flows into ").append(flowsInto.id).append("\n"); sb.append(" flows into ").append(succ.id).append("\n");
} }
sb.append("\n"); sb.append("\n");
return sb.toString(); return sb.toString();
@@ -111,54 +96,37 @@ public class Block
instructions.add(i); instructions.add(i);
} }
public List<Instruction> getInstructions()
{
return instructions;
}
public void addPrev(Block block) public void addPrev(Block block)
{ {
if (!prev.contains(block)) if (!preds.contains(block))
{ {
prev.add(block); preds.add(block);
} }
} }
public List<Block> getPrev()
{
return prev;
}
public void addNext(Block block) public void addNext(Block block)
{ {
if (!next.contains(block)) if (!succs.contains(block))
{ {
next.add(block); succs.add(block);
} }
} }
public List<Block> getNext() static int compare(Block a, Block b)
{ {
return next; final int l1 = a.getLineNumber();
final int l2 = b.getLineNumber();
if (l1 == l2 || l1 == -1 || l2 == -1)
return 0;
return Integer.compare(l1, l2);
} }
public Block getFlowsFrom() private int getLineNumber()
{ {
return flowsFrom; for (Instruction i : instructions)
} if (i instanceof Label)
if (((Label) i).getLineNumber() != null)
public void setFlowsFrom(Block flowsFrom) return ((Label) i).getLineNumber();
{ return -1;
this.flowsFrom = flowsFrom;
}
public Block getFlowsInto()
{
return flowsInto;
}
public void setFlowsInto(Block flowsInto)
{
this.flowsInto = flowsInto;
} }
} }
@@ -24,16 +24,11 @@
*/ */
package net.runelite.deob.deobfuscators.cfg; package net.runelite.deob.deobfuscators.cfg;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.code.Exception;
import net.runelite.asm.attributes.code.Exceptions;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.Label; import net.runelite.asm.attributes.code.Label;
@@ -64,7 +59,6 @@ public class ControlFlowDeobfuscator implements Deobfuscator
continue; continue;
} }
split(code);
run(code); run(code);
runJumpLabel(code); runJumpLabel(code);
} }
@@ -74,167 +68,49 @@ public class ControlFlowDeobfuscator implements Deobfuscator
insertedJump, placedBlocks, removedJumps, insertedJump - removedJumps); insertedJump, placedBlocks, removedJumps, insertedJump - removedJumps);
} }
/**
* Add gotos at the end of blocks without terminal instructions
*
* @param code
*/
private void split(Code code)
{
Instructions ins = code.getInstructions();
Exceptions exceptions = code.getExceptions();
ControlFlowGraph graph = new ControlFlowGraph.Builder().build(code);
List<Exception> exc = new ArrayList<>(exceptions.getExceptions());
exceptions.clear(); // Must clear this before ins.clear() runs
ins.clear();
// insert jumps where blocks flow into others
for (Block block : graph.getBlocks())
{
if (block.getFlowsInto() == null)
{
continue;
}
Block into = block.getFlowsInto();
assert into.getFlowsFrom() == block;
Instruction first = into.getInstructions().get(0);
Label label;
if (!(first instanceof Label))
{
label = new Label(null);
into.addInstruction(0, label);
}
else
{
label = (Label) first;
}
Goto g = new Goto(null, label);
block.addInstruction(g);
block.setFlowsInto(null);
into.setFlowsFrom(null);
++insertedJump;
}
// Readd instructions from modified blocks
for (Block block : graph.getBlocks())
{
for (Instruction i : block.getInstructions())
{
assert i.getInstructions() == null;
i.setInstructions(ins); // I shouldn't have to do this here
ins.addInstruction(i);
}
}
// Readd exceptions
for (Exception ex : exc)
{
exceptions.add(ex);
}
}
private int compareBlock(Block o1, Block o2)
{
// higher numbers have the lowest priority
if (o1.isJumptarget() && !o2.isJumptarget())
{
return -1;
}
if (o2.isJumptarget() && !o1.isJumptarget())
{
return 1;
}
return 0;
}
private void run(Code code) private void run(Code code)
{ {
Instructions ins = code.getInstructions(); Instructions ins = code.getInstructions();
Exceptions exceptions = code.getExceptions();
ControlFlowGraph graph = new ControlFlowGraph.Builder().build(code); ControlFlowGraph graph = new ControlFlowGraph(code);
for (Block block : graph.getBlocks())
{
assert block.getFlowsFrom() == null;
assert block.getFlowsInto() == null;
}
if (logger.isDebugEnabled()) // graph.toString() is expensive if (logger.isDebugEnabled()) // graph.toString() is expensive
{ {
logger.debug(graph.toString()); logger.debug(graph.toString());
} }
List<Exception> originalExceptions = new ArrayList<>(exceptions.getExceptions()); // Clear existing instructions as we are going to rebuild them
// Clear existing exceptions and instructions as we are going to
// rebuild them
exceptions.clear();
ins.clear(); ins.clear();
final List<Block> sorted = graph.topologicalSort();
List<Block> done = new ArrayList<>(); for (Block b : sorted)
Queue<Block> queue = new PriorityQueue<>(this::compareBlock);
// add initial code block
queue.add(graph.getHead());
while (!queue.isEmpty())
{ {
Block block = queue.remove();
if (done.contains(block))
{
continue;
}
done.add(block);
++placedBlocks; ++placedBlocks;
for (Instruction i : b.getInstructions())
logger.debug("Placed block {}", block.getId());
List<Block> next = block.getNext();
if (next.isEmpty() == false)
{ {
// jumps are added in order their instructions are reached by ControlFlowGraph,
// so the last jump is the goto.
//
// removing this line causes the priority queue (due to implementation detail on how
// it handles objects with equal priority) to try to optimize for block closeness
// (how close blocks which are neighbors are to each other in bytecode).
// I get a jump delta of ~+14k with this on 143, vs ~-47k when priotiziing optimizing
// out jumps. I can't tell which is better.
next.get(next.size() - 1).setJumptarget(true);
}
// add next reachable blocks
for (Block bl : next)
{
queue.add(bl);
}
for (Instruction i : block.getInstructions())
{
assert i.getInstructions() == null;
i.setInstructions(ins); // I shouldn't have to do this here
ins.addInstruction(i); ins.addInstruction(i);
i.setInstructions(ins);
}
if (b.getSucc() != null && b.getInstructions().size() > 0)
{
final var i = b.getInstructions().get(b.getInstructions().size() - 1);
if (!i.isTerminal())
{
final var next = b.getSucc();
var maybeLabel = next.getInstructions().get(0);
if (!(maybeLabel instanceof Label))
{
maybeLabel = new Label(ins);
next.getInstructions().add(0, maybeLabel);
}
ins.addInstruction(new Goto(ins, (Label) maybeLabel));
++insertedJump;
}
} }
} }
} }
/** /**
* remove jumps followed immediately by the label they are jumping to * remove jumps followed immediately by the label they are jumping to
*
* @param code
*/ */
private void runJumpLabel(Code code) private void runJumpLabel(Code code)
{ {
@@ -26,9 +26,12 @@ package net.runelite.deob.deobfuscators.cfg;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.Label; import net.runelite.asm.attributes.code.Label;
@@ -36,10 +39,90 @@ import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction;
public class ControlFlowGraph public class ControlFlowGraph
{ {
private Map<Label, Block> blocks = new HashMap<>(); private final Map<Label, Block> blocks = new HashMap<>();
private List<Block> allBlocks = new ArrayList<>(); private final List<Block> allBlocks = new ArrayList<>();
private final Block head; private final Block head;
public ControlFlowGraph(Code code)
{
int id = 0;
this.head = new Block();
for (Instruction i : code.getInstructions())
if (i instanceof Label)
blocks.computeIfAbsent((Label) i, lbl -> {
var b = new Block();
allBlocks.add(b);
return b;
});
allBlocks.add(0, head);
Block cur = head;
for (Instruction i : code.getInstructions())
{
if (i instanceof Label)
{
Block next = blocks.get(i);
if (next.getId() == -1)
{
next.setId(id++);
}
if (next != cur)
{
Instruction last = cur.getInstructions().isEmpty()
? null
: cur.getInstructions().get(cur.getInstructions().size() - 1);
if (last == null || !last.isTerminal())
{
assert next.getPred() == null;
assert cur.getSucc() == null;
// previous block flows directly into next
next.setPred(cur);
cur.setSucc(next);
}
cur = next;
}
}
cur.addInstruction(i);
if (i instanceof JumpingInstruction)
{
JumpingInstruction ji = (JumpingInstruction) i;
for (Label l : ji.getJumps())
{
Block next = blocks.get(l);
if (next.getId() == -1)
{
next.setId(id++);
}
cur.addNext(next);
next.addPrev(cur);
}
}
}
assert head.getPred() == null;
}
List<Block> topologicalSort()
{
final List<Block> ret = new ArrayList<>();
walk(head, ret, new HashSet<>());
Collections.reverse(ret);
return ret;
}
private static void walk(Block cur, List<Block> order, Set<Block> done)
{
Block dirsucc = cur.getSucc();
if (dirsucc != null && done.add(dirsucc))
walk(cur.getSucc(), order, done);
List<Block> succs = cur.getSuccs();
succs.sort(Block::compare);
for (Block succ : succs)
if (done.add(succ))
walk(succ, order, done);
order.add(cur);
}
public ControlFlowGraph(Block head) public ControlFlowGraph(Block head)
{ {
this.head = head; this.head = head;
@@ -70,91 +153,4 @@ public class ControlFlowGraph
{ {
return head; return head;
} }
public static class Builder
{
private final Map<Label, Block> blocks = new HashMap<>();
private final List<Block> allBlocks = new ArrayList<>();
public ControlFlowGraph build(Code code)
{
int id = 0;
Block head = new Block(),
cur = head;
allBlocks.add(head);
for (Instruction i : code.getInstructions().getInstructions())
{
if (i instanceof Label)
{
// blocks always begin at labels, so create initial blocks
Block block = new Block();
blocks.put((Label) i, block);
allBlocks.add(block);
}
}
for (Instruction i : code.getInstructions().getInstructions())
{
if (i instanceof Label)
{
Block next = blocks.get((Label) i);
assert next != null;
if (next.getId() == -1)
{
next.setId(id++);
}
if (next != cur)
{
Instruction last = cur.getInstructions().isEmpty()
? null
: cur.getInstructions().get(cur.getInstructions().size() - 1);
if (last == null || !last.isTerminal())
{
assert next.getFlowsFrom() == null;
assert cur.getFlowsInto() == null;
// previous block flows directly into next
next.setFlowsFrom(cur);
cur.setFlowsInto(next);
}
cur = next;
}
}
cur.addInstruction(i);
if (i instanceof JumpingInstruction)
{
JumpingInstruction ji = (JumpingInstruction) i;
for (Label l : ji.getJumps())
{
Block next = blocks.get(l);
if (next.getId() == -1)
{
next.setId(id++);
}
cur.addNext(next);
next.addPrev(cur);
}
}
}
assert head != null : "no instructions in code";
assert head.getFlowsFrom() == null;
ControlFlowGraph cfg = new ControlFlowGraph(head);
cfg.blocks = blocks;
cfg.allBlocks = allBlocks;
return cfg;
}
}
} }
@@ -34,10 +34,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.annotation.SimpleElement;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import net.runelite.asm.attributes.code.InstructionType; import net.runelite.asm.attributes.code.InstructionType;
import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Instructions;
@@ -62,8 +59,8 @@ public class ConstantParameter implements Deobfuscator
{ {
private static final Logger logger = LoggerFactory.getLogger(ConstantParameter.class); private static final Logger logger = LoggerFactory.getLogger(ConstantParameter.class);
private Map<ConstantMethodParameter, ConstantMethodParameter> parameters = new HashMap<>(); private final Map<ConstantMethodParameter, ConstantMethodParameter> parameters = new HashMap<>();
private Multimap<Method, ConstantMethodParameter> mparams = HashMultimap.create(); private final Multimap<Method, ConstantMethodParameter> mparams = HashMultimap.create();
private void checkMethodsAreConsistent(List<Method> methods) private void checkMethodsAreConsistent(List<Method> methods)
{ {
@@ -436,23 +433,18 @@ public class ConstantParameter implements Deobfuscator
{ {
Object value = parameter.values.get(0); Object value = parameter.values.get(0);
Annotations annotations = m.getAnnotations(); Annotation obfuscatedSignature = m.findAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, true);
if (obfuscatedSignature.size() == 2)
Annotation obfuscatedSignature = annotations.find(DeobAnnotations.OBFUSCATED_SIGNATURE);
if (obfuscatedSignature != null && obfuscatedSignature.getElements().size() == 2)
{ {
// already annotated // already annotated
continue; continue;
} }
else if (obfuscatedSignature.size() == 0)
if (obfuscatedSignature == null)
{ {
obfuscatedSignature = annotations.addAnnotation(DeobAnnotations.OBFUSCATED_SIGNATURE, "signature", m.getDescriptor().toString()); obfuscatedSignature.setElement("descriptor", m.getDescriptor().toString());
} }
// Add garbage value obfuscatedSignature.setElement("garbageValue", String.valueOf(value));
Element element = new SimpleElement("garbageValue", value.toString());
obfuscatedSignature.addElement(element);
} }
} }
@@ -30,8 +30,6 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import net.runelite.mapping.Import; import net.runelite.mapping.Import;
import net.runelite.rs.api.RSClient; import net.runelite.rs.api.RSClient;
@@ -65,11 +63,6 @@ public class AnnotationIntegrityChecker
return errors; return errors;
} }
public int getWarnings()
{
return warnings;
}
public void run() public void run()
{ {
for (ClassFile cf : one.getClasses()) for (ClassFile cf : one.getClasses())
@@ -97,11 +90,11 @@ public class AnnotationIntegrityChecker
if (f1.isStatic()) if (f1.isStatic())
{ {
f2 = findExportedFieldStatic(two, DeobAnnotations.getExportedName(f1.getAnnotations())); f2 = findExportedFieldStatic(two, DeobAnnotations.getExportedName(f1));
} }
else else
{ {
f2 = findExportedField(other, DeobAnnotations.getExportedName(f1.getAnnotations())); f2 = findExportedField(other, DeobAnnotations.getExportedName(f1));
} }
if (f2 == null) if (f2 == null)
@@ -110,7 +103,7 @@ public class AnnotationIntegrityChecker
{ {
logger.error("Missing IMPORTED field on {} named {}", logger.error("Missing IMPORTED field on {} named {}",
other, other,
DeobAnnotations.getExportedName(f1.getAnnotations())); DeobAnnotations.getExportedName(f1));
++errors; ++errors;
} }
@@ -118,7 +111,7 @@ public class AnnotationIntegrityChecker
{ {
logger.warn("Missing exported field on {} named {}", logger.warn("Missing exported field on {} named {}",
other, other,
DeobAnnotations.getExportedName(f1.getAnnotations())); DeobAnnotations.getExportedName(f1));
++warnings; ++warnings;
} }
@@ -143,11 +136,11 @@ public class AnnotationIntegrityChecker
if (m1.isStatic()) if (m1.isStatic())
{ {
m2 = findExportedMethodStatic(two, DeobAnnotations.getExportedName(m1.getAnnotations())); m2 = findExportedMethodStatic(two, DeobAnnotations.getExportedName(m1));
} }
else else
{ {
m2 = findExportedMethod(other, DeobAnnotations.getExportedName(m1.getAnnotations())); m2 = findExportedMethod(other, DeobAnnotations.getExportedName(m1));
} }
if (m2 == null) if (m2 == null)
@@ -156,7 +149,7 @@ public class AnnotationIntegrityChecker
{ {
logger.error("Missing IMPORTED method on {} named {} ({})", logger.error("Missing IMPORTED method on {} named {} ({})",
other, other,
DeobAnnotations.getExportedName(m1.getAnnotations()), DeobAnnotations.getExportedName(m1),
m1); m1);
++errors; ++errors;
@@ -165,7 +158,7 @@ public class AnnotationIntegrityChecker
{ {
logger.warn("Missing exported method on {} named {} ({})", logger.warn("Missing exported method on {} named {} ({})",
other, other,
DeobAnnotations.getExportedName(m1.getAnnotations()), DeobAnnotations.getExportedName(m1),
m1); m1);
++warnings; ++warnings;
@@ -173,36 +166,6 @@ public class AnnotationIntegrityChecker
} }
} }
} }
checkAnnotationCounts();
}
private void checkAnnotationCounts()
{
for (ClassFile cf : two.getClasses())
{
for (Field f : cf.getFields())
{
int num = this.getNumberOfExports(f.getAnnotations());
if (num > 1)
{
logger.warn("Field {} has more than 1 export", f);
++errors;
}
}
for (Method m : cf.getMethods())
{
int num = this.getNumberOfExports(m.getAnnotations());
if (num > 1)
{
logger.warn("Method {} has more than 1 export", m);
++errors;
}
}
}
} }
/** /**
@@ -212,7 +175,6 @@ public class AnnotationIntegrityChecker
* @param cf Class file field/method is on * @param cf Class file field/method is on
* @param name Exported name of field/method * @param name Exported name of field/method
* @param isStatic Whether or not field/method is static * @param isStatic Whether or not field/method is static
* @return
*/ */
private boolean isImported(ClassFile cf, String name, boolean isStatic) private boolean isImported(ClassFile cf, String name, boolean isStatic)
{ {
@@ -259,7 +221,7 @@ public class AnnotationIntegrityChecker
List<Field> list = new ArrayList<>(); List<Field> list = new ArrayList<>();
for (Field f : clazz.getFields()) for (Field f : clazz.getFields())
{ {
if (DeobAnnotations.getExportedName(f.getAnnotations()) != null) if (DeobAnnotations.getExportedName(f) != null)
{ {
list.add(f); list.add(f);
} }
@@ -272,7 +234,7 @@ public class AnnotationIntegrityChecker
List<Method> list = new ArrayList<>(); List<Method> list = new ArrayList<>();
for (Method m : clazz.getMethods()) for (Method m : clazz.getMethods())
{ {
if (DeobAnnotations.getExportedName(m.getAnnotations()) != null) if (DeobAnnotations.getExportedName(m) != null)
{ {
list.add(m); list.add(m);
} }
@@ -280,26 +242,11 @@ public class AnnotationIntegrityChecker
return list; return list;
} }
private int getNumberOfExports(Annotations an)
{
int count = 0;
for (Annotation a : an.getAnnotations())
{
if (a.getType().equals(DeobAnnotations.EXPORT))
{
++count;
}
}
return count;
}
private Field findExportedField(ClassFile clazz, String name) private Field findExportedField(ClassFile clazz, String name)
{ {
for (Field f : getExportedFields(clazz)) for (Field f : getExportedFields(clazz))
{ {
if (DeobAnnotations.getExportedName(f.getAnnotations()).equals(name)) if (name.equals(DeobAnnotations.getExportedName(f)))
{ {
return f; return f;
} }
@@ -315,7 +262,7 @@ public class AnnotationIntegrityChecker
{ {
if (f.isStatic()) if (f.isStatic())
{ {
if (name.equals(DeobAnnotations.getExportedName(f.getAnnotations()))) if (name.equals(DeobAnnotations.getExportedName(f)))
{ {
return f; return f;
} }
@@ -333,7 +280,7 @@ public class AnnotationIntegrityChecker
{ {
if (m.isStatic()) if (m.isStatic())
{ {
if (name.equals(DeobAnnotations.getExportedName(m.getAnnotations()))) if (name.equals(DeobAnnotations.getExportedName(m)))
{ {
return m; return m;
} }
@@ -347,7 +294,7 @@ public class AnnotationIntegrityChecker
{ {
for (Method m : getExportedMethods(clazz)) for (Method m : getExportedMethods(clazz))
{ {
if (DeobAnnotations.getExportedName(m.getAnnotations()).equals(name)) if (name.equals(DeobAnnotations.getExportedName(m)))
{ {
return m; return m;
} }
@@ -29,10 +29,8 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.annotation.SimpleElement;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -69,11 +67,11 @@ public class AnnotationMapper
{ {
int count = 0; int count = 0;
if (hasCopyableAnnotation(from.getAnnotations())) if (hasCopyableAnnotation(from))
{ {
if (to != null) if (to != null)
{ {
count += copyAnnotations(from.getAnnotations(), to.getAnnotations()); count += copyAnnotations(from, to);
} }
else else
{ {
@@ -83,57 +81,49 @@ public class AnnotationMapper
for (Field f : from.getFields()) for (Field f : from.getFields())
{ {
if (!hasCopyableAnnotation(f.getAnnotations())) if (!hasCopyableAnnotation(f))
continue; continue;
Field other = (Field) mapping.get(f); Field other = (Field) mapping.get(f);
if (other == null) if (other == null)
{ {
logger.warn("Unable to map annotated field {} named {}", f, DeobAnnotations.getExportedName(f.getAnnotations())); logger.warn("Unable to map annotated field {} named {}", f, DeobAnnotations.getExportedName(f));
continue; continue;
} }
count += copyAnnotations(f.getAnnotations(), other.getAnnotations()); count += copyAnnotations(f, other);
} }
for (Method m : from.getMethods()) for (Method m : from.getMethods())
{ {
if (!hasCopyableAnnotation(m.getAnnotations())) if (!hasCopyableAnnotation(m))
continue; continue;
Method other = (Method) mapping.get(m); Method other = (Method) mapping.get(m);
if (other == null) if (other == null)
{ {
logger.warn("Unable to map annotated method {} named {}", m, DeobAnnotations.getExportedName(m.getAnnotations())); logger.warn("Unable to map annotated method {} named {}", m, DeobAnnotations.getExportedName(m));
continue; continue;
} }
count += copyAnnotations(m.getAnnotations(), other.getAnnotations()); count += copyAnnotations(m, other);
} }
return count; return count;
} }
private int copyAnnotations(Annotations from, Annotations to) private int copyAnnotations(Annotated from, Annotated to)
{ {
int count = 0; int count = 0;
if (from.getAnnotations() == null) if (from.getAnnotations() == null)
return count; return count;
for (Annotation a : from.getAnnotations()) for (Annotation a : from.getAnnotations().values())
{ {
if (isCopyable(a)) if (isCopyable(a))
{ {
Annotation annotation = new Annotation(a.getType()); to.addAnnotation(a.getType(), a);
to.addAnnotation(annotation);
for (Element e : a.getElements())
{
Element element = new SimpleElement(e.getName(), e.getValue());
annotation.addElement(element);
}
++count; ++count;
} }
} }
@@ -141,13 +131,9 @@ public class AnnotationMapper
return count; return count;
} }
private boolean hasCopyableAnnotation(Annotations a) private boolean hasCopyableAnnotation(Annotated a)
{ {
for (Annotation an : a.getAnnotations()) return a.findAnnotation(DeobAnnotations.EXPORT) != null || a.findAnnotation(DeobAnnotations.IMPLEMENTS) != null;
if (isCopyable(an))
return true;
return false;
} }
private boolean isCopyable(Annotation a) private boolean isCopyable(Annotation a)
@@ -36,7 +36,7 @@ import net.runelite.asm.signature.Signature;
public class StaticMethodSignatureMapper public class StaticMethodSignatureMapper
{ {
private Multimap<Method, Method> map = LinkedHashMultimap.create(); private final Multimap<Method, Method> map = LinkedHashMultimap.create();
private List<Method> getStaticMethods(ClassGroup group) private List<Method> getStaticMethods(ClassGroup group)
{ {
@@ -33,7 +33,6 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.code.Instruction; import net.runelite.asm.attributes.code.Instruction;
import static net.runelite.asm.attributes.code.InstructionType.INVOKEVIRTUAL;
import net.runelite.asm.attributes.code.Instructions; import net.runelite.asm.attributes.code.Instructions;
import net.runelite.asm.attributes.code.Label; import net.runelite.asm.attributes.code.Label;
import net.runelite.asm.attributes.code.instruction.types.InvokeInstruction; import net.runelite.asm.attributes.code.instruction.types.InvokeInstruction;
@@ -55,6 +54,7 @@ import net.runelite.deob.Deobfuscator;
import net.runelite.deob.c2s.RWOpcodeFinder; import net.runelite.deob.c2s.RWOpcodeFinder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import static net.runelite.asm.attributes.code.InstructionType.INVOKEVIRTUAL;
public class PacketWriteDeobfuscator implements Deobfuscator public class PacketWriteDeobfuscator implements Deobfuscator
{ {
@@ -5,10 +5,8 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Named;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.annotation.SimpleElement;
import net.runelite.deob.Deob; import net.runelite.deob.Deob;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -24,7 +22,6 @@ public class AnnotationAdder
private final ClassGroup group; private final ClassGroup group;
private final Logger log = LoggerFactory.getLogger(AnnotationAdder.class); private final Logger log = LoggerFactory.getLogger(AnnotationAdder.class);
@SuppressWarnings("unchecked")
public void run() public void run()
{ {
int impl = 0; int impl = 0;
@@ -46,83 +43,43 @@ public class AnnotationAdder
// Still error here cause I don't wanna call classes dumb shit // Still error here cause I don't wanna call classes dumb shit
assert implementingName.equals(c.getClassName()) : c + " implements " + implementingName + " but is called " + c.getClassName(); assert implementingName.equals(c.getClassName()) : c + " implements " + implementingName + " but is called " + c.getClassName();
} }
else else if (!Deob.isObfuscated(c.getClassName()))
{ {
if (!Deob.isObfuscated(c.getClassName())) c.addAnnotation(DeobAnnotations.IMPLEMENTS, c.getClassName());
{ impl++;
Annotations an = c.getAnnotations();
Annotation implAn = new Annotation(DeobAnnotations.IMPLEMENTS);
Element value = new SimpleElement(c.getClassName());
implAn.addElement(value);
an.addAnnotation(implAn);
impl++;
}
} }
for (Field f : c.getFields()) for (Field f : c.getFields())
{ {
Annotations an = f.getAnnotations(); if (addExport(f))
String fieldName = f.getName();
String exportedName = DeobAnnotations.getExportedName(an);
if (exportedName == null && Deob.isObfuscated(fieldName) || fieldName.equals(DeobAnnotations.getObfuscatedName(an)) || DeobAnnotations.getObfuscatedName(an) == null)
{
continue;
}
if (!fieldName.equals(exportedName))
{
log.info("Changed export from {} to {}", exportedName, fieldName);
Annotation a = an.find(DeobAnnotations.EXPORT);
if (a == null)
{
a = new Annotation(DeobAnnotations.EXPORT);
Element value = new SimpleElement(fieldName);
a.addElement(value);
an.addAnnotation(a);
}
a.getElement().setValue(fieldName);
field++; field++;
}
} }
for (Method m : c.getMethods()) for (Method m : c.getMethods())
{ {
Annotations an = m.getAnnotations(); if (addExport(m))
String methodName = m.getName();
String exportedName = DeobAnnotations.getExportedName(an);
if (exportedName == null && Deob.isObfuscated(methodName) || methodName.equals(DeobAnnotations.getObfuscatedName(an)) || DeobAnnotations.getObfuscatedName(an) == null)
{
continue;
}
if (!methodName.equals(exportedName))
{
log.info("Changed export from {} to {}", exportedName, methodName);
Annotation a = an.find(DeobAnnotations.EXPORT);
if (a == null)
{
a = new Annotation(DeobAnnotations.EXPORT);
Element value = new SimpleElement(methodName);
a.addElement(value);
an.addAnnotation(a);
}
a.getElement().setValue(methodName);
meth++; meth++;
}
} }
} }
log.info("Changed {} classes, {} methods, {} fields", impl, meth, field); log.info("Changed {} classes, {} methods, {} fields", impl, meth, field);
} }
private <T extends Annotated & Named> boolean addExport(T m)
{
String methodName = m.getName();
String exportedName = DeobAnnotations.getExportedName(m);
if (exportedName == null && Deob.isObfuscated(methodName)
|| methodName.equals(DeobAnnotations.getObfuscatedName(m))
|| DeobAnnotations.getObfuscatedName(m) == null
|| methodName.equals(exportedName))
{
return false;
}
log.info("Changed export from {} to {}", exportedName, methodName);
m.findAnnotation(DeobAnnotations.EXPORT, true).setElement(methodName);
return true;
}
} }
@@ -26,26 +26,26 @@
package net.runelite.deob.updater; package net.runelite.deob.updater;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.annotation.SimpleElement;
public class AnnotationCopier public class AnnotationCopier
{ {
private final ClassGroup group1, group2; private final ClassGroup group1, group2;
private final Type[] types; private final Set<Type> types;
public AnnotationCopier(ClassGroup group1, ClassGroup group2, Type... types) public AnnotationCopier(ClassGroup group1, ClassGroup group2, Type... types)
{ {
this.group1 = group1; this.group1 = group1;
this.group2 = group2; this.group2 = group2;
this.types = types; this.types = new HashSet<>(Arrays.asList(types));
} }
public void copy() public void copy()
@@ -56,63 +56,46 @@ public class AnnotationCopier
assert cf2 != null; assert cf2 != null;
copy(cf1.getAnnotations(), cf2.getAnnotations()); copy(cf1, cf2);
for (Field f : cf1.getFields()) for (Field f : cf1.getFields())
{ {
Field f2 = cf2.findField(f.getName(), f.getType()); Field f2 = cf2.findField(f.getName(), f.getType());
assert f2 != null || f.getAnnotations() == null; assert f2 != null || f.getAnnotations().isEmpty();
if (f2 == null) if (f2 == null)
continue; continue;
copy(f.getAnnotations(), f2.getAnnotations()); copy(f, f2);
} }
for (Method m : cf1.getMethods()) for (Method m : cf1.getMethods())
{ {
Method m2 = cf2.findMethod(m.getName(), m.getDescriptor()); Method m2 = cf2.findMethod(m.getName(), m.getDescriptor());
assert m2 != null || m.getAnnotations() == null; assert m2 != null || m == null;
if (m2 == null) if (m2 == null)
continue; continue;
copy(m.getAnnotations(), m2.getAnnotations()); copy(m, m2);
} }
} }
} }
private void copy(Annotations an, Annotations an2) private void copy(Annotated an, Annotated an2)
{ {
for (Annotation a : an2.getAnnotations()) for (Annotation a : an.getAnnotations().values())
{ {
if (isType(a.getType())) final var t = a.getType();
{ if (isType(t))
an2.removeAnnotation(a); an2.getAnnotations().replace(t, a);
}
}
for (Annotation a : an.getAnnotations())
{
if (!isType(a.getType()))
continue;
Annotation a2 = new Annotation(a.getType());
for (Element element : a.getElements())
{
Element element2 = new SimpleElement(element.getName(), element.getValue());
a2.addElement(element2);
}
an2.addAnnotation(a2);
} }
} }
private boolean isType(Type type) private boolean isType(Type type)
{ {
return Arrays.asList(types).contains(type); return types.contains(type);
} }
} }
@@ -29,8 +29,8 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.Annotated;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import net.runelite.deob.deobfuscators.Renamer; import net.runelite.deob.deobfuscators.Renamer;
import net.runelite.deob.util.NameMappings; import net.runelite.deob.util.NameMappings;
@@ -58,20 +58,20 @@ public class AnnotationRenamer
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
String name = getImplements(cf.getAnnotations()); String name = getImplements(cf);
if (name != null) if (name != null)
mappings.map(cf.getPoolClass(), name); mappings.map(cf.getPoolClass(), name);
for (Field f : cf.getFields()) for (Field f : cf.getFields())
{ {
name = DeobAnnotations.getExportedName(f.getAnnotations()); name = DeobAnnotations.getExportedName(f);
if (name != null) if (name != null)
mappings.map(f.getPoolField(), name); mappings.map(f.getPoolField(), name);
} }
for (Method m : cf.getMethods()) for (Method m : cf.getMethods())
{ {
name = DeobAnnotations.getExportedName(m.getAnnotations()); name = DeobAnnotations.getExportedName(m);
if (name != null) if (name != null)
mappings.map(m.getPoolMethod(), name); mappings.map(m.getPoolMethod(), name);
} }
@@ -80,9 +80,9 @@ public class AnnotationRenamer
return mappings; return mappings;
} }
private String getImplements(Annotations annotations) private String getImplements(Annotated cf)
{ {
Annotation an = annotations.find(DeobAnnotations.IMPLEMENTS); Annotation an = cf.findAnnotation(DeobAnnotations.IMPLEMENTS);
return an != null ? an.getElement().getString() : null; return an == null ? null : an.getValueString();
} }
} }
@@ -27,7 +27,7 @@ public class MappedClass
implementingName = DeobAnnotations.getImplements(c); implementingName = DeobAnnotations.getImplements(c);
obfuscatedName = DeobAnnotations.getObfuscatedName(c.getAnnotations()); obfuscatedName = DeobAnnotations.getObfuscatedName(c);
if (obfuscatedName == null) if (obfuscatedName == null)
{ {
obfuscatedName = c.getName(); obfuscatedName = c.getName();
@@ -36,7 +36,7 @@ public class MappedClass
ClassFile parent = c.getParent(); ClassFile parent = c.getParent();
if (parent != null) if (parent != null)
{ {
superClass = DeobAnnotations.getObfuscatedName(parent.getAnnotations()); superClass = DeobAnnotations.getObfuscatedName(parent);
} }
access = c.getAccess(); access = c.getAccess();
@@ -44,7 +44,6 @@ public class MappedClass
interfaces = c.getInterfaces() interfaces = c.getInterfaces()
.getMyInterfaces() .getMyInterfaces()
.stream() .stream()
.map(ClassFile::getAnnotations)
.map(DeobAnnotations::getObfuscatedName) .map(DeobAnnotations::getObfuscatedName)
.collect(Collectors.toList()); .collect(Collectors.toList());
@@ -26,11 +26,11 @@ public class MappedField
{ {
MappingDumper.putMap(f.getPoolField(), this); MappingDumper.putMap(f.getPoolField(), this);
exportedName = DeobAnnotations.getExportedName(f.getAnnotations()); exportedName = DeobAnnotations.getExportedName(f);
owner = MappingDumper.getMap(f.getClassFile()).obfuscatedName; owner = MappingDumper.getMap(f.getClassFile()).obfuscatedName;
obfuscatedName = DeobAnnotations.getObfuscatedName(f.getAnnotations()); obfuscatedName = DeobAnnotations.getObfuscatedName(f);
if (obfuscatedName == null) if (obfuscatedName == null)
{ {
obfuscatedName = f.getName(); obfuscatedName = f.getName();
@@ -4,6 +4,7 @@ import com.google.gson.annotations.SerializedName;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Code; import net.runelite.asm.attributes.Code;
@@ -37,11 +38,11 @@ public class MappedMethod
public MappedMethod visitMethod(final Method m, final MappingDump dump) public MappedMethod visitMethod(final Method m, final MappingDump dump)
{ {
MappingDumper.putMap(m.getPoolMethod(), this); MappingDumper.putMap(m.getPoolMethod(), this);
exportedName = DeobAnnotations.getExportedName(m.getAnnotations()); exportedName = DeobAnnotations.getExportedName(m);
owner = MappingDumper.getMap(m.getClassFile()).obfuscatedName; owner = MappingDumper.getMap(m.getClassFile()).obfuscatedName;
obfuscatedName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); obfuscatedName = DeobAnnotations.getObfuscatedName(m);
if (obfuscatedName == null) if (obfuscatedName == null)
{ {
obfuscatedName = m.getName(); obfuscatedName = m.getName();
@@ -94,8 +95,8 @@ public class MappedMethod
{ {
Method mme = met.get(0); Method mme = met.get(0);
k = new net.runelite.asm.pool.Method( k = new net.runelite.asm.pool.Method(
new Class(DeobAnnotations.getObfuscatedName(mme.getClassFile().getAnnotations())), new Class(Objects.requireNonNull(DeobAnnotations.getObfuscatedName(mme.getClassFile()))),
DeobAnnotations.getObfuscatedName(mme.getAnnotations()), DeobAnnotations.getObfuscatedName(mme),
mme.getObfuscatedSignature() != null ? mme.getObfuscatedSignature() : mme.getDescriptor() mme.getObfuscatedSignature() != null ? mme.getObfuscatedSignature() : mme.getDescriptor()
); );
} }
@@ -34,7 +34,6 @@ import java.util.Enumeration;
import java.util.jar.JarEntry; import java.util.jar.JarEntry;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.JarOutputStream; import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.objectwebasm.NonloadingClassWriter; import net.runelite.asm.objectwebasm.NonloadingClassWriter;
@@ -118,11 +117,12 @@ public class JarUtil
public static void saveJar(ClassGroup group, File jarfile) throws IOException public static void saveJar(ClassGroup group, File jarfile) throws IOException
{ {
try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile), new Manifest())) try (JarOutputStream jout = new JarOutputStream(new FileOutputStream(jarfile)))
{ {
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
JarEntry entry = new JarEntry(cf.getName() + ".class"); JarEntry entry = new JarEntry(cf.getName() + ".class");
entry.setTime(-1);
jout.putNextEntry(entry); jout.putNextEntry(entry);
byte[] data = writeClass(group, cf); byte[] data = writeClass(group, cf);
@@ -27,6 +27,8 @@ package net.runelite.deob.util;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import net.runelite.asm.pool.Class; import net.runelite.asm.pool.Class;
import net.runelite.asm.pool.Field; import net.runelite.asm.pool.Field;
import net.runelite.asm.pool.Method; import net.runelite.asm.pool.Method;
@@ -37,6 +39,10 @@ public class NameMappings
private final Map<Object, String[]> paramMap = new HashMap<>(); private final Map<Object, String[]> paramMap = new HashMap<>();
@Getter
@Setter
private int fields, methods, classes;
public void map(Class cf, String name) public void map(Class cf, String name)
{ {
map.put(cf, name); map.put(cf, name);
@@ -27,16 +27,11 @@ package net.runelite.asm.annotations;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List;
import java.util.Optional;
import net.runelite.asm.ClassFile; import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.ClassUtil; import net.runelite.asm.ClassUtil;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.deob.util.JarUtil; import net.runelite.deob.util.JarUtil;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
@@ -62,20 +57,14 @@ public class AnnotationTest
Method method = cf.getMethods().get(1); Method method = cf.getMethods().get(1);
Assert.assertEquals("method1", method.getName()); Assert.assertEquals("method1", method.getName());
Annotations annotations = method.getAnnotations(); var annotation = method.findAnnotation(new Type("Lnet/runelite/asm/annotations/MyAnnotation;"));
Assert.assertNotNull(annotations); Assert.assertNotNull(annotation);
Optional<Annotation> annotation = annotations.getAnnotations().stream().filter(a -> a.getType().equals(new Type("Lnet/runelite/asm/annotations/MyAnnotation;"))).findFirst(); Assert.assertEquals(1, annotation.size());
Assert.assertTrue(annotation.isPresent());
Annotation an = annotation.get(); Object element = annotation.getValue();
List<Element> elements = an.getElements(); Object also = annotation.get("value");
Assert.assertEquals(also, element);
Assert.assertEquals(1, elements.size()); Assert.assertEquals("method1", element);
Element element = elements.get(0);
Assert.assertEquals("value", element.getName());
Assert.assertEquals("method1", element.getValue());
} }
} }
@@ -82,7 +82,7 @@ public class MappingDumper
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
String implName = cf.getName(); String implName = cf.getName();
String className = DeobAnnotations.getObfuscatedName(cf.getAnnotations()); String className = DeobAnnotations.getObfuscatedName(cf);
if (implName != null) if (implName != null)
{ {
@@ -92,7 +92,7 @@ public class MappingDumper
for (Field f : cf.getFields()) for (Field f : cf.getFields())
{ {
String exportName = DeobAnnotations.getExportedName(f.getAnnotations()); String exportName = DeobAnnotations.getExportedName(f);
if (exportName == null) if (exportName == null)
{ {
@@ -101,7 +101,7 @@ public class MappingDumper
++fields; ++fields;
String fieldName = DeobAnnotations.getObfuscatedName(f.getAnnotations()); String fieldName = DeobAnnotations.getObfuscatedName(f);
Type type = f.getType(); Type type = f.getType();
Number getter = DeobAnnotations.getObfuscatedGetter(f); Number getter = DeobAnnotations.getObfuscatedGetter(f);
@@ -171,7 +171,7 @@ public class MappingDumper
for (Method m : cf.getMethods()) for (Method m : cf.getMethods())
{ {
String exportName = DeobAnnotations.getExportedName(m.getAnnotations()); String exportName = DeobAnnotations.getExportedName(m);
if (exportName == null) if (exportName == null)
{ {
@@ -180,7 +180,7 @@ public class MappingDumper
methods++; methods++;
String methodName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); String methodName = DeobAnnotations.getObfuscatedName(m);
Signature signature = DeobAnnotations.getObfuscatedSignature(m); Signature signature = DeobAnnotations.getObfuscatedSignature(m);
String garbageValue = DeobAnnotations.getDecoder(m); String garbageValue = DeobAnnotations.getDecoder(m);
@@ -329,18 +329,18 @@ public class MappingDumper
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
String implName = DeobAnnotations.getImplements(cf); String implName = DeobAnnotations.getImplements(cf);
String className = DeobAnnotations.getObfuscatedName(cf.getAnnotations()); String className = DeobAnnotations.getObfuscatedName(cf);
for (Field f : cf.getFields()) for (Field f : cf.getFields())
{ {
String exportName = DeobAnnotations.getExportedName(f.getAnnotations()); String exportName = DeobAnnotations.getExportedName(f);
if (exportName == null) if (exportName == null)
{ {
continue; continue;
} }
String fieldName = DeobAnnotations.getObfuscatedName(f.getAnnotations()); String fieldName = DeobAnnotations.getObfuscatedName(f);
Type obfType = DeobAnnotations.getObfuscatedType(f); Type obfType = DeobAnnotations.getObfuscatedType(f);
Number getter = DeobAnnotations.getObfuscatedGetter(f); Number getter = DeobAnnotations.getObfuscatedGetter(f);
@@ -351,7 +351,7 @@ public class MappingDumper
jField.addProperty("class", className); jField.addProperty("class", className);
jField.addProperty("field", fieldName); jField.addProperty("field", fieldName);
jField.addProperty("obfSignature", (obfType != null ? obfType.toString() : "")); jField.addProperty("obfSignature", (obfType != null ? obfType.toString() : ""));
jField.addProperty("signature", f.getType().toString()); jField.addProperty("descriptor", f.getType().toString());
jField.addProperty("multiplier", (getter != null ? getter : 0)); jField.addProperty("multiplier", (getter != null ? getter : 0));
jField.addProperty("static", f.isStatic()); jField.addProperty("static", f.isStatic());
@@ -361,14 +361,14 @@ public class MappingDumper
for (Method m : cf.getMethods()) for (Method m : cf.getMethods())
{ {
String exportName = DeobAnnotations.getExportedName(m.getAnnotations()); String exportName = DeobAnnotations.getExportedName(m);
if (exportName == null) if (exportName == null)
{ {
continue; continue;
} }
String methodName = DeobAnnotations.getObfuscatedName(m.getAnnotations()); String methodName = DeobAnnotations.getObfuscatedName(m);
Signature obfSignature = DeobAnnotations.getObfuscatedSignature(m); Signature obfSignature = DeobAnnotations.getObfuscatedSignature(m);
String predicate = DeobAnnotations.getDecoder(m); String predicate = DeobAnnotations.getDecoder(m);
@@ -379,7 +379,7 @@ public class MappingDumper
jMethod.addProperty("class", className); jMethod.addProperty("class", className);
jMethod.addProperty("field", methodName); jMethod.addProperty("field", methodName);
jMethod.addProperty("obfSignature", (obfSignature != null ? obfSignature.toString() : "")); jMethod.addProperty("obfSignature", (obfSignature != null ? obfSignature.toString() : ""));
jMethod.addProperty("signature", m.getDescriptor().toString()); jMethod.addProperty("descriptor", m.getDescriptor().toString());
jMethod.addProperty("predicate", (predicate != null ? predicate : "")); jMethod.addProperty("predicate", (predicate != null ? predicate : ""));
jMethod.addProperty("static", m.isStatic()); jMethod.addProperty("static", m.isStatic());
@@ -8,7 +8,6 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.attributes.Annotations;
import net.runelite.deob.Deob; import net.runelite.deob.Deob;
import net.runelite.deob.DeobAnnotations; import net.runelite.deob.DeobAnnotations;
import net.runelite.deob.DeobTestProperties; import net.runelite.deob.DeobTestProperties;
@@ -58,14 +57,12 @@ public class AnnotationCleaner
for (Field f : c.getFields()) for (Field f : c.getFields())
{ {
Annotations an = f.getAnnotations();
String fieldName = f.getName(); String fieldName = f.getName();
String exportedName = DeobAnnotations.getExportedName(an); String exportedName = DeobAnnotations.getExportedName(f);
if (exportedName == null) if (exportedName == null)
{ {
if (!Deob.isObfuscated(fieldName) && DeobAnnotations.getObfuscatedName(an) != null) if (!Deob.isObfuscated(fieldName) && DeobAnnotations.getObfuscatedName(f) != null)
{ {
missing.add("Export: (field) " + className + '.' + fieldName + " == missing"); missing.add("Export: (field) " + className + '.' + fieldName + " == missing");
} }
@@ -78,14 +75,12 @@ public class AnnotationCleaner
for (Method m : c.getMethods()) for (Method m : c.getMethods())
{ {
Annotations an = m.getAnnotations();
String methodName = m.getName(); String methodName = m.getName();
String exportedName = DeobAnnotations.getExportedName(an); String exportedName = DeobAnnotations.getExportedName(m);
if (exportedName == null) if (exportedName == null)
{ {
if (!Deob.isObfuscated(methodName) && DeobAnnotations.getObfuscatedName(an) != null) if (!Deob.isObfuscated(methodName) && DeobAnnotations.getObfuscatedName(m) != null)
{ {
missing.add("Export: (method) " + className + '.' + methodName + " == missing"); missing.add("Export: (method) " + className + '.' + methodName + " == missing");
} }
@@ -124,7 +119,7 @@ public class AnnotationCleaner
JarUtil.saveJar(group, new File("C:/Users/Lucas/Desktop/niec.jar")); JarUtil.saveJar(group, new File("C:/Users/Lucas/Desktop/niec.jar"));
} }
private class OhNoException extends Exception private static class OhNoException extends Exception
{ {
private OhNoException() private OhNoException()
{ {
@@ -105,16 +105,16 @@ public class UpdateMappingsTest
{ {
for (ClassFile cf : group.getClasses()) for (ClassFile cf : group.getClasses())
{ {
cf.getAnnotations().clearAnnotations(); cf.getAnnotations().clear();
for (Field f : cf.getFields()) for (Field f : cf.getFields())
{ {
f.getAnnotations().clearAnnotations(); f.getAnnotations().clear();
} }
for (Method m : cf.getMethods()) for (Method m : cf.getMethods())
{ {
m.getAnnotations().clearAnnotations(); m.getAnnotations().clear();
} }
} }
} }
@@ -136,8 +136,8 @@ public class UpdateMappingsTest
assert otherf != null : "unable to find " + f; assert otherf != null : "unable to find " + f;
String name = DeobAnnotations.getExportedName(f.getAnnotations()); String name = DeobAnnotations.getExportedName(f);
String otherName = DeobAnnotations.getExportedName(otherf.getAnnotations()); String otherName = DeobAnnotations.getExportedName(otherf);
Assert.assertEquals(name + " <-> " + otherName, name, otherName); Assert.assertEquals(name + " <-> " + otherName, name, otherName);
} }
@@ -148,8 +148,8 @@ public class UpdateMappingsTest
assert otherm != null : "unable to find " + m; assert otherm != null : "unable to find " + m;
String name = DeobAnnotations.getExportedName(m.getAnnotations()); String name = DeobAnnotations.getExportedName(m);
String otherName = DeobAnnotations.getExportedName(otherm.getAnnotations()); String otherName = DeobAnnotations.getExportedName(otherm);
Assert.assertEquals(name + " <-> " + otherName, name, otherName); Assert.assertEquals(name + " <-> " + otherName, name, otherName);
} }
@@ -36,10 +36,9 @@ import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
import net.runelite.deob.DeobAnnotations;
import net.runelite.deob.util.JarUtil; import net.runelite.deob.util.JarUtil;
import net.runelite.osb.inject.ClassHook; import net.runelite.osb.inject.ClassHook;
import net.runelite.osb.inject.FieldHook; import net.runelite.osb.inject.FieldHook;
@@ -88,17 +87,17 @@ public class HookImporter
{ {
int classes = 0, fields = 0, methods = 0, callbacks = 0; int classes = 0, fields = 0, methods = 0, callbacks = 0;
for (String deobfuscatedClassName : hooks.keySet()) for (Map.Entry<String, ClassHook> entry : hooks.entrySet())
{ {
ClassHook ch = hooks.get(deobfuscatedClassName); ClassHook ch = entry.getValue();
ClassFile cf = this.findClassWithObfuscatedName(ch.getClazz()); ClassFile cf = this.findClassWithObfuscatedName(ch.getClazz());
assert cf != null; assert cf != null;
String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS); String implementsName = getAnnotation(cf, IMPLEMENTS);
if (implementsName.isEmpty()) if (implementsName.isEmpty())
{ {
cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName); cf.addAnnotation(IMPLEMENTS, entry.getKey());
++classes; ++classes;
} }
@@ -127,10 +126,10 @@ public class HookImporter
assert f != null; assert f != null;
String exportedName = getAnnotation(f.getAnnotations(), EXPORT); String exportedName = getAnnotation(f, EXPORT);
if (exportedName.isEmpty()) if (exportedName.isEmpty())
{ {
f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName); f.addAnnotation(EXPORT, deobfuscatedFieldName);
++fields; ++fields;
} }
} }
@@ -160,10 +159,10 @@ public class HookImporter
assert m != null; assert m != null;
String exportedName = getAnnotation(m.getAnnotations(), EXPORT); String exportedName = getAnnotation(m, EXPORT);
if (exportedName.isEmpty()) if (exportedName.isEmpty())
{ {
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName); m.addAnnotation(EXPORT, deobfuscatedMethodName);
++methods; ++methods;
} }
} }
@@ -193,10 +192,10 @@ public class HookImporter
assert m != null; assert m != null;
String exportedName = getAnnotation(m.getAnnotations(), EXPORT); String exportedName = getAnnotation(m, EXPORT);
if (exportedName.isEmpty()) if (exportedName.isEmpty())
{ {
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName); m.addAnnotation(EXPORT, deobfuscatedMethodName);
++callbacks; ++callbacks;
} }
} }
@@ -214,8 +213,7 @@ public class HookImporter
return c; return c;
} }
Annotations an = c.getAnnotations(); if (getAnnotation(c, OBFUSCATED_NAME).equals(name))
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
return c; return c;
} }
@@ -227,8 +225,7 @@ public class HookImporter
{ {
for (Field f : c.getFields()) for (Field f : c.getFields())
{ {
Annotations an = f.getAnnotations(); if (name.equals(DeobAnnotations.getObfuscatedName(f)))
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
return f; return f;
} }
@@ -242,8 +239,7 @@ public class HookImporter
for (Method m : c.getMethods()) for (Method m : c.getMethods())
{ {
Annotations an = m.getAnnotations(); if (getAnnotation(m, OBFUSCATED_NAME).equals(name))
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
Signature methodSig = getObfuscatedMethodSignature(m); Signature methodSig = getObfuscatedMethodSignature(m);
@@ -261,30 +257,15 @@ public class HookImporter
return null; return null;
} }
private String getAnnotation(Annotations an, Type type) private String getAnnotation(Annotated an, Type type)
{ {
if (an == null) final var s = DeobAnnotations.getStringValue(an, type);
{ return s == null ? "" : s;
return "";
}
for (Annotation a : an.getAnnotations())
{
if (a.getType().equals(type))
{
for (Element e : a.getElements())
{
return (String) e.getValue();
}
}
}
return "";
} }
private Signature getObfuscatedMethodSignature(Method method) private Signature getObfuscatedMethodSignature(Method method)
{ {
String sig = getAnnotation(method.getAnnotations(), OBFUSCATED_SIGNATURE); String sig = getAnnotation(method, OBFUSCATED_SIGNATURE);
if (!sig.isEmpty()) if (!sig.isEmpty())
{ {
return toObSignature(new Signature(sig)); // if it is annoted, use that return toObSignature(new Signature(sig)); // if it is annoted, use that
@@ -310,8 +291,7 @@ public class HookImporter
ClassFile cf = group.findClass(t.getInternalName()); ClassFile cf = group.findClass(t.getInternalName());
assert cf != null; assert cf != null;
Annotations an = cf.getAnnotations(); String obfuscatedName = (String) cf.findAnnotation(OBFUSCATED_NAME).getValue();
String obfuscatedName = an.find(OBFUSCATED_NAME).getElement().getString();
return Type.getType("L" + obfuscatedName + ";", t.getDimensions()); return Type.getType("L" + obfuscatedName + ";", t.getDimensions());
} }
@@ -30,9 +30,9 @@ import net.runelite.asm.ClassFile;
import net.runelite.asm.ClassGroup; import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.Annotation;
import net.runelite.asm.attributes.annotation.Annotation; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Element; import net.runelite.deob.DeobAnnotations;
import net.runelite.deob.util.JarUtil; import net.runelite.deob.util.JarUtil;
import net.runelite.runeloader.inject.AddInterfaceInstruction; import net.runelite.runeloader.inject.AddInterfaceInstruction;
import net.runelite.runeloader.inject.GetterInjectInstruction; import net.runelite.runeloader.inject.GetterInjectInstruction;
@@ -73,29 +73,13 @@ public class MappingImporter
JarUtil.saveJar(group, OUT); JarUtil.saveJar(group, OUT);
} }
private boolean hasObfuscatedName(Annotations an, String name) private boolean hasObfuscatedName(Annotated an, String name)
{ {
if (an == null) if (an == null)
{ {
return false; return false;
} }
return name.equals(DeobAnnotations.getStringValue(an, OBFUSCATED_NAME));
for (Annotation a : an.getAnnotations())
{
if (a.getType().equals(OBFUSCATED_NAME))
{
for (Element e : a.getElements())
{
String str = (String) e.getValue();
if (str.equals(name))
{
return true;
}
}
}
}
return false;
} }
private ClassFile findClassWithObfuscatedName(String name) private ClassFile findClassWithObfuscatedName(String name)
@@ -107,8 +91,7 @@ public class MappingImporter
return c; return c;
} }
Annotations an = c.getAnnotations(); if (this.hasObfuscatedName(c, name))
if (this.hasObfuscatedName(an, name))
{ {
return c; return c;
} }
@@ -120,8 +103,7 @@ public class MappingImporter
{ {
for (Field f : c.getFields()) for (Field f : c.getFields())
{ {
Annotations an = f.getAnnotations(); if (this.hasObfuscatedName(f, name))
if (this.hasObfuscatedName(an, name))
{ {
return f; return f;
} }
@@ -131,7 +113,7 @@ public class MappingImporter
@Test @Test
@Ignore @Ignore
public void makeMappings() throws IOException public void makeMappings()
{ {
InjectionModscript mod = Injection.load(MappingImporter.class.getResourceAsStream(RL_INJECTION)); InjectionModscript mod = Injection.load(MappingImporter.class.getResourceAsStream(RL_INJECTION));
int fields = 0, classes = 0; int fields = 0, classes = 0;
@@ -154,12 +136,10 @@ public class MappingImporter
String attrName = gii.getGetterName(); String attrName = gii.getGetterName();
attrName = Utils.toExportedName(attrName); attrName = Utils.toExportedName(attrName);
Annotations an = f.getAnnotations(); Annotation a = f.findAnnotation(EXPORT);
Annotation a = an.find(EXPORT);
if (a != null) if (a != null)
{ {
String exportedName = a.getElement().getString(); String exportedName = a.getValueString();
if (!attrName.equals(exportedName)) if (!attrName.equals(exportedName))
{ {
@@ -168,7 +148,7 @@ public class MappingImporter
} }
else else
{ {
an.addAnnotation(EXPORT, "value", attrName); f.addAnnotation(EXPORT, attrName);
logger.info("Exporting field " + f + " with name " + attrName); logger.info("Exporting field " + f + " with name " + attrName);
++fields; ++fields;
@@ -184,12 +164,10 @@ public class MappingImporter
iface = iface.replace("com/runeloader/api/bridge/os/accessor/", ""); iface = iface.replace("com/runeloader/api/bridge/os/accessor/", "");
Annotations an = cf.getAnnotations(); Annotation a = cf.findAnnotation(IMPLEMENTS);
Annotation a = an.find(IMPLEMENTS);
if (a != null) if (a != null)
{ {
String implementsName = a.getElement().getString(); String implementsName = a.getValueString();
if (!iface.equals(implementsName)) if (!iface.equals(implementsName))
{ {
@@ -198,7 +176,7 @@ public class MappingImporter
} }
else else
{ {
an.addAnnotation(IMPLEMENTS, "value", iface); cf.addAnnotation(IMPLEMENTS, iface);
logger.info("Exporting class " + cf.getName() + " with name " + iface); logger.info("Exporting class " + cf.getName() + " with name " + iface);
++classes; ++classes;
@@ -36,9 +36,7 @@ import net.runelite.asm.ClassGroup;
import net.runelite.asm.Field; import net.runelite.asm.Field;
import net.runelite.asm.Method; import net.runelite.asm.Method;
import net.runelite.asm.Type; import net.runelite.asm.Type;
import net.runelite.asm.attributes.Annotations; import net.runelite.asm.attributes.Annotated;
import net.runelite.asm.attributes.annotation.Annotation;
import net.runelite.asm.attributes.annotation.Element;
import net.runelite.asm.attributes.code.LocalVariable; import net.runelite.asm.attributes.code.LocalVariable;
import net.runelite.asm.attributes.code.Parameter; import net.runelite.asm.attributes.code.Parameter;
import net.runelite.asm.signature.Signature; import net.runelite.asm.signature.Signature;
@@ -107,11 +105,11 @@ public class HookImporter
assert cf != null; assert cf != null;
String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS); String implementsName = getAnnotation(cf, IMPLEMENTS);
if (implementsName.isEmpty()) if (implementsName.isEmpty())
{ {
String deobfuscatedClassName = hc.clazz; String deobfuscatedClassName = hc.clazz;
cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName); cf.addAnnotation(IMPLEMENTS, deobfuscatedClassName);
mappings.map(cf.getPoolClass(), deobfuscatedClassName); mappings.map(cf.getPoolClass(), deobfuscatedClassName);
++classes; ++classes;
} }
@@ -138,7 +136,7 @@ public class HookImporter
continue; continue;
} }
String exportedName = getAnnotation(f.getAnnotations(), EXPORT); String exportedName = getAnnotation(f, EXPORT);
if (exportedName.isEmpty()) if (exportedName.isEmpty())
{ {
String deobfuscatedFieldName = fh.field; String deobfuscatedFieldName = fh.field;
@@ -150,7 +148,7 @@ public class HookImporter
continue; continue;
} }
f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName); f.addAnnotation(EXPORT, deobfuscatedFieldName);
mappings.map(f.getPoolField(), deobfuscatedFieldName); mappings.map(f.getPoolField(), deobfuscatedFieldName);
++fields; ++fields;
} }
@@ -219,7 +217,7 @@ public class HookImporter
List<Method> virtualMethods = VirtualMethods.getVirtualMethods(m); List<Method> virtualMethods = VirtualMethods.getVirtualMethods(m);
for (Method method : virtualMethods) for (Method method : virtualMethods)
{ {
String exportedName = getAnnotation(method.getAnnotations(), EXPORT); String exportedName = getAnnotation(method, EXPORT);
if (!exportedName.isEmpty()) if (!exportedName.isEmpty())
{ {
if (!exportedName.equals(hm.method)) if (!exportedName.equals(hm.method))
@@ -231,7 +229,7 @@ public class HookImporter
} }
String deobfuscatedMethodName = hm.method; String deobfuscatedMethodName = hm.method;
m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName); m.addAnnotation(EXPORT, deobfuscatedMethodName);
mappings.map(m.getPoolMethod(), deobfuscatedMethodName); mappings.map(m.getPoolMethod(), deobfuscatedMethodName);
++methods; ++methods;
} }
@@ -252,8 +250,7 @@ public class HookImporter
return c; return c;
} }
Annotations an = c.getAnnotations(); if (getAnnotation(c, OBFUSCATED_NAME).equals(name))
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
return c; return c;
} }
@@ -265,8 +262,7 @@ public class HookImporter
{ {
for (Field f : c.getFields()) for (Field f : c.getFields())
{ {
Annotations an = f.getAnnotations(); if (getAnnotation(f, OBFUSCATED_NAME).equals(name))
if (getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
return f; return f;
} }
@@ -280,8 +276,7 @@ public class HookImporter
for (Method m : c.getMethods()) for (Method m : c.getMethods())
{ {
Annotations an = m.getAnnotations(); if (m.getName().equals(name) || getAnnotation(m, OBFUSCATED_NAME).equals(name))
if (m.getName().equals(name) || getAnnotation(an, OBFUSCATED_NAME).equals(name))
{ {
Signature methodSig = getObfuscatedMethodSignature(m); Signature methodSig = getObfuscatedMethodSignature(m);
@@ -294,15 +289,12 @@ public class HookImporter
return null; return null;
} }
private String getAnnotation(Annotations an, Type type) private String getAnnotation(Annotated an, Type type)
{ {
Annotation a = an.find(type); final var a = an.findAnnotation(type);
if (a != null) if (a != null)
{ {
for (Element e : a.getElements()) return a.getValueString();
{
return (String) e.getValue();
}
} }
return ""; return "";
@@ -310,7 +302,7 @@ public class HookImporter
private Signature getObfuscatedMethodSignature(Method method) private Signature getObfuscatedMethodSignature(Method method)
{ {
String sig = getAnnotation(method.getAnnotations(), OBFUSCATED_SIGNATURE); String sig = getAnnotation(method, OBFUSCATED_SIGNATURE);
if (sig.isEmpty()) if (sig.isEmpty())
{ {
return method.getDescriptor(); return method.getDescriptor();
Binary file not shown.
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-6.6-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
Vendored
+3 -18
View File
@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1 %JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init if "%ERRORLEVEL%" == "0" goto execute
echo. echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=% set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init if exist "%JAVA_EXE%" goto execute
echo. echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute :execute
@rem Setup the command line @rem Setup the command line
@@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle @rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end :end
@rem End local scope for the variables with windows NT shell @rem End local scope for the variables with windows NT shell
+3 -4
View File
@@ -30,18 +30,17 @@ description = "Web API"
dependencies { dependencies {
annotationProcessor(group = "org.projectlombok", name = "lombok", version = "1.18.12") annotationProcessor(group = "org.projectlombok", name = "lombok", version = "1.18.12")
compileOnly(group = "javax.inject", name = "javax.inject", version = "1")
compileOnly(group = "org.projectlombok", name = "lombok", version = "1.18.12") compileOnly(group = "org.projectlombok", name = "lombok", version = "1.18.12")
implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6") implementation(group = "com.google.code.gson", name = "gson", version = "2.8.6")
implementation(group = "com.google.guava", name = "guava", version = "29.0-jre") implementation(group = "com.google.guava", name = "guava", version = "29.0-jre")
implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.7.2") implementation(group = "com.squareup.okhttp3", name = "okhttp", version = "4.8.0")
implementation(group = "io.reactivex.rxjava3", name = "rxjava", version = "3.0.4") implementation(group = "io.reactivex.rxjava3", name = "rxjava", version = "3.0.5")
implementation(group = "org.apache.commons", name = "commons-csv", version = "1.8") implementation(group = "org.apache.commons", name = "commons-csv", version = "1.8")
implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30") implementation(group = "org.slf4j", name = "slf4j-api", version = "1.7.30")
implementation(project(":runelite-api")) implementation(project(":runelite-api"))
testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "4.7.2") testImplementation(group = "com.squareup.okhttp3", name = "mockwebserver", version = "4.8.0")
testImplementation(group = "junit", name = "junit", version = "4.13") testImplementation(group = "junit", name = "junit", version = "4.13")
testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.30") testImplementation(group = "org.slf4j", name = "slf4j-simple", version = "1.7.30")
} }
@@ -66,6 +66,7 @@ public class RuneLiteAPI
private static final String STATICBASE = "https://static.runelite.net"; private static final String STATICBASE = "https://static.runelite.net";
private static final String OPENOSRS_SESSION = "http://session.openosrs.dev"; private static final String OPENOSRS_SESSION = "http://session.openosrs.dev";
private static final String OPENOSRS_XTEA = "http://xtea.openosrs.dev";
private static final String MAVEN_METADATA = "https://repo.runelite.net/net/runelite/runelite-parent/maven-metadata.xml"; private static final String MAVEN_METADATA = "https://repo.runelite.net/net/runelite/runelite-parent/maven-metadata.xml";
private static final Properties properties = new Properties(); private static final Properties properties = new Properties();
@@ -121,6 +122,11 @@ public class RuneLiteAPI
return HttpUrl.parse(OPENOSRS_SESSION); return HttpUrl.parse(OPENOSRS_SESSION);
} }
public static HttpUrl getXteaBase()
{
return HttpUrl.parse(OPENOSRS_XTEA);
}
public static HttpUrl getApiBase() public static HttpUrl getApiBase()
{ {
final String prop = System.getProperty("runelite.http-service.url"); final String prop = System.getProperty("runelite.http-service.url");
@@ -30,24 +30,22 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
@RequiredArgsConstructor
public class AccountClient public class AccountClient
{ {
private static final Logger logger = LoggerFactory.getLogger(AccountClient.class); private final OkHttpClient client;
private UUID uuid; private UUID uuid;
public AccountClient() public void setUuid(UUID uuid)
{
}
public AccountClient(UUID uuid)
{ {
this.uuid = uuid; this.uuid = uuid;
} }
@@ -60,13 +58,13 @@ public class AccountClient
.addQueryParameter("uuid", uuid.toString()) .addQueryParameter("uuid", uuid.toString())
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class); return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OAuthResponse.class);
@@ -84,16 +82,16 @@ public class AccountClient
.addPathSegment("logout") .addPathSegment("logout")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()) .header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
logger.debug("Sent logout request"); log.debug("Sent logout request");
} }
} }
@@ -104,7 +102,7 @@ public class AccountClient
.addPathSegment("session-check") .addPathSegment("session-check")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
return Observable.fromCallable(() -> return Observable.fromCallable(() ->
{ {
@@ -113,13 +111,13 @@ public class AccountClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
catch (IOException ex) catch (IOException ex)
{ {
logger.debug("Unable to verify session", ex); log.debug("Unable to verify session", ex);
return true; // assume it is still valid if the server is unreachable return true; // assume it is still valid if the server is unreachable
} }
}); });
@@ -28,16 +28,19 @@ import com.google.gson.JsonParseException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import lombok.AllArgsConstructor;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@AllArgsConstructor
public class ChatClient public class ChatClient
{ {
private static final RequestBody body = RequestBody.Companion.create(new byte[0], null); private static final RequestBody body = RequestBody.Companion.create(new byte[0], null);
private final OkHttpClient client;
public boolean submitKc(String username, String boss, int kc) throws IOException public boolean submitKc(String username, String boss, int kc) throws IOException
{ {
@@ -49,13 +52,12 @@ public class ChatClient
.addQueryParameter("kc", Integer.toString(kc)) .addQueryParameter("kc", Integer.toString(kc))
.build(); .build();
Request request = new Request.Builder() Request request = new Request.Builder()
.post(RequestBody.create(null, new byte[0])) .post(RequestBody.create(null, new byte[0]))
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -74,7 +76,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -98,7 +100,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -116,7 +118,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -143,7 +145,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -161,7 +163,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -192,7 +194,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -211,7 +213,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -235,7 +237,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -253,7 +255,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -280,7 +282,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -299,7 +301,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -328,7 +330,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
return response.isSuccessful(); return response.isSuccessful();
} }
@@ -346,7 +348,7 @@ public class ChatClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -30,44 +30,41 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@AllArgsConstructor
@Slf4j
public class ConfigClient public class ConfigClient
{ {
private static final Logger logger = LoggerFactory.getLogger(ConfigClient.class);
private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain"); private static final MediaType TEXT_PLAIN = MediaType.parse("text/plain");
private final OkHttpClient client;
private final UUID uuid; private final UUID uuid;
public ConfigClient(UUID uuid)
{
this.uuid = uuid;
}
public Configuration get() throws IOException public Configuration get() throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("config") .addPathSegment("config")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString()) .header(RuneLiteAPI.RUNELITE_AUTH, uuid.toString())
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
InputStream in = response.body().byteStream(); InputStream in = response.body().byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class); return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), Configuration.class);
@@ -87,7 +84,7 @@ public class ConfigClient
.addPathSegment(key) .addPathSegment(key)
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.put(RequestBody.create(TEXT_PLAIN, value)) .put(RequestBody.create(TEXT_PLAIN, value))
@@ -95,12 +92,12 @@ public class ConfigClient
.url(url) .url(url)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
{ {
logger.warn("Unable to synchronize configuration item", e); log.warn("Unable to synchronize configuration item", e);
future.completeExceptionally(e); future.completeExceptionally(e);
} }
@@ -108,7 +105,7 @@ public class ConfigClient
public void onResponse(Call call, Response response) public void onResponse(Call call, Response response)
{ {
response.close(); response.close();
logger.debug("Synchronized configuration value '{}' to '{}'", key, value); log.debug("Synchronized configuration value '{}' to '{}'", key, value);
future.complete(null); future.complete(null);
} }
}); });
@@ -125,7 +122,7 @@ public class ConfigClient
.addPathSegment(key) .addPathSegment(key)
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.delete() .delete()
@@ -133,12 +130,12 @@ public class ConfigClient
.url(url) .url(url)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
{ {
logger.warn("Unable to unset configuration item", e); log.warn("Unable to unset configuration item", e);
future.completeExceptionally(e); future.completeExceptionally(e);
} }
@@ -146,7 +143,7 @@ public class ConfigClient
public void onResponse(Call call, Response response) public void onResponse(Call call, Response response)
{ {
response.close(); response.close();
logger.debug("Unset configuration value '{}'", key); log.debug("Unset configuration value '{}'", key);
future.complete(null); future.complete(null);
} }
}); });
@@ -25,23 +25,26 @@
package net.runelite.http.api.examine; package net.runelite.http.api.examine;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
@RequiredArgsConstructor
public class ExamineClient public class ExamineClient
{ {
private static final Logger logger = LoggerFactory.getLogger(ExamineClient.class);
private static final MediaType TEXT = MediaType.parse("text"); private static final MediaType TEXT = MediaType.parse("text");
private final OkHttpClient client;
public void submitObject(int id, String text) public void submitObject(int id, String text)
{ {
submit("object", id, text); submit("object", id, text);
@@ -65,7 +68,7 @@ public class ExamineClient
.addPathSegment(Integer.toString(id)) .addPathSegment(Integer.toString(id))
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
RequestBody body = RequestBody.Companion.create(text, TEXT); RequestBody body = RequestBody.Companion.create(text, TEXT);
Request request = new Request.Builder() Request request = new Request.Builder()
@@ -73,19 +76,19 @@ public class ExamineClient
.post(body) .post(body)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
{ {
logger.warn("Error submitting examine", e); log.warn("Error submitting examine", e);
} }
@Override @Override
public void onResponse(Call call, Response response) public void onResponse(Call call, Response response)
{ {
response.close(); response.close();
logger.debug("Submitted examine info for {} {}: {}", type, id, text); log.debug("Submitted examine info for {} {}: {}", type, id, text);
} }
}); });
} }
@@ -28,34 +28,27 @@ import com.google.gson.JsonParseException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import javax.inject.Inject; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
@RequiredArgsConstructor
public class FeedClient public class FeedClient
{ {
private static final Logger logger = LoggerFactory.getLogger(FeedClient.class);
private final OkHttpClient client; private final OkHttpClient client;
@Inject
public FeedClient(OkHttpClient client)
{
this.client = client;
}
public FeedResult lookupFeed() throws IOException public FeedResult lookupFeed() throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("feed.js") .addPathSegment("feed.js")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
@@ -65,7 +58,7 @@ public class FeedClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error looking up feed: {}", response); log.debug("Error looking up feed: {}", response);
return null; return null;
} }
@@ -27,6 +27,7 @@ package net.runelite.http.api.ge;
import com.google.gson.Gson; import com.google.gson.Gson;
import java.io.IOException; import java.io.IOException;
import java.util.UUID; import java.util.UUID;
import lombok.RequiredArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
@@ -34,15 +35,19 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@Slf4j @Slf4j
@RequiredArgsConstructor
public class GrandExchangeClient public class GrandExchangeClient
{ {
private static final Gson GSON = RuneLiteAPI.GSON; private static final Gson GSON = RuneLiteAPI.GSON;
private final OkHttpClient client;
@Setter @Setter
private UUID uuid; private UUID uuid;
@Setter @Setter
@@ -70,7 +75,7 @@ public class GrandExchangeClient
.url(url) .url(url)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
@@ -25,9 +25,10 @@
package net.runelite.http.api.hiscore; package net.runelite.http.api.hiscore;
import java.io.IOException; import java.io.IOException;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVFormat;
@@ -35,8 +36,11 @@ import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVRecord; import org.apache.commons.csv.CSVRecord;
@Slf4j @Slf4j
@RequiredArgsConstructor
public class HiscoreClient public class HiscoreClient
{ {
private final OkHttpClient client;
public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException public HiscoreResult lookup(String username, HiscoreEndpoint endpoint) throws IOException
{ {
return lookup(username, endpoint.getHiscoreURL()); return lookup(username, endpoint.getHiscoreURL());
@@ -97,7 +101,7 @@ public class HiscoreClient
String responseStr; String responseStr;
try (Response okresponse = RuneLiteAPI.CLIENT.newCall(okrequest).execute()) try (Response okresponse = client.newCall(okrequest).execute())
{ {
if (!okresponse.isSuccessful()) if (!okresponse.isSuccessful())
{ {
@@ -34,28 +34,21 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.Arrays; import java.util.Arrays;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.inject.Inject;
import javax.naming.directory.SearchResult; import javax.naming.directory.SearchResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
@AllArgsConstructor
public class ItemClient public class ItemClient
{ {
private static final Logger logger = LoggerFactory.getLogger(ItemClient.class);
private final OkHttpClient client; private final OkHttpClient client;
@Inject
public ItemClient(OkHttpClient client)
{
this.client = client;
}
public ItemPrice lookupItemPrice(int itemId) throws IOException public ItemPrice lookupItemPrice(int itemId) throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
@@ -64,7 +57,7 @@ public class ItemClient
.addPathSegment("price") .addPathSegment("price")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
@@ -74,7 +67,7 @@ public class ItemClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error looking up item {}: {}", itemId, response); log.debug("Error looking up item {}: {}", itemId, response);
return null; return null;
} }
@@ -100,7 +93,7 @@ public class ItemClient
HttpUrl url = urlBuilder.build(); HttpUrl url = urlBuilder.build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
@@ -110,7 +103,7 @@ public class ItemClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error looking up items {}: {}", Arrays.toString(itemIds), response); log.debug("Error looking up items {}: {}", Arrays.toString(itemIds), response);
return null; return null;
} }
@@ -131,7 +124,7 @@ public class ItemClient
.addPathSegment("icon") .addPathSegment("icon")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
@@ -143,7 +136,7 @@ public class ItemClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error grabbing icon {}: {}", itemId, response); log.debug("Error grabbing icon {}: {}", itemId, response);
return Observable.just(null); return Observable.just(null);
} }
@@ -164,7 +157,7 @@ public class ItemClient
.addQueryParameter("query", itemName) .addQueryParameter("query", itemName)
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
return Observable.defer(() -> return Observable.defer(() ->
{ {
@@ -176,7 +169,7 @@ public class ItemClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error looking up item {}: {}", itemName, response); log.debug("Error looking up item {}: {}", itemName, response);
return Observable.just(null); return Observable.just(null);
} }
@@ -198,7 +191,7 @@ public class ItemClient
HttpUrl url = urlBuilder.build(); HttpUrl url = urlBuilder.build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
return Observable.fromCallable(() -> return Observable.fromCallable(() ->
{ {
@@ -235,7 +228,7 @@ public class ItemClient
.addPathSegment("stats.ids.min.json") .addPathSegment("stats.ids.min.json")
.build(); .build();
logger.debug("Built URI {}", url); log.debug("Built URI {}", url);
return Observable.fromCallable(() -> return Observable.fromCallable(() ->
{ {
Request request = new Request.Builder() Request request = new Request.Builder()
@@ -24,6 +24,7 @@
*/ */
package net.runelite.http.api.item; package net.runelite.http.api.item;
import com.google.gson.annotations.SerializedName;
import lombok.Builder; import lombok.Builder;
import lombok.Value; import lombok.Value;
@@ -33,6 +34,9 @@ public class ItemEquipmentStats
{ {
private int slot; private int slot;
@SerializedName("is2h")
private boolean isTwoHanded;
private int astab; private int astab;
private int aslash; private int aslash;
private int acrush; private int acrush;
@@ -51,4 +55,3 @@ public class ItemEquipmentStats
private int prayer; private int prayer;
private int aspeed; private int aspeed;
} }
@@ -41,6 +41,7 @@ public class LootRecord
@Getter @Getter
private String username; private String username;
private LootRecordType type; private LootRecordType type;
private Object metadata;
private Collection<GameItem> drops; private Collection<GameItem> drops;
private Instant time; private Instant time;
@@ -41,6 +41,7 @@ import static net.runelite.http.api.RuneLiteAPI.JSON;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import okhttp3.Response; import okhttp3.Response;
@@ -51,6 +52,7 @@ public class LootTrackerClient
{ {
private static final Gson GSON = RuneLiteAPI.GSON; private static final Gson GSON = RuneLiteAPI.GSON;
private final OkHttpClient client;
private final UUID uuid; private final UUID uuid;
public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords) public CompletableFuture<Void> submit(Collection<LootRecord> lootRecords)
@@ -68,7 +70,7 @@ public class LootTrackerClient
.url(url) .url(url)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
@@ -100,7 +102,7 @@ public class LootTrackerClient
.url(url) .url(url)
.build(); .build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -133,7 +135,7 @@ public class LootTrackerClient
.url(builder.build()) .url(builder.build())
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
@@ -29,15 +29,20 @@ import io.reactivex.rxjava3.core.Observable;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
@Slf4j @Slf4j
@AllArgsConstructor
public class OSBGrandExchangeClient public class OSBGrandExchangeClient
{ {
private final OkHttpClient client;
public Observable<OSBGrandExchangeResult> lookupItem(int itemId) public Observable<OSBGrandExchangeResult> lookupItem(int itemId)
{ {
final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() final HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
@@ -50,11 +55,11 @@ public class OSBGrandExchangeClient
return Observable.defer(() -> return Observable.defer(() ->
{ {
Request request = new Request.Builder() final Request request = new Request.Builder()
.url(url) .url(url)
.build(); .build();
try (final Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) try (final Response response = client.newCall(request).execute())
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
@@ -64,9 +69,9 @@ public class OSBGrandExchangeClient
final InputStream in = response.body().byteStream(); final InputStream in = response.body().byteStream();
return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OSBGrandExchangeResult.class)); return Observable.just(RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), OSBGrandExchangeResult.class));
} }
catch (JsonParseException e) catch (JsonParseException ex)
{ {
return Observable.error(e); return Observable.error(ex);
} }
}); });
} }
@@ -29,35 +29,28 @@ import com.google.gson.JsonParseException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import javax.inject.Inject; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.CacheControl; import okhttp3.CacheControl;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient; import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
@RequiredArgsConstructor
public class WorldClient public class WorldClient
{ {
private static final Logger logger = LoggerFactory.getLogger(WorldClient.class);
private final OkHttpClient client; private final OkHttpClient client;
@Inject
public WorldClient(OkHttpClient client)
{
this.client = client;
}
public WorldResult lookupWorlds() throws IOException public WorldResult lookupWorlds() throws IOException
{ {
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder() HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("worlds.js") .addPathSegment("worlds.js")
.build(); .build();
logger.debug("Built URI: {}", url); log.debug("Built URI: {}", url);
Request request = new Request.Builder() Request request = new Request.Builder()
.url(url) .url(url)
@@ -68,7 +61,7 @@ public class WorldClient
{ {
if (!response.isSuccessful()) if (!response.isSuccessful())
{ {
logger.debug("Error looking up worlds: {}", response); log.debug("Error looking up worlds: {}", response);
throw new IOException("unsuccessful response looking up worlds"); throw new IOException("unsuccessful response looking up worlds");
} }
@@ -25,18 +25,24 @@
package net.runelite.http.api.xp; package net.runelite.http.api.xp;
import java.io.IOException; import java.io.IOException;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI; import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call; import okhttp3.Call;
import okhttp3.Callback; import okhttp3.Callback;
import okhttp3.HttpUrl; import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request; import okhttp3.Request;
import okhttp3.Response; import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Slf4j
public class XpClient public class XpClient
{ {
private static final Logger logger = LoggerFactory.getLogger(XpClient.class); private final OkHttpClient client;
public XpClient(OkHttpClient client)
{
this.client = client;
}
public void update(String username) public void update(String username)
{ {
@@ -50,19 +56,19 @@ public class XpClient
.url(url) .url(url)
.build(); .build();
RuneLiteAPI.CLIENT.newCall(request).enqueue(new Callback() client.newCall(request).enqueue(new Callback()
{ {
@Override @Override
public void onFailure(Call call, IOException e) public void onFailure(Call call, IOException e)
{ {
logger.warn("Error submitting xp track", e); log.warn("Error submitting xp track", e);
} }
@Override @Override
public void onResponse(Call call, Response response) public void onResponse(Call call, Response response)
{ {
response.close(); response.close();
logger.debug("Submitted xp track for {}", username); log.debug("Submitted xp track for {}", username);
} }
}); });
} }
@@ -0,0 +1,115 @@
/*
* Copyright (c) 2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.http.api.xtea;
import com.google.gson.JsonParseException;
import com.google.gson.reflect.TypeToken;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.runelite.http.api.RuneLiteAPI;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
@Slf4j
@AllArgsConstructor
public class XteaClient
{
private final OkHttpClient client;
public void submit(int region, int[] keys)
{
HttpUrl url = RuneLiteAPI.getXteaBase().newBuilder()
.addPathSegment("submit")
.addQueryParameter("region", String.valueOf(region))
.addQueryParameter("key1", String.valueOf(keys[0]))
.addQueryParameter("key2", String.valueOf(keys[1]))
.addQueryParameter("key3", String.valueOf(keys[2]))
.addQueryParameter("key4", String.valueOf(keys[3]))
.build();
log.debug("Built URI: {}", url);
Request request = new Request.Builder()
.url(url)
.build();
client.newCall(request).enqueue(new Callback()
{
@Override
public void onFailure(Call call, IOException e)
{
log.warn("unable to submit xtea keys", e);
}
@Override
public void onResponse(Call call, Response response)
{
try
{
if (!response.isSuccessful())
{
log.debug("unsuccessful xtea response");
}
}
finally
{
response.close();
}
}
});
}
public HashMap<Integer, Integer[]> get() throws IOException
{
HttpUrl url = RuneLiteAPI.getXteaBase().newBuilder()
.addPathSegment("get")
.build();
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = client.newCall(request).execute())
{
InputStream in = response.body().byteStream();
// CHECKSTYLE:OFF
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in), new TypeToken<HashMap<Integer, Integer[]>>() {}.getType());
// CHECKSTYLE:ON
}
catch (JsonParseException ex)
{
throw new IOException(ex);
}
}
}
+1 -8
View File
@@ -62,14 +62,10 @@ injector {
vanilla.set(vanillaDep.singleFile) vanilla.set(vanillaDep.singleFile)
} }
artifacts {
runtimeElements(tasks.inject.get().output)
}
// keep the sourcesets etc but remove useless tasks // keep the sourcesets etc but remove useless tasks
tasks { tasks {
inject { inject {
dependsOn(configurations["combined"]) dependsOn(combined)
} }
classes { classes {
enabled = false enabled = false
@@ -86,7 +82,4 @@ tasks {
processResources { processResources {
enabled = false enabled = false
} }
assemble {
finalizedBy("inject")
}
} }
@@ -36,7 +36,7 @@ import java.lang.annotation.Target;
}) })
public @interface ObfuscatedSignature public @interface ObfuscatedSignature
{ {
String signature(); String descriptor();
String garbageValue() default ""; // valid garbage value for last parameter. can't be an Object because Java. String garbageValue() default ""; // valid garbage value for last parameter. can't be an Object because Java.
} }
@@ -292,6 +292,7 @@ public final class AnimationID
public static final int ROCKSLUG_DEATH = 1568; public static final int ROCKSLUG_DEATH = 1568;
public static final int ZYGOMITE_DEATH = 3327; public static final int ZYGOMITE_DEATH = 3327;
public static final int IMP_DEATH = 172; public static final int IMP_DEATH = 172;
public static final int NIGHTMARE_DEATH = 8612;
// POH Animations // POH Animations
public static final int INCENSE_BURNER = 3687; public static final int INCENSE_BURNER = 3687;
@@ -407,6 +407,11 @@ public interface Client extends GameShell
*/ */
IndexDataBase getIndexScripts(); IndexDataBase getIndexScripts();
/**
* Gets the config index.
*/
IndexDataBase getIndexConfig();
/** /**
* Returns the x-axis base coordinate. * Returns the x-axis base coordinate.
* <p> * <p>
@@ -488,6 +493,7 @@ public interface Client extends GameShell
* @param widget the widget info * @param widget the widget info
* @return the widget * @return the widget
*/ */
@Nullable
Widget getWidget(WidgetInfo widget); Widget getWidget(WidgetInfo widget);
/** /**
@@ -500,6 +506,7 @@ public interface Client extends GameShell
* @param childId the child widget ID * @param childId the child widget ID
* @return the widget corresponding to the group and child pair * @return the widget corresponding to the group and child pair
*/ */
@Nullable
Widget getWidget(int groupId, int childId); Widget getWidget(int groupId, int childId);
/** /**
@@ -809,6 +816,12 @@ public interface Client extends GameShell
*/ */
void setVarbitValue(int[] varps, int varbit, int value); void setVarbitValue(int[] varps, int varbit, int value);
/**
* Gets the varbit composition for a given varbit id
*/
@Nullable
VarbitDefinition getVarbitDefinition(int id);
/** /**
* Gets the widget flags table. * Gets the widget flags table.
* *
@@ -1870,6 +1883,10 @@ public interface Client extends GameShell
boolean isSpellSelected(); boolean isSpellSelected();
String getSelectedSpellActionName();
int getSelectedSpellFlags();
/** /**
* Set whether or not player attack options will be hidden for friends * Set whether or not player attack options will be hidden for friends
*/ */
@@ -1924,8 +1941,12 @@ public interface Client extends GameShell
void setSelectedItemID(int id); void setSelectedItemID(int id);
int getSelectedItemWidget();
void setSelectedItemWidget(int widgetID); void setSelectedItemWidget(int widgetID);
int getSelectedItemSlot();
void setSelectedItemSlot(int idx); void setSelectedItemSlot(int idx);
int getSelectedSpellWidget(); int getSelectedSpellWidget();
@@ -2050,4 +2071,12 @@ public interface Client extends GameShell
* @see KeyCode * @see KeyCode
*/ */
boolean isKeyPressed(int keycode); boolean isKeyPressed(int keycode);
int getFollowerIndex();
int isItemSelected();
String getSelectedItemName();
Widget getMessageContinueWidget();
} }
@@ -33,6 +33,7 @@ public final class EnumID
{ {
public static final int MUSIC_TRACK_NAMES = 812; public static final int MUSIC_TRACK_NAMES = 812;
public static final int MUSIC_TRACK_IDS = 819; public static final int MUSIC_TRACK_IDS = 819;
public static final int XPDROP_COLORS = 1169;
/** /**
* Translates spellbook varbit into enum ID * Translates spellbook varbit into enum ID
@@ -1,3 +1,27 @@
/*
* Copyright (c) 2020, Lucas <https://github.com/Lucwousin>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api; package net.runelite.api;
/** /**
@@ -9,4 +33,9 @@ public interface IndexDataBase
* Returns true if any cache overlay in this index is outdated due to hash mismatch * Returns true if any cache overlay in this index is outdated due to hash mismatch
*/ */
boolean isOverlayOutdated(); boolean isOverlayOutdated();
/**
* Get the child file ids for a given group
*/
int[] getFileIds(int group);
} }
@@ -33,6 +33,14 @@ public enum InventoryID
* Reward from fishing trawler * Reward from fishing trawler
*/ */
FISHING_TRAWLER_REWARD(0), FISHING_TRAWLER_REWARD(0),
/**
* The trade inventory.
*/
TRADE(90),
/**
* The other trade inventory.
*/
TRADEOTHER(90 | 0x8000),
/** /**
* Standard player inventory. * Standard player inventory.
*/ */
@@ -67,4 +67,10 @@ public interface ItemContainer extends Node
* @see ItemID * @see ItemID
*/ */
int count(int itemId); int count(int itemId);
/**
* Get the number of items in this item container. May include empty slots.
* @return
*/
int size();
} }
@@ -75,6 +75,14 @@ public interface ItemDefinition
*/ */
int getPrice(); int getPrice();
/**
* Get the high alchemy price for this item. All items have a high alchemy price,
* but not all items can be alched.
*
* @return the high alch price
*/
int getHaPrice();
/** /**
* Checks whether the item is members only. * Checks whether the item is members only.
* *
@@ -103,6 +111,8 @@ public interface ItemDefinition
*/ */
String[] getInventoryActions(); String[] getInventoryActions();
String[] getGroundActions();
/** /**
* Gets the menu action index of the shift-click action. * Gets the menu action index of the shift-click action.
* *
@@ -8159,7 +8159,7 @@ public final class ItemID
public static final int HUMAN_EYE = 12843; public static final int HUMAN_EYE = 12843;
public static final int VOICE_POTION = 12844; public static final int VOICE_POTION = 12844;
public static final int GRIM_REAPER_HOOD = 12845; public static final int GRIM_REAPER_HOOD = 12845;
public static final int BOUNTY_TELEPORT_SCROLL = 12846; public static final int TARGET_TELEPORT_SCROLL = 12846;
public static final int GRANITE_MAUL_12848 = 12848; public static final int GRANITE_MAUL_12848 = 12848;
public static final int GRANITE_CLAMP = 12849; public static final int GRANITE_CLAMP = 12849;
public static final int AMULET_OF_THE_DAMNED_FULL = 12851; public static final int AMULET_OF_THE_DAMNED_FULL = 12851;
@@ -11321,7 +11321,7 @@ public final class ItemID
public static final int BIRTHDAY_CAKE_24331 = 24331; public static final int BIRTHDAY_CAKE_24331 = 24331;
public static final int BIRTHDAY_CAKE_24332 = 24332; public static final int BIRTHDAY_CAKE_24332 = 24332;
public static final int DAGONHAI_ROBES_SET = 24333; public static final int DAGONHAI_ROBES_SET = 24333;
public static final int BOUNTY_TARGET_TELEPORT = 24336; public static final int TARGET_TELEPORT = 24336;
public static final int BOUNTY_HUNTER_HAT_TIER_1 = 24338; public static final int BOUNTY_HUNTER_HAT_TIER_1 = 24338;
public static final int BOUNTY_HUNTER_HAT_TIER_2 = 24340; public static final int BOUNTY_HUNTER_HAT_TIER_2 = 24340;
public static final int BOUNTY_HUNTER_HAT_TIER_3 = 24342; public static final int BOUNTY_HUNTER_HAT_TIER_3 = 24342;
@@ -11578,5 +11578,20 @@ public final class ItemID
public static final int ZIGGY = 24849; public static final int ZIGGY = 24849;
public static final int SOFT_CLAY_PACK_24851 = 24851; public static final int SOFT_CLAY_PACK_24851 = 24851;
public static final int BAG_FULL_OF_GEMS_24853 = 24853; public static final int BAG_FULL_OF_GEMS_24853 = 24853;
public static final int MYTHICAL_MAX_CAPE = 24855;
public static final int MYTHICAL_MAX_HOOD = 24857;
public static final int WARRIOR_PATH_STARTER_KIT = 24859;
public static final int WIZARD_PATH_STARTER_KIT = 24860;
public static final int RANGER_PATH_STARTER_KIT = 24861;
public static final int KARAMJAN_MONKEY = 24862;
public static final int ZOMBIE_MONKEY = 24863;
public static final int MANIACAL_MONKEY = 24864;
public static final int SKELETON_MONKEY = 24865;
public static final int KRUK_JR = 24866;
public static final int PRINCELY_MONKEY = 24867;
public static final int GOLDEN_ARMADYL_SPECIAL_ATTACK = 24868;
public static final int GOLDEN_BANDOS_SPECIAL_ATTACK = 24869;
public static final int GOLDEN_SARADOMIN_SPECIAL_ATTACK = 24870;
public static final int GOLDEN_ZAMORAK_SPECIAL_ATTACK = 24871;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -29,5 +29,87 @@ package net.runelite.api;
*/ */
public final class KeyCode public final class KeyCode
{ {
public static final int KC_F1 = 1;
public static final int KC_F2 = 2;
public static final int KC_F3 = 3;
public static final int KC_F4 = 4;
public static final int KC_F5 = 5;
public static final int KC_F6 = 6;
public static final int KC_F7 = 7;
public static final int KC_F8 = 8;
public static final int KC_F9 = 9;
public static final int KC_F10 = 10;
public static final int KC_F11 = 11;
public static final int KC_F12 = 12;
public static final int KC_ESCAPE = 13;
public static final int KC_1 = 16;
public static final int KC_2 = 17;
public static final int KC_3 = 18;
public static final int KC_4 = 19;
public static final int KC_5 = 20;
public static final int KC_6 = 21;
public static final int KC_7 = 22;
public static final int KC_8 = 23;
public static final int KC_9 = 24;
public static final int KC_0 = 25;
public static final int KC_MINUS = 26;
public static final int KC_EQUALS = 27;
public static final int KC_TILDE = 28;
public static final int KC_Q = 32;
public static final int KC_W = 33;
public static final int KC_E = 34;
public static final int KC_R = 35;
public static final int KC_T = 36;
public static final int KC_Y = 37;
public static final int KC_U = 38;
public static final int KC_I = 39;
public static final int KC_O = 40;
public static final int KC_P = 41;
public static final int KC_OPEN_BRACKET = 42;
public static final int KC_CLOSE_BRACKET = 43;
public static final int KC_A = 48;
public static final int KC_S = 49;
public static final int KC_D = 50;
public static final int KC_F = 51;
public static final int KC_G = 52;
public static final int KC_H = 53;
public static final int KC_J = 54;
public static final int KC_K = 55;
public static final int KC_L = 56;
public static final int KC_SEMICOLON = 57;
public static final int KC_QUOTE = 58;
public static final int KC_Z = 64;
public static final int KC_X = 65;
public static final int KC_C = 66;
public static final int KC_V = 67;
public static final int KC_B = 68;
public static final int KC_N = 69;
public static final int KC_M = 70;
public static final int KC_COMMA = 71;
public static final int KC_PERIOD = 72;
public static final int KC_FORWARD_SLASH = 73;
public static final int KC_BACK_SLASH = 74;
public static final int KC_TAB = 80;
public static final int KC_SHIFT = 81; public static final int KC_SHIFT = 81;
public static final int KC_CONTROL = 82;
public static final int KC_SPACE = 83;
public static final int KC_ENTER = 84;
public static final int KC_BACKSPACE = 85;
public static final int KC_ALT = 86;
public static final int KC_LEFT = 96;
public static final int KC_RIGHT = 97;
public static final int KC_UP = 98;
public static final int KC_DOWN = 99;
public static final int KC_INSERT = 100;
public static final int KC_DELETE = 101;
public static final int KC_HOME = 102;
public static final int KC_END = 103;
public static final int KC_PAGE_UP = 104;
public static final int KC_PAGE_DOWN = 105;
} }
@@ -8758,5 +8758,38 @@ public final class NpcID
public static final int GRAVE = 9856; public static final int GRAVE = 9856;
public static final int GRAVE_9857 = 9857; public static final int GRAVE_9857 = 9857;
public static final int SQUIRE_10368 = 10368; public static final int SQUIRE_10368 = 10368;
public static final int BOBAWU = 10369;
public static final int MARTEN = 10370;
public static final int WIZARD_10371 = 10371;
public static final int WIZARD_10372 = 10372;
public static final int WIZARD_10373 = 10373;
public static final int HILL_GIANT_10374 = 10374;
public static final int HILL_GIANT_10375 = 10375;
public static final int HILL_GIANT_10376 = 10376;
public static final int FEROX = 10377;
public static final int SIGISMUND = 10378;
public static final int ZAMORAKIAN_ACOLYTE = 10379;
public static final int ZAMORAKIAN_ACOLYTE_10380 = 10380;
public static final int ZAMORAKIAN_ACOLYTE_10381 = 10381;
public static final int REFUGEE = 10382;
public static final int REFUGEE_10383 = 10383;
public static final int REFUGEE_10384 = 10384;
public static final int REFUGEE_10385 = 10385;
public static final int PHABELLE_BILE = 10386;
public static final int DERSE_VENATOR = 10387;
public static final int ANDROS_MAI = 10388;
public static final int BANKER_10389 = 10389;
public static final int MERCENARY_10390 = 10390;
public static final int FINANCIAL_WIZARD_10391 = 10391;
public static final int CAMARST = 10392;
public static final int WARRIOR_OF_MURAHS = 10393;
public static final int WARRIOR_OF_MURAHS_10394 = 10394;
public static final int WARRIOR_OF_MURAHS_10395 = 10395;
public static final int SPIKED_TUROTH = 10397;
public static final int SHADOW_WYRM = 10398;
public static final int SHADOW_WYRM_10399 = 10399;
public static final int GUARDIAN_DRAKE = 10400;
public static final int GUARDIAN_DRAKE_10401 = 10401;
public static final int COLOSSAL_HYDRA = 10402;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -13068,5 +13068,7 @@ public final class NullItemID
public static final int NULL_24850 = 24850; public static final int NULL_24850 = 24850;
public static final int NULL_24852 = 24852; public static final int NULL_24852 = 24852;
public static final int NULL_24854 = 24854; public static final int NULL_24854 = 24854;
public static final int NULL_24856 = 24856;
public static final int NULL_24858 = 24858;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -1592,5 +1592,6 @@ public final class NullNpcID
public static final int NULL_10365 = 10365; public static final int NULL_10365 = 10365;
public static final int NULL_10366 = 10366; public static final int NULL_10366 = 10366;
public static final int NULL_10367 = 10367; public static final int NULL_10367 = 10367;
public static final int NULL_10396 = 10396;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -18031,22 +18031,8 @@ public final class NullObjectID
public static final int NULL_37430 = 37430; public static final int NULL_37430 = 37430;
public static final int NULL_37432 = 37432; public static final int NULL_37432 = 37432;
public static final int NULL_37433 = 37433; public static final int NULL_37433 = 37433;
public static final int NULL_37436 = 37436;
public static final int NULL_37437 = 37437;
public static final int NULL_37438 = 37438;
public static final int NULL_37439 = 37439; public static final int NULL_37439 = 37439;
public static final int NULL_37440 = 37440; public static final int NULL_37440 = 37440;
public static final int NULL_37446 = 37446;
public static final int NULL_37447 = 37447;
public static final int NULL_37448 = 37448;
public static final int NULL_37449 = 37449;
public static final int NULL_37451 = 37451;
public static final int NULL_37452 = 37452;
public static final int NULL_37453 = 37453;
public static final int NULL_37454 = 37454;
public static final int NULL_37455 = 37455;
public static final int NULL_37456 = 37456;
public static final int NULL_37457 = 37457;
public static final int NULL_37467 = 37467; public static final int NULL_37467 = 37467;
public static final int NULL_37468 = 37468; public static final int NULL_37468 = 37468;
public static final int NULL_37469 = 37469; public static final int NULL_37469 = 37469;
@@ -19517,5 +19503,81 @@ public final class NullObjectID
public static final int NULL_39616 = 39616; public static final int NULL_39616 = 39616;
public static final int NULL_39618 = 39618; public static final int NULL_39618 = 39618;
public static final int NULL_39619 = 39619; public static final int NULL_39619 = 39619;
public static final int NULL_39622 = 39622;
public static final int NULL_39623 = 39623;
public static final int NULL_39624 = 39624;
public static final int NULL_39625 = 39625;
public static final int NULL_39626 = 39626;
public static final int NULL_39627 = 39627;
public static final int NULL_39628 = 39628;
public static final int NULL_39629 = 39629;
public static final int NULL_39630 = 39630;
public static final int NULL_39631 = 39631;
public static final int NULL_39632 = 39632;
public static final int NULL_39633 = 39633;
public static final int NULL_39634 = 39634;
public static final int NULL_39635 = 39635;
public static final int NULL_39636 = 39636;
public static final int NULL_39638 = 39638;
public static final int NULL_39649 = 39649;
public static final int NULL_39654 = 39654;
public static final int NULL_39655 = 39655;
public static final int NULL_39656 = 39656;
public static final int NULL_39661 = 39661;
public static final int NULL_39662 = 39662;
public static final int NULL_39663 = 39663;
public static final int NULL_39664 = 39664;
public static final int NULL_39665 = 39665;
public static final int NULL_39666 = 39666;
public static final int NULL_39667 = 39667;
public static final int NULL_39668 = 39668;
public static final int NULL_39669 = 39669;
public static final int NULL_39670 = 39670;
public static final int NULL_39671 = 39671;
public static final int NULL_39672 = 39672;
public static final int NULL_39673 = 39673;
public static final int NULL_39683 = 39683;
public static final int NULL_39684 = 39684;
public static final int NULL_39685 = 39685;
public static final int NULL_39686 = 39686;
public static final int NULL_39694 = 39694;
public static final int NULL_39701 = 39701;
public static final int NULL_39702 = 39702;
public static final int NULL_39703 = 39703;
public static final int NULL_39704 = 39704;
public static final int NULL_39705 = 39705;
public static final int NULL_39706 = 39706;
public static final int NULL_39707 = 39707;
public static final int NULL_39708 = 39708;
public static final int NULL_39709 = 39709;
public static final int NULL_39710 = 39710;
public static final int NULL_39711 = 39711;
public static final int NULL_39712 = 39712;
public static final int NULL_39713 = 39713;
public static final int NULL_39714 = 39714;
public static final int NULL_39715 = 39715;
public static final int NULL_39717 = 39717;
public static final int NULL_39722 = 39722;
public static final int NULL_39725 = 39725;
public static final int NULL_39726 = 39726;
public static final int NULL_39727 = 39727;
public static final int NULL_39728 = 39728;
public static final int NULL_39729 = 39729;
public static final int NULL_39730 = 39730;
public static final int NULL_39731 = 39731;
public static final int NULL_39732 = 39732;
public static final int NULL_39733 = 39733;
public static final int NULL_39734 = 39734;
public static final int NULL_39735 = 39735;
public static final int NULL_39736 = 39736;
public static final int NULL_39737 = 39737;
public static final int NULL_39738 = 39738;
public static final int NULL_39739 = 39739;
public static final int NULL_39742 = 39742;
public static final int NULL_39743 = 39743;
public static final int NULL_39744 = 39744;
public static final int NULL_39745 = 39745;
public static final int NULL_39746 = 39746;
public static final int NULL_39747 = 39747;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -8061,7 +8061,7 @@ public final class ObjectID
public static final int STONE_BLOCK_14203 = 14203; public static final int STONE_BLOCK_14203 = 14203;
public static final int STONE_BLOCK_14204 = 14204; public static final int STONE_BLOCK_14204 = 14204;
public static final int STONE_BLOCK_14205 = 14205; public static final int STONE_BLOCK_14205 = 14205;
public static final int FINAL_OWNAGE_ELITE_STATUE = 14209; public static final int HERBS_14209 = 14209;
public static final int WALL_14212 = 14212; public static final int WALL_14212 = 14212;
public static final int WALL_14213 = 14213; public static final int WALL_14213 = 14213;
public static final int WALL_14216 = 14216; public static final int WALL_14216 = 14216;
@@ -14137,11 +14137,11 @@ public final class ObjectID
public static final int HUTCH_26822 = 26822; public static final int HUTCH_26822 = 26822;
public static final int CAGES_26823 = 26823; public static final int CAGES_26823 = 26823;
public static final int CAGE_26824 = 26824; public static final int CAGE_26824 = 26824;
public static final int ANCIENT_FURY_STATUE = 26825; public static final int HERBS_26825 = 26825;
public static final int FATALITY_STATUE = 26826; public static final int HERBS_26826 = 26826;
public static final int HEXIS_STATUE = 26827; public static final int HERBS_26827 = 26827;
public static final int REIGN_OF_TERROR_STATUE = 26828; public static final int HERBS_26828 = 26828;
public static final int STUD_UNIT_STATUE = 26829; public static final int HERBS_26829 = 26829;
public static final int CONSECRATED_HOUSE = 26830; public static final int CONSECRATED_HOUSE = 26830;
public static final int DESECRATED_HOUSE = 26831; public static final int DESECRATED_HOUSE = 26831;
public static final int NATURE_HOUSE = 26832; public static final int NATURE_HOUSE = 26832;
@@ -19396,7 +19396,6 @@ public final class ObjectID
public static final int DECORATIVE_WINDOW_37442 = 37442; public static final int DECORATIVE_WINDOW_37442 = 37442;
public static final int STAINEDGLASS_WINDOW_37443 = 37443; public static final int STAINEDGLASS_WINDOW_37443 = 37443;
public static final int LOG_PILE_37444 = 37444; public static final int LOG_PILE_37444 = 37444;
public static final int HOTSPOT_MARKER = 37445;
public static final int DECORATIVE_WINDOW_37450 = 37450; public static final int DECORATIVE_WINDOW_37450 = 37450;
public static final int STAINEDGLASS_WINDOW_37458 = 37458; public static final int STAINEDGLASS_WINDOW_37458 = 37458;
public static final int DECORATIVE_WINDOW_37459 = 37459; public static final int DECORATIVE_WINDOW_37459 = 37459;
@@ -20089,6 +20088,191 @@ public final class ObjectID
public static final int COFFIN_39608 = 39608; public static final int COFFIN_39608 = 39608;
public static final int STAIRS_39609 = 39609; public static final int STAIRS_39609 = 39609;
public static final int CRYPT = 39617; public static final int CRYPT = 39617;
public static final int COFFIN_39620 = 39620; public static final int RUSTED_ANVIL = 39620;
public static final int MOUNTED_MAX_CAPE_39621 = 39621;
public static final int DEATHS_DOMAIN_39637 = 39637;
public static final int CASUAL = 39639;
public static final int COMPETITIVE = 39640;
public static final int HIGH_STAKES = 39641;
public static final int ALTAR_39642 = 39642;
public static final int STAIRS_39643 = 39643;
public static final int LADDER_39644 = 39644;
public static final int LADDER_39645 = 39645;
public static final int LIFT_PLATFORM_39646 = 39646;
public static final int STAIRS_39647 = 39647;
public static final int OPENING_39648 = 39648;
public static final int STAIRS_39650 = 39650;
public static final int POOL_OF_REFRESHMENT = 39651;
public static final int BARRIER_39652 = 39652;
public static final int BARRIER_39653 = 39653;
public static final int GATE_39657 = 39657;
public static final int GATE_39658 = 39658;
public static final int GATE_39659 = 39659;
public static final int GATE_39660 = 39660;
public static final int STATUE_39674 = 39674;
public static final int CORPSE_39675 = 39675;
public static final int TREE_39676 = 39676;
public static final int TREE_39677 = 39677;
public static final int TREE_39678 = 39678;
public static final int TREE_39679 = 39679;
public static final int BUSH_39680 = 39680;
public static final int BUSH_39681 = 39681;
public static final int BUSH_39682 = 39682;
public static final int BENCH_39687 = 39687;
public static final int CAMPING_EQUIPMENT_39688 = 39688;
public static final int TWISTED_CRATE = 39689;
public static final int BARREL_39690 = 39690;
public static final int STONE_PILE_39691 = 39691;
public static final int STONE_PILE_39692 = 39692;
public static final int WOOD_39693 = 39693;
public static final int SACKS_39695 = 39695;
public static final int SACKS_39696 = 39696;
public static final int FLOWERS_39697 = 39697;
public static final int FLOWERS_39698 = 39698;
public static final int FLOWERS_39699 = 39699;
public static final int FLOWERS_39700 = 39700;
public static final int TABLE_39716 = 39716;
public static final int STOOL_39718 = 39718;
public static final int HOLE_39719 = 39719;
public static final int WELL_39720 = 39720;
public static final int CAVE_39721 = 39721;
public static final int ALTAR_39723 = 39723;
public static final int GIANT_ANVIL_39724 = 39724;
public static final int STONE_PILE_39740 = 39740;
public static final int STONE_PILE_39741 = 39741;
public static final int HERBS_39748 = 39748;
public static final int HERBS_39749 = 39749;
public static final int HERBS_39750 = 39750;
public static final int HERBS_39751 = 39751;
public static final int HERBS_39752 = 39752;
public static final int HERBS_39753 = 39753;
public static final int HERBS_39754 = 39754;
public static final int HERBS_39755 = 39755;
public static final int HERBS_39756 = 39756;
public static final int HERBS_39757 = 39757;
public static final int HERBS_39758 = 39758;
public static final int HERBS_39759 = 39759;
public static final int HERBS_39760 = 39760;
public static final int HERBS_39761 = 39761;
public static final int HERBS_39762 = 39762;
public static final int HERBS_39763 = 39763;
public static final int HERBS_39764 = 39764;
public static final int HERBS_39765 = 39765;
public static final int HERBS_39766 = 39766;
public static final int HERBS_39767 = 39767;
public static final int HERBS_39768 = 39768;
public static final int HERBS_39769 = 39769;
public static final int HERBS_39770 = 39770;
public static final int HERBS_39771 = 39771;
public static final int HERBS_39772 = 39772;
public static final int HERBS_39773 = 39773;
public static final int HERBS_39774 = 39774;
public static final int HERBS_39775 = 39775;
public static final int HERBS_39776 = 39776;
public static final int HERBS_39777 = 39777;
public static final int HERBS_39778 = 39778;
public static final int HERBS_39779 = 39779;
public static final int HERBS_39780 = 39780;
public static final int HERBS_39781 = 39781;
public static final int HERBS_39782 = 39782;
public static final int HERBS_39783 = 39783;
public static final int HERBS_39784 = 39784;
public static final int HERBS_39785 = 39785;
public static final int HERBS_39786 = 39786;
public static final int HERBS_39787 = 39787;
public static final int HERBS_39788 = 39788;
public static final int HERBS_39789 = 39789;
public static final int HERBS_39790 = 39790;
public static final int HERBS_39791 = 39791;
public static final int HERBS_39792 = 39792;
public static final int HERBS_39793 = 39793;
public static final int HERBS_39794 = 39794;
public static final int HERBS_39795 = 39795;
public static final int HERBS_39796 = 39796;
public static final int HERBS_39797 = 39797;
public static final int HERBS_39798 = 39798;
public static final int HERBS_39799 = 39799;
public static final int HERBS_39800 = 39800;
public static final int HERBS_39801 = 39801;
public static final int HERBS_39802 = 39802;
public static final int HERBS_39803 = 39803;
public static final int HERBS_39804 = 39804;
public static final int HERBS_39805 = 39805;
public static final int HERBS_39806 = 39806;
public static final int HERBS_39807 = 39807;
public static final int HERBS_39808 = 39808;
public static final int HERBS_39809 = 39809;
public static final int HERBS_39810 = 39810;
public static final int HERBS_39811 = 39811;
public static final int HERB_PATCH_39812 = 39812;
public static final int HERB_PATCH_39813 = 39813;
public static final int HERBS_39814 = 39814;
public static final int HERBS_39815 = 39815;
public static final int HERBS_39816 = 39816;
public static final int HERB_PATCH_39817 = 39817;
public static final int HERB_PATCH_39818 = 39818;
public static final int HERBS_39819 = 39819;
public static final int HERBS_39820 = 39820;
public static final int HERBS_39821 = 39821;
public static final int HERB_PATCH_39822 = 39822;
public static final int HERB_PATCH_39823 = 39823;
public static final int HERBS_39824 = 39824;
public static final int HERBS_39825 = 39825;
public static final int HERBS_39826 = 39826;
public static final int HERB_PATCH_39827 = 39827;
public static final int HERB_PATCH_39828 = 39828;
public static final int HERBS_39829 = 39829;
public static final int HERBS_39830 = 39830;
public static final int HERBS_39831 = 39831;
public static final int HERB_PATCH_39832 = 39832;
public static final int HERB_PATCH_39833 = 39833;
public static final int HERBS_39834 = 39834;
public static final int HERBS_39835 = 39835;
public static final int HERBS_39836 = 39836;
public static final int HERB_PATCH_39837 = 39837;
public static final int HERB_PATCH_39838 = 39838;
public static final int HERBS_39839 = 39839;
public static final int HERBS_39840 = 39840;
public static final int HERBS_39841 = 39841;
public static final int HERB_PATCH_39842 = 39842;
public static final int HERB_PATCH_39843 = 39843;
public static final int HERBS_39844 = 39844;
public static final int HERBS_39845 = 39845;
public static final int HERBS_39846 = 39846;
public static final int HERB_PATCH_39847 = 39847;
public static final int HERB_PATCH_39848 = 39848;
public static final int HERBS_39849 = 39849;
public static final int HERBS_39850 = 39850;
public static final int HERBS_39851 = 39851;
public static final int HERB_PATCH_39852 = 39852;
public static final int HERB_PATCH_39853 = 39853;
public static final int HERBS_39854 = 39854;
public static final int HERBS_39855 = 39855;
public static final int HERBS_39856 = 39856;
public static final int HERB_PATCH_39857 = 39857;
public static final int HERB_PATCH_39858 = 39858;
public static final int HERBS_39859 = 39859;
public static final int HERBS_39860 = 39860;
public static final int HERBS_39861 = 39861;
public static final int HERB_PATCH_39862 = 39862;
public static final int HERB_PATCH_39863 = 39863;
public static final int HERBS_39864 = 39864;
public static final int HERBS_39865 = 39865;
public static final int HERBS_39866 = 39866;
public static final int HERB_PATCH_39867 = 39867;
public static final int HERB_PATCH_39868 = 39868;
public static final int HERBS_39869 = 39869;
public static final int HERBS_39870 = 39870;
public static final int HERBS_39871 = 39871;
public static final int HERB_PATCH_39872 = 39872;
public static final int HERB_PATCH_39873 = 39873;
public static final int HERBS_39874 = 39874;
public static final int HERBS_39875 = 39875;
public static final int HERBS_39876 = 39876;
public static final int HERB_PATCH_39877 = 39877;
public static final int HERB_PATCH_39878 = 39878;
public static final int HERBS_39879 = 39879;
public static final int HERBS_39880 = 39880;
public static final int HERBS_39881 = 39881;
/* This file is automatically generated. Do not edit. */ /* This file is automatically generated. Do not edit. */
} }
@@ -89,4 +89,12 @@ public interface Player extends Actor
*/ */
@Nullable @Nullable
SkullIcon getSkullIcon(); SkullIcon getSkullIcon();
/**
* This is almost always not what you want
* @return literal 0
*/
int getRSSkillLevel();
String[] getActions();
} }
@@ -31,6 +31,13 @@ import net.runelite.api.kit.KitType;
*/ */
public interface PlayerAppearance public interface PlayerAppearance
{ {
/**
* Checks if the player is female.
*
* @return true if the player is female
*/
boolean isFemale();
/** /**
* Gets an array of IDs related to equipment slots. * Gets an array of IDs related to equipment slots.
* <p> * <p>
@@ -167,8 +167,8 @@ public final class ScriptID
* *
* Updates the VarClientInts (73, 74) to this same value * Updates the VarClientInts (73, 74) to this same value
* <ul> * <ul>
* <li> int Reset zoom position </li> * <li> int Reset zoom position for fixed viewport mode</li>
* <li> int Reset zoom position </li> * <li> int Reset zoom position for resizable viewport mode</li>
* </ul> * </ul>
*/ */
@ScriptArguments(integer = 2) @ScriptArguments(integer = 2)
@@ -241,12 +241,6 @@ public final class ScriptID
@ScriptArguments(integer = 18) @ScriptArguments(integer = 18)
public static final int BANKMAIN_SEARCH_TOGGLE = 281; public static final int BANKMAIN_SEARCH_TOGGLE = 281;
/**
* Builds the items kept on death widget
*/
@ScriptArguments(integer = 4, string = 2)
public static final int DEATH_KEEP_BUILD = 1601;
/** /**
* Builds the widget that holds all of the players inside a friends chat * Builds the widget that holds all of the players inside a friends chat
*/ */
@@ -329,4 +323,28 @@ public final class ScriptID
*/ */
@ScriptArguments(integer = 2) @ScriptArguments(integer = 2)
public static final int TOPLEVEL_REDRAW = 907; public static final int TOPLEVEL_REDRAW = 907;
/**
* Called to set position of an xpdrop text and sprite(s)
* <ul>
* <li> XP drop parent component </li>
* </ul>
*/
@ScriptArguments(integer = 4, string = 1)
public static final int XPDROPS_SETDROPSIZE = 996;
/**
* Main layout script for the bank
* <ul>
* <li>int (WidgetID) * 17, various widgets making up the bank interface</li>
* </ul>
*/
@ScriptArguments(integer = 17)
public static final int BANKMAIN_BUILD = 277;
@ScriptArguments(integer = 19)
public static final int BANKMAIN_FINISHBUILDING = 505;
@ScriptArguments()
public static final int BANKMAIN_SEARCHING = 514;
} }
@@ -42,4 +42,9 @@ public interface TileItem extends Entity
* @return * @return
*/ */
int getSpawnTime(); int getSpawnTime();
/**
* @return the tile this item is on
*/
Tile getTile();
} }

Some files were not shown because too many files have changed in this diff Show More