From ab229696409ad5d7b2c4ab4db7e0e07b0ddf61dc Mon Sep 17 00:00:00 2001 From: ThatGamerBlue Date: Thu, 18 Jun 2020 13:12:24 +0100 Subject: [PATCH] make error messages better --- ...Injexception.java => InjectException.java} | 8 +-- .../com/openosrs/injector/InjectUtil.java | 40 ++++++------ .../java/com/openosrs/injector/Injection.java | 20 +++--- .../openosrs/injector/InjectorValidator.java | 4 +- .../injector/injection/InjectData.java | 4 +- .../injector/injection/InjectTaskHandler.java | 4 +- .../injector/injectors/InjectConstruct.java | 12 ++-- .../injector/injectors/InjectHook.java | 24 +++---- .../injector/injectors/InjectHookMethod.java | 12 ++-- .../openosrs/injector/injectors/Injector.java | 4 +- .../injector/injectors/InterfaceInjector.java | 4 +- .../injector/injectors/MixinInjector.java | 63 ++++++++++--------- .../injector/injectors/RSApiInjector.java | 26 ++++---- .../injectors/raw/AddPlayerToMenu.java | 24 ++++--- .../injectors/raw/ClearColorBuffer.java | 6 +- .../injectors/raw/DrawAfterWidgets.java | 12 ++-- .../injector/injectors/raw/DrawMenu.java | 8 +-- .../injector/injectors/raw/Occluder.java | 6 +- .../injectors/raw/RasterizerAlpha.java | 10 +-- .../injector/injectors/raw/RenderDraw.java | 8 +-- .../injector/injectors/raw/ScriptVM.java | 18 +++--- .../injectors/rsapi/InjectGetter.java | 7 ++- .../injectors/rsapi/InjectInvoke.java | 7 ++- .../injectors/rsapi/InjectSetter.java | 7 ++- .../com/openosrs/injector/rsapi/RSApi.java | 6 +- .../injector/transformers/SourceChanger.java | 4 +- .../com/openosrs/injector/TestInjection.java | 2 +- .../transformers/SourceChangerTest.java | 5 +- 28 files changed, 180 insertions(+), 175 deletions(-) rename src/main/java/com/openosrs/injector/{Injexception.java => InjectException.java} (63%) diff --git a/src/main/java/com/openosrs/injector/Injexception.java b/src/main/java/com/openosrs/injector/InjectException.java similarity index 63% rename from src/main/java/com/openosrs/injector/Injexception.java rename to src/main/java/com/openosrs/injector/InjectException.java index eae1ac5..aa1a352 100644 --- a/src/main/java/com/openosrs/injector/Injexception.java +++ b/src/main/java/com/openosrs/injector/InjectException.java @@ -7,19 +7,19 @@ */ package com.openosrs.injector; -public class Injexception extends RuntimeException +public class InjectException extends RuntimeException { - public Injexception(String message) + public InjectException(String message) { super(message); } - public Injexception(Throwable cause) + public InjectException(Throwable cause) { super(cause); } - public Injexception(String message, Throwable cause) + public InjectException(String message, Throwable cause) { super(message, cause); } diff --git a/src/main/java/com/openosrs/injector/InjectUtil.java b/src/main/java/com/openosrs/injector/InjectUtil.java index 9ac265f..492d61d 100644 --- a/src/main/java/com/openosrs/injector/InjectUtil.java +++ b/src/main/java/com/openosrs/injector/InjectUtil.java @@ -54,7 +54,7 @@ public interface InjectUtil * @param name The name of the method you want to find * @return The obfuscated version of the found method */ - static Method findMethod(InjectData data, String name) throws Injexception + static Method findMethod(InjectData data, String name) throws InjectException { return findMethod(data, name, null, null); } @@ -74,7 +74,7 @@ public interface InjectUtil String name, String classHint, @Nullable Predicate sig) - throws Injexception + throws InjectException { return findMethod(data, name, classHint, sig, false, false); } @@ -85,13 +85,13 @@ public interface InjectUtil * @param data InjectData instance * @param name (Exported) method name * @param classHint The (exported) name of a class you expect (or know) the method to be in, or null, if you're not sure - * @throws Injexception If the hint class couldn't be found, or no method matching the settings was found + * @throws InjectException If the hint class couldn't be found, or no method matching the settings was found */ static Method findMethod( InjectData data, String name, @Nullable String classHint) - throws Injexception + throws InjectException { return findMethod(data, name, classHint, null, false, false); } @@ -106,7 +106,7 @@ public interface InjectUtil * @param notStatic If this is true, only check non-static methods. If classHint isn't null, check only subclasses * @param returnDeob If this is true, this method will return the deobfuscated method, instead of turning it into vanilla first * - * @throws Injexception If the hint class couldn't be found, or no method matching the settings was found + * @throws InjectException If the hint class couldn't be found, or no method matching the settings was found */ static Method findMethod( InjectData data, @@ -115,7 +115,7 @@ public interface InjectUtil @Nullable Predicate sig, boolean notStatic, boolean returnDeob) - throws Injexception + throws InjectException { final ClassGroup deob = data.getDeobfuscated(); if (classHint != null) @@ -144,14 +144,14 @@ public interface InjectUtil if (sig == null || sig.test(m.getDescriptor())) return returnDeob ? m : data.toVanilla(m); - throw new Injexception(String.format("Couldn't find %s", name)); + throw new InjectException(String.format("Couldn't find %s", name)); } - static ClassFile findClassOrThrow(ClassGroup group, String name) throws Injexception + static ClassFile findClassOrThrow(ClassGroup group, String name) throws InjectException { ClassFile clazz = group.findClass(name); if (clazz == null) - throw new Injexception("Hint class " + name + " doesn't exist"); + throw new InjectException("Hint class " + name + " doesn't exist"); return clazz; } @@ -159,7 +159,7 @@ public interface InjectUtil /** * Fail-fast implementation of ClassFile.findMethodDeep, using a predicate for signature */ - static Method findMethodDeep(ClassFile clazz, String name, Predicate type) throws Injexception + static Method findMethodDeep(ClassFile clazz, String name, Predicate type) throws InjectException { do for (Method method : clazz.getMethods()) @@ -168,7 +168,7 @@ public interface InjectUtil return method; while ((clazz = clazz.getParent()) != null); - throw new Injexception(String.format("Method %s couldn't be found", name + type.toString())); + throw new InjectException(String.format("Method %s couldn't be found", name + type.toString())); } /** @@ -176,7 +176,7 @@ public interface InjectUtil * * well... */ - static Field findStaticField(ClassGroup group, String name) throws Injexception + static Field findStaticField(ClassGroup group, String name) throws InjectException { for (ClassFile clazz : group) { @@ -185,7 +185,7 @@ public interface InjectUtil return f; } - throw new Injexception("Couldn't find static field " + name); + throw new InjectException("Couldn't find static field " + name); } /** @@ -198,7 +198,7 @@ public interface InjectUtil * * @return The obfuscated version of the found field */ - static Field findStaticField(InjectData data, String name, String classHint, Type type) throws Injexception + static Field findStaticField(InjectData data, String name, String classHint, Type type) throws InjectException { final ClassGroup deob = data.getDeobfuscated(); Field field; @@ -227,13 +227,13 @@ public interface InjectUtil return field; } - throw new Injexception(String.format("Static field %s doesn't exist", (type != null ? type + " " : "") + name)); + throw new InjectException(String.format("Static field %s doesn't exist", (type != null ? type + " " : "") + name)); } /** * Fail-fast implementation of ClassGroup.findFieldDeep */ - static Field findFieldDeep(ClassFile clazz, String name) throws Injexception + static Field findFieldDeep(ClassFile clazz, String name) throws InjectException { Field f; @@ -242,16 +242,16 @@ public interface InjectUtil return f; while ((clazz = clazz.getParent()) != null); - throw new Injexception("Couldn't find field " + name); + throw new InjectException("Couldn't find field " + name); } - static Field findField(InjectData data, String name, String hintClass) throws Injexception + static Field findField(InjectData data, String name, String hintClass) throws InjectException { final ClassGroup deob = data.getDeobfuscated(); return data.toVanilla(findField(deob, name, hintClass)); } - static Field findField(ClassGroup group, String name, String hintClass) throws Injexception + static Field findField(ClassGroup group, String name, String hintClass) throws InjectException { Field field; if (hintClass != null) @@ -267,7 +267,7 @@ public interface InjectUtil if ((field = clazz.findField(name)) != null) return field; - throw new Injexception("Field " + name + " doesn't exist"); + throw new InjectException("Field " + name + " doesn't exist"); } static ClassFile deobFromApiMethod(InjectData data, RSApiMethod apiMethod) diff --git a/src/main/java/com/openosrs/injector/Injection.java b/src/main/java/com/openosrs/injector/Injection.java index 724c569..3c01e1a 100644 --- a/src/main/java/com/openosrs/injector/Injection.java +++ b/src/main/java/com/openosrs/injector/Injection.java @@ -36,7 +36,7 @@ public class Injection extends InjectData implements InjectTaskHandler { private static final Logger log = Logging.getLogger(Injection.class); - public Injection(File vanilla, File rsclient, File mixins, FileTree rsapi) throws Injexception, IOException + public Injection(File vanilla, File rsclient, File mixins, FileTree rsapi) throws InjectException, IOException { super( JarUtil.loadJar(vanilla), @@ -46,9 +46,9 @@ public class Injection extends InjectData implements InjectTaskHandler ); } - public void inject() throws Injexception + public void inject() throws InjectException { - log.debug("Starting injection"); + log.debug("[DEBUG] Starting injection"); inject(new InterfaceInjector(this)); @@ -86,16 +86,16 @@ public class Injection extends InjectData implements InjectTaskHandler public void save(File outputJar) throws IOException { - log.info("Saving jar to {}", outputJar.toString()); + log.info("[INFO] Saving jar to {}", outputJar.toString()); JarUtil.saveJar(this.getVanilla(), outputJar); } - private void inject(Injector injector) throws Injexception + private void inject(Injector injector) throws InjectException { final String name = injector.getName(); - log.info("Starting {}", name); + log.info("[INFO] Starting {}", name); injector.start(); @@ -107,13 +107,13 @@ public class Injection extends InjectData implements InjectTaskHandler validate((Validator) injector); } - private void validate(Validator validator) throws Injexception + private void validate(Validator validator) throws InjectException { final String name = validator.getName(); if (!validator.validate()) { - throw new Injexception(name + " failed validation"); + throw new InjectException(name + " failed validation"); } } @@ -121,14 +121,14 @@ public class Injection extends InjectData implements InjectTaskHandler { final String name = transformer.getName(); - log.info("Starting {}", name); + log.info("[INFO] Starting {}", name); transformer.transform(); log.lifecycle("{} {}", name, transformer.getCompletionMsg()); } - public void runChildInjector(Injector injector) throws Injexception + public void runChildInjector(Injector injector) throws InjectException { inject(injector); } diff --git a/src/main/java/com/openosrs/injector/InjectorValidator.java b/src/main/java/com/openosrs/injector/InjectorValidator.java index 931a859..4a606a4 100644 --- a/src/main/java/com/openosrs/injector/InjectorValidator.java +++ b/src/main/java/com/openosrs/injector/InjectorValidator.java @@ -50,7 +50,7 @@ public class InjectorValidator implements Validator } String status = wtf > 0 ? WTF : missing > 0 ? ERROR : OK; - log.info("RSApiValidator completed. Status [{}] {} overridden methods, {} missing", status, okay, missing); + log.info("[INFO] RSApiValidator completed. Status [{}] {} overridden methods, {} missing", status, okay, missing); // valid, ref to static final field return status == OK; @@ -65,7 +65,7 @@ public class InjectorValidator implements Validator if (clazz.findMethodDeep(apiMethod.getName(), apiMethod.getSignature()) == null) { - log.warn("Class {} implements interface {} but doesn't implement {}", + log.warn("[WARN] Class {} implements interface {} but doesn't implement {}", clazz.getPoolClass(), apiClass.getClazz(), apiMethod.getMethod()); ++missing; } diff --git a/src/main/java/com/openosrs/injector/injection/InjectData.java b/src/main/java/com/openosrs/injector/injection/InjectData.java index c3acdeb..68992e6 100644 --- a/src/main/java/com/openosrs/injector/injection/InjectData.java +++ b/src/main/java/com/openosrs/injector/injection/InjectData.java @@ -9,7 +9,7 @@ package com.openosrs.injector.injection; import com.google.common.collect.ImmutableMap; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injectors.Injector; import com.openosrs.injector.rsapi.RSApi; import java.util.HashMap; @@ -64,7 +64,7 @@ public abstract class InjectData this.toVanilla = initToVanilla(); } - public abstract void runChildInjector(Injector injector) throws Injexception; + public abstract void runChildInjector(Injector injector) throws InjectException; private Map initToVanilla() { diff --git a/src/main/java/com/openosrs/injector/injection/InjectTaskHandler.java b/src/main/java/com/openosrs/injector/injection/InjectTaskHandler.java index 72925e8..b57702a 100644 --- a/src/main/java/com/openosrs/injector/injection/InjectTaskHandler.java +++ b/src/main/java/com/openosrs/injector/injection/InjectTaskHandler.java @@ -7,7 +7,7 @@ */ package com.openosrs.injector.injection; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import java.io.File; import java.io.IOException; @@ -19,7 +19,7 @@ public interface InjectTaskHandler /** * The actual method that does all the work */ - void inject() throws Injexception; + void inject() throws InjectException; /** * Call this to save the injected jar to outputJar diff --git a/src/main/java/com/openosrs/injector/injectors/InjectConstruct.java b/src/main/java/com/openosrs/injector/injectors/InjectConstruct.java index 24e2f63..2e7d43e 100644 --- a/src/main/java/com/openosrs/injector/injectors/InjectConstruct.java +++ b/src/main/java/com/openosrs/injector/injectors/InjectConstruct.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.rsapi.RSApiMethod; import static com.openosrs.injector.rsapi.RSApi.CONSTRUCT; @@ -63,7 +63,7 @@ public class InjectConstruct extends AbstractInjector } @Override - public void inject() throws Injexception + public void inject() throws InjectException { for (RSApiMethod apiMethod : inject.getRsApi().getConstructs()) { @@ -81,12 +81,12 @@ public class InjectConstruct extends AbstractInjector injected++; } - log.info("Injected {} constructors", injected); + log.info("[INFO] Injected {} constructors", injected); } - private void injectConstruct(ClassFile targetClass, Method apiMethod) throws Injexception + private void injectConstruct(ClassFile targetClass, Method apiMethod) throws InjectException { - log.debug("Injecting constructor for {} into {}", apiMethod, targetClass.getPoolClass()); + log.debug("[DEBUG] Injecting constructor for {} into {}", apiMethod, targetClass.getPoolClass()); final Type returnval = apiMethod.getType().getReturnValue(); @@ -103,7 +103,7 @@ public class InjectConstruct extends AbstractInjector final net.runelite.asm.Method constructor = classToConstruct.findMethod("", constr); if (constructor == null) - throw new Injexception("Unable to find constructor for " + classToConstruct.getName() + "." + constr); + throw new InjectException("Unable to find constructor for " + classToConstruct.getName() + "." + constr); net.runelite.asm.Method setterMethod = new net.runelite.asm.Method(targetClass, apiMethod.getName(), apiMethod.getType()); diff --git a/src/main/java/com/openosrs/injector/injectors/InjectHook.java b/src/main/java/com/openosrs/injector/injectors/InjectHook.java index e6e4c96..ec72763 100644 --- a/src/main/java/com/openosrs/injector/injectors/InjectHook.java +++ b/src/main/java/com/openosrs/injector/injectors/InjectHook.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors; import com.google.common.collect.Lists; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import java.util.HashMap; import java.util.HashSet; @@ -83,17 +83,17 @@ public class InjectHook extends AbstractInjector } @Override - public void inject() throws Injexception + public void inject() throws InjectException { for (Map.Entry, List> entry : mixinTargets.entrySet()) injectMethods(entry.getKey(), entry.getValue()); injectHooks(); - log.info("Injected {} field hooks.", injectedHooks); + log.info("[INFO] Injected {} field hooks.", injectedHooks); } - private void injectMethods(Provider mixinProvider, List targetClasses) throws Injexception + private void injectMethods(Provider mixinProvider, List targetClasses) throws InjectException { final ClassFile mixinClass = mixinProvider.get(); @@ -189,7 +189,7 @@ public class InjectHook extends AbstractInjector // idx + 1 to insert after the set injectCallback(ins, idx + 1, hookInfo, null, objectStackContext); } - catch (Injexception ex) + catch (InjectException ex) { throw new RuntimeException(ex); } @@ -237,7 +237,7 @@ public class InjectHook extends AbstractInjector objectStackContext = arrayReferencePushed.getPops().get(0); // inject hook after 'i' - log.debug("Found array injection location for hook {} at instruction {}", hookInfo.method.getName(), i); + log.debug("[DEBUG] Found array injection location for hook {} at instruction {}", hookInfo.method.getName(), i); ++injectedHooks; int idx = ins.getInstructions().indexOf(i); @@ -250,7 +250,7 @@ public class InjectHook extends AbstractInjector else injectCallback(ins, idx + 1, hookInfo, index, objectStackContext); } - catch (Injexception ex) + catch (InjectException ex) { throw new RuntimeException(ex); } @@ -259,7 +259,8 @@ public class InjectHook extends AbstractInjector e.run(); } - private void injectCallbackBefore(Instructions ins, int idx, HookInfo hookInfo, StackContext index, StackContext object, StackContext value) throws Injexception + private void injectCallbackBefore(Instructions ins, int idx, HookInfo hookInfo, StackContext index, StackContext object, StackContext value) throws + InjectException { Signature signature = hookInfo.method.getDescriptor(); Type methodArgumentType = signature.getTypeOfArg(0); @@ -267,7 +268,7 @@ public class InjectHook extends AbstractInjector if (!hookInfo.method.isStatic()) { if (object == null) - throw new Injexception("null object"); + throw new InjectException("null object"); ins.getInstructions().add(idx++, new Dup(ins)); // dup value idx = recursivelyPush(ins, idx, object); @@ -321,12 +322,13 @@ public class InjectHook extends AbstractInjector return idx; } - private void injectCallback(Instructions ins, int idx, HookInfo hookInfo, StackContext index, StackContext objectPusher) throws Injexception + private void injectCallback(Instructions ins, int idx, HookInfo hookInfo, StackContext index, StackContext objectPusher) throws + InjectException { if (!hookInfo.method.isStatic()) { if (objectPusher == null) - throw new Injexception("Null object pusher"); + throw new InjectException("Null object pusher"); idx = recursivelyPush(ins, idx, objectPusher); } diff --git a/src/main/java/com/openosrs/injector/injectors/InjectHookMethod.java b/src/main/java/com/openosrs/injector/injectors/InjectHookMethod.java index fae0cea..37d7afb 100644 --- a/src/main/java/com/openosrs/injector/injectors/InjectHookMethod.java +++ b/src/main/java/com/openosrs/injector/injectors/InjectHookMethod.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import java.util.List; import java.util.ListIterator; @@ -62,15 +62,15 @@ public class InjectHookMethod extends AbstractInjector } @Override - public void inject() throws Injexception + public void inject() throws InjectException { for (Map.Entry, List> entry : mixinTargets.entrySet()) injectMethods(entry.getKey(), entry.getValue()); - log.info("Injected {} method hooks", injected); + log.info("[INFO] Injected {} method hooks", injected); } - private void injectMethods(Provider mixinProvider, List targetClasses) throws Injexception + private void injectMethods(Provider mixinProvider, List targetClasses) throws InjectException { final ClassFile mixinClass = mixinProvider.get(); @@ -83,7 +83,7 @@ public class InjectHookMethod extends AbstractInjector continue; if (!mixinMethod.getDescriptor().isVoid()) - throw new Injexception("Method hook " + mixinMethod.getPoolMethod() + " doesn't have void return type"); + throw new InjectException("Method hook " + mixinMethod.getPoolMethod() + " doesn't have void return type"); final String hookName = methodHook.getElement().getString(); final boolean end = methodHook.getElements().size() == 2 && methodHook.getElements().get(1).getValue().equals(true); @@ -101,7 +101,7 @@ public class InjectHookMethod extends AbstractInjector inject(targetMethod, hookMethod, end); - log.debug("Injected method hook {} in {}", hookMethod, targetMethod); + log.debug("[DEBUG] Injected method hook {} in {}", hookMethod, targetMethod); ++injected; } } diff --git a/src/main/java/com/openosrs/injector/injectors/Injector.java b/src/main/java/com/openosrs/injector/injectors/Injector.java index 44a159f..d779896 100644 --- a/src/main/java/com/openosrs/injector/injectors/Injector.java +++ b/src/main/java/com/openosrs/injector/injectors/Injector.java @@ -7,7 +7,7 @@ */ package com.openosrs.injector.injectors; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import net.runelite.asm.Named; public interface Injector extends Named @@ -15,7 +15,7 @@ public interface Injector extends Named /** * Where all the injection should be done */ - void inject() throws Injexception; + void inject() throws InjectException; /** * Get a name the injector is going to be referred to in logging diff --git a/src/main/java/com/openosrs/injector/injectors/InterfaceInjector.java b/src/main/java/com/openosrs/injector/injectors/InterfaceInjector.java index 7f2bf0f..c04b490 100644 --- a/src/main/java/com/openosrs/injector/injectors/InterfaceInjector.java +++ b/src/main/java/com/openosrs/injector/injectors/InterfaceInjector.java @@ -28,7 +28,7 @@ public class InterfaceInjector extends AbstractInjector // forEachPair performs actions on a deob-vanilla pair, which is what's needed here inject.forEachPair(this::injectInterface); - log.info("Injected {} interfaces", implemented); + log.info("[INFO] Injected {} interfaces", implemented); } private void injectInterface(final ClassFile deobCf, final ClassFile vanillaCf) @@ -41,7 +41,7 @@ public class InterfaceInjector extends AbstractInjector final String fullName = API_BASE + impls; if (!inject.getRsApi().hasClass(fullName)) { - log.debug("Class {} implements nonexistent interface {}, skipping interface injection", + log.debug("[DEBUG] Class {} implements nonexistent interface {}, skipping interface injection", deobCf.getName(), fullName ); diff --git a/src/main/java/com/openosrs/injector/injectors/MixinInjector.java b/src/main/java/com/openosrs/injector/injectors/MixinInjector.java index e2b3ffb..a620b12 100644 --- a/src/main/java/com/openosrs/injector/injectors/MixinInjector.java +++ b/src/main/java/com/openosrs/injector/injectors/MixinInjector.java @@ -34,7 +34,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import java.util.ArrayList; import java.util.HashMap; @@ -96,35 +96,35 @@ public class MixinInjector extends AbstractInjector } @Override - public void inject() throws Injexception + public void inject() throws InjectException { final Map, List> mixinTargets = initTargets(); inject(mixinTargets); } @VisibleForTesting - void inject(Map, List> mixinTargets) throws Injexception + void inject(Map, List> mixinTargets) throws InjectException { for (Map.Entry, List> entry : mixinTargets.entrySet()) { injectFields(entry.getKey(), entry.getValue()); } - log.info("Injected {} fields", injectedFields.size()); + log.info("[INFO] Injected {} fields", injectedFields.size()); for (Map.Entry, List> entry : mixinTargets.entrySet()) { findShadowFields(entry.getKey()); } - log.info("Shadowed {} fields", shadowFields.size()); + log.info("[INFO] Shadowed {} fields", shadowFields.size()); for (Map.Entry, List> entry : mixinTargets.entrySet()) { injectMethods(entry.getKey(), entry.getValue()); } - log.info("Injected {}, copied {}, replaced {} methods", injected, copied, replaced); + log.info("[INFO] Injected {}, copied {}, replaced {} methods", injected, copied, replaced); inject.runChildInjector(new InjectHook(inject, mixinTargets)); @@ -184,7 +184,7 @@ public class MixinInjector extends AbstractInjector return builder.build(); } - private void injectFields(Provider mixinProvider, List targetClasses) throws Injexception + private void injectFields(Provider mixinProvider, List targetClasses) throws InjectException { final ClassFile mixinClass = mixinProvider.get(); @@ -211,14 +211,14 @@ public class MixinInjector extends AbstractInjector targetClass.addField(copy); if (injectedFields.containsKey(field.getName()) && !ASSERTION_FIELD.equals(field.getName())) - throw new Injexception("Duplicate field: " + field.getName()); + throw new InjectException("Duplicate field: " + field.getName()); injectedFields.put(field.getName(), copy); } } } - private void findShadowFields(Provider mixinProvider) throws Injexception + private void findShadowFields(Provider mixinProvider) throws InjectException { final ClassFile mixinClass = mixinProvider.get(); @@ -230,7 +230,7 @@ public class MixinInjector extends AbstractInjector continue; if (!field.isStatic()) - throw new Injexception("Shadowed fields must be static"); + throw new InjectException("Shadowed fields must be static"); String shadowed = shadow.getElement().getString(); @@ -246,7 +246,7 @@ public class MixinInjector extends AbstractInjector } if ((targetField.getAccessFlags() & Opcodes.ACC_PRIVATE) != 0) - throw new Injexception("Shadowed fields can't be private"); + throw new InjectException("Shadowed fields can't be private"); shadowFields.put( field.getPoolField(), @@ -255,7 +255,7 @@ public class MixinInjector extends AbstractInjector } } - private void injectMethods(Provider mixinProvider, List targetClasses) throws Injexception + private void injectMethods(Provider mixinProvider, List targetClasses) throws InjectException { for (ClassFile targetClass : targetClasses) { @@ -278,13 +278,13 @@ public class MixinInjector extends AbstractInjector Method deobSourceMethod = InjectUtil.findMethod(inject, copiedName, inject.toDeob(targetClass.getName()).getName(), deobSig::equals, notStat, true); if (mixinMethod.isStatic() != deobSourceMethod.isStatic()) - throw new Injexception("Mixin method " + mixinMethod + " should be " + (deobSourceMethod.isStatic() ? "static" : "non-static")); + throw new InjectException("Mixin method " + mixinMethod + " should be " + (deobSourceMethod.isStatic() ? "static" : "non-static")); // The actual method we're copying, including code etc Method sourceMethod = inject.toVanilla(deobSourceMethod); if (mixinMethod.getDescriptor().size() > sourceMethod.getDescriptor().size()) - throw new Injexception("Mixin methods cannot have more parameters than their corresponding ob method"); + throw new InjectException("Mixin methods cannot have more parameters than their corresponding ob method"); Method copy = new Method(targetClass, "copy$" + copiedName, sourceMethod.getDescriptor()); moveCode(copy, sourceMethod.getCode()); @@ -317,7 +317,7 @@ public class MixinInjector extends AbstractInjector if ((hasInject && isInit) || isClinit) { if (!"()V".equals(mixinMethod.getDescriptor().toString())) - throw new Injexception("Injected constructors cannot have arguments"); + throw new InjectException("Injected constructors cannot have arguments"); Method[] originalMethods = targetClass.getMethods().stream() .filter(m -> m.getName().equals(mixinMethod.getName())) @@ -392,7 +392,7 @@ public class MixinInjector extends AbstractInjector } } - log.debug("Injected mixin method {} to {}", copy, targetClass); + log.debug("[DEBUG] Injected mixin method {} to {}", copy, targetClass); ++injected; } else if (hasInject) @@ -406,7 +406,7 @@ public class MixinInjector extends AbstractInjector if (copiedMethods.containsKey(ii.getMethod())) { - throw new Injexception("Injected methods cannot invoke copied methods"); + throw new InjectException("Injected methods cannot invoke copied methods"); } } } @@ -421,7 +421,7 @@ public class MixinInjector extends AbstractInjector targetClass.addMethod(copy); - log.debug("Injected mixin method {} to {}", copy, targetClass); + log.debug("[DEBUG] Injected mixin method {} to {}", copy, targetClass); ++injected; } else if (mixinMethod.getAnnotations().find(REPLACE) != null) @@ -434,12 +434,12 @@ public class MixinInjector extends AbstractInjector if (deobMethod == null) { - throw new Injexception("Failed to find the deob method " + replacedName + " for mixin " + mixinClass); + throw new InjectException("Failed to find the deob method " + replacedName + " for mixin " + mixinClass); } if (mixinMethod.isStatic() != deobMethod.isStatic()) { - throw new Injexception("Mixin method " + mixinMethod + " should be " + throw new InjectException("Mixin method " + mixinMethod + " should be " + (deobMethod.isStatic() ? "static" : "non-static")); } @@ -454,7 +454,7 @@ public class MixinInjector extends AbstractInjector if (mixinMethod.getDescriptor().size() > obMethod.getDescriptor().size()) { - throw new Injexception("Mixin methods cannot have more parameters than their corresponding ob method"); + throw new InjectException("Mixin methods cannot have more parameters than their corresponding ob method"); } Type returnType = mixinMethod.getDescriptor().getReturnValue(); @@ -507,7 +507,7 @@ public class MixinInjector extends AbstractInjector setOwnersToTargetClass(mixinClass, targetClass, obMethod, copiedMethods); - log.debug("Replaced method {} with mixin method {}", obMethod, mixinMethod); + log.debug("[DEBUG] Replaced method {} with mixin method {}", obMethod, mixinMethod); replaced++; } } @@ -531,7 +531,8 @@ public class MixinInjector extends AbstractInjector targetMethod.setCode(newCode); } - private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, Map copiedMethods) throws Injexception + private void setOwnersToTargetClass(ClassFile mixinCf, ClassFile cf, Method method, Map copiedMethods) throws + InjectException { ListIterator iterator = method.getCode().getInstructions().listIterator(); @@ -549,7 +550,7 @@ public class MixinInjector extends AbstractInjector Type newType = new Type("L" + inject.toVanilla(deobTypeClass).getName() + ";"); ((ANewArray) i).setType(newType); - log.debug("Replaced {} type {} with type {}", i, type, newType); + log.debug("[DEBUG] Replaced {} type {} with type {}", i, type, newType); } } else if (i instanceof InvokeInstruction) @@ -628,7 +629,7 @@ public class MixinInjector extends AbstractInjector } } - private void verify(ClassFile mixinCf, Instruction i) throws Injexception + private void verify(ClassFile mixinCf, Instruction i) throws InjectException { if (i instanceof FieldInstruction) { @@ -637,11 +638,11 @@ public class MixinInjector extends AbstractInjector if (fi.getField().getClazz().getName().equals(mixinCf.getName())) { if (i instanceof PutField || i instanceof GetField) - throw new Injexception("Access to non static member field of mixin"); + throw new InjectException("Access to non static member field of mixin"); Field field = fi.getMyField(); if (field != null && !field.isPublic()) - throw new Injexception("Static access to non public field " + field); + throw new InjectException("Static access to non public field " + field); } } else if (i instanceof InvokeStatic) @@ -650,15 +651,15 @@ public class MixinInjector extends AbstractInjector if (is.getMethod().getClazz() != mixinCf.getPoolClass() && is.getMethod().getClazz().getName().startsWith(MIXIN_BASE)) - throw new Injexception("Invoking static methods of other mixins is not supported"); + throw new InjectException("Invoking static methods of other mixins is not supported"); } else if (i instanceof InvokeDynamic) // RS classes don't verify under java 7+ due to the // super() invokespecial being inside of a try{} - throw new Injexception("Injected bytecode must be Java 6 compatible"); + throw new InjectException("Injected bytecode must be Java 6 compatible"); } - private Method findDeobMatching(ClassFile deobClass, Method mixinMethod, String deobName) throws Injexception + private Method findDeobMatching(ClassFile deobClass, Method mixinMethod, String deobName) throws InjectException { List matching = new ArrayList<>(); @@ -674,7 +675,7 @@ public class MixinInjector extends AbstractInjector if (matching.size() > 1) // this happens when it has found several deob methods for some mixin method, // to get rid of the error, refine your search by making your mixin method have more parameters - throw new Injexception("There are several matching methods when there should only be one"); + throw new InjectException("There are several matching methods when there should only be one"); else if (matching.size() == 1) return matching.get(0); diff --git a/src/main/java/com/openosrs/injector/injectors/RSApiInjector.java b/src/main/java/com/openosrs/injector/injectors/RSApiInjector.java index 6fb1bec..fe0d6b2 100644 --- a/src/main/java/com/openosrs/injector/injectors/RSApiInjector.java +++ b/src/main/java/com/openosrs/injector/injectors/RSApiInjector.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.rsapi.InjectGetter; import com.openosrs.injector.injectors.rsapi.InjectInvoke; @@ -62,7 +62,7 @@ public class RSApiInjector extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { for (final ClassFile deobClass : inject.getDeobfuscated()) { @@ -74,10 +74,10 @@ public class RSApiInjector extends AbstractInjector retryFailures(); - log.info("Injected {} getters, {} setters, and {} invokers", get, set, voke); + log.info("[INFO] Injected {} getters, {} setters, and {} invokers", get, set, voke); } - private void injectFields(ClassFile deobClass, RSApiClass implementingClass) throws Injexception + private void injectFields(ClassFile deobClass, RSApiClass implementingClass) throws InjectException { for (Field deobField : deobClass.getFields()) { @@ -153,13 +153,13 @@ public class RSApiInjector extends AbstractInjector final Number getter = DeobAnnotations.getObfuscatedGetter(deobField); if (deobField.isStatic() != vanillaField.isStatic()) // Can this even happen - throw new Injexception("Something went horribly wrong, and this should honestly never happen, but you never know. Btw it's the static-ness"); + throw new InjectException("Something went horribly wrong, and this should honestly never happen, but you never know. Btw it's the static-ness"); inject(matching, deobField, vanillaField, getter); } } - private void injectMethods(ClassFile deobClass, RSApiClass implementingClass) throws Injexception + private void injectMethods(ClassFile deobClass, RSApiClass implementingClass) throws InjectException { for (Method deobMethod : deobClass.getMethods()) { @@ -205,17 +205,17 @@ public class RSApiInjector extends AbstractInjector final ClassFile targetClass = InjectUtil.vanillaFromApiMethod(inject, apiMethod); final Method vanillaMethod = inject.toVanilla(deobMethod); final String garbage = DeobAnnotations.getDecoder(deobMethod); - log.debug("Injecting invoker {} for {} into {}", apiMethod.getMethod(), vanillaMethod.getPoolMethod(), targetClass.getPoolClass()); + log.debug("[DEBUG] Injecting invoker {} for {} into {}", apiMethod.getMethod(), vanillaMethod.getPoolMethod(), targetClass.getPoolClass()); InjectInvoke.inject(targetClass, apiMethod, vanillaMethod, garbage); ++voke; apiMethod.setInjected(true); } else if (matching.size() != 0) - throw new Injexception("Multiple api imports matching method " + deobMethod.getPoolMethod()); + throw new InjectException("Multiple api imports matching method " + deobMethod.getPoolMethod()); } } - private void retryFailures() throws Injexception + private void retryFailures() throws InjectException { for (Map.Entry> entry : retryFields.entrySet()) { @@ -225,7 +225,7 @@ public class RSApiInjector extends AbstractInjector matched.removeIf(RSApiMethod::isInjected); if (matched.size() > 2) - throw new Injexception("More than 2 imported api methods for field " + deobField.getPoolField()); + throw new InjectException("More than 2 imported api methods for field " + deobField.getPoolField()); final Field vanillaField = inject.toVanilla(deobField); final Number getter = DeobAnnotations.getObfuscatedGetter(deobField); @@ -257,7 +257,7 @@ public class RSApiInjector extends AbstractInjector return matching; } - private void inject(List matched, Field field, Field targetField, Number getter) throws Injexception + private void inject(List matched, Field field, Field targetField, Number getter) throws InjectException { for (RSApiMethod apiMethod : matched) { @@ -267,7 +267,7 @@ public class RSApiInjector extends AbstractInjector if (apiMethod.getSignature().isVoid()) { ++set; - log.debug("Injecting setter {} for {} into {}", apiMethod.getMethod(), field.getPoolField(), targetClass.getPoolClass()); + log.debug("[DEBUG] Injecting setter {} for {} into {}", apiMethod.getMethod(), field.getPoolField(), targetClass.getPoolClass()); InjectSetter.inject( targetClass, apiMethod, @@ -278,7 +278,7 @@ public class RSApiInjector extends AbstractInjector else { ++get; - log.debug("Injecting getter {} for {} into {}", apiMethod.getMethod(), field.getPoolField(), targetClass.getPoolClass()); + log.debug("[DEBUG] Injecting getter {} for {} into {}", apiMethod.getMethod(), field.getPoolField(), targetClass.getPoolClass()); InjectGetter.inject( targetClass, apiMethod, diff --git a/src/main/java/com/openosrs/injector/injectors/raw/AddPlayerToMenu.java b/src/main/java/com/openosrs/injector/injectors/raw/AddPlayerToMenu.java index dca72a8..77b4727 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/AddPlayerToMenu.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/AddPlayerToMenu.java @@ -9,7 +9,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.AbstractInjector; import java.util.ArrayList; @@ -43,7 +43,7 @@ public class AddPlayerToMenu extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { final Method addPlayerOptions = InjectUtil.findMethod(inject, "addPlayerToMenu"); final net.runelite.asm.pool.Method shouldHideAttackOptionFor = @@ -57,11 +57,9 @@ public class AddPlayerToMenu extends AbstractInjector injectHideAttack(addPlayerOptions, shouldHideAttackOptionFor); injectHideCast(addPlayerOptions, shouldHideAttackOptionFor); } - catch (Injexception | AssertionError e) + catch (InjectException | AssertionError e) { - log.warn( - "HidePlayerAttacks failed, but as this doesn't mess up anything other than that functionality, we're carrying on", - e); + log.warn("[WARN] HidePlayerAttacks failed, but as this doesn't mess up anything other than that functionality, we're carrying on", e); } } @@ -93,7 +91,7 @@ public class AddPlayerToMenu extends AbstractInjector } private void injectHideAttack(Method addPlayerOptions, net.runelite.asm.pool.Method shouldHideAttackOptionFor) - throws Injexception + throws InjectException { final Field AttackOption_hidden = InjectUtil.findField(inject, "AttackOption_hidden", "AttackOption").getPoolField(); @@ -139,7 +137,7 @@ public class AddPlayerToMenu extends AbstractInjector i = iterator.next(); if (!(i instanceof ComparisonInstruction && i instanceof JumpingInstruction)) { - log.info("You're not supposed to see this lol"); + log.info("[INFO] You're not supposed to see this lol"); continue; } @@ -160,7 +158,7 @@ public class AddPlayerToMenu extends AbstractInjector if (injectIdx <= 0 || label == null && labelIns == null) { - throw new Injexception("HidePlayerAttacks failed"); + throw new InjectException("HidePlayerAttacks failed"); } // Load the player @@ -185,7 +183,7 @@ public class AddPlayerToMenu extends AbstractInjector } private void injectHideCast(Method addPlayerOptions, net.runelite.asm.pool.Method shouldHideAttackOptionFor) - throws Injexception + throws InjectException { // LABEL before // BIPUSH 8 @@ -227,7 +225,7 @@ public class AddPlayerToMenu extends AbstractInjector } else { - throw new Injexception("3 bipushes? fucking mental, Hide spells failed btw"); + throw new InjectException("3 bipushes? fucking mental, Hide spells failed btw"); } continue; @@ -249,7 +247,7 @@ public class AddPlayerToMenu extends AbstractInjector { if (b1 && b2 && iAnd && getstatic) { - throw new Injexception("@ me in discord if this shit is broken lol, hide spells failed btw"); + throw new InjectException("@ me in discord if this shit is broken lol, hide spells failed btw"); } continue; } @@ -266,7 +264,7 @@ public class AddPlayerToMenu extends AbstractInjector } else { - throw new Injexception("@ me in discord if this shit is broken lol, hide spells failed btw"); + throw new InjectException("@ me in discord if this shit is broken lol, hide spells failed btw"); } // Load the player diff --git a/src/main/java/com/openosrs/injector/injectors/raw/ClearColorBuffer.java b/src/main/java/com/openosrs/injector/injectors/raw/ClearColorBuffer.java index 644e2c9..42abbbb 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/ClearColorBuffer.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/ClearColorBuffer.java @@ -8,7 +8,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import static com.openosrs.injector.injection.InjectData.HOOKS; import com.openosrs.injector.injectors.AbstractInjector; @@ -39,7 +39,7 @@ public class ClearColorBuffer extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { /* * This class stops the client from basically painting everything black before the scene is drawn @@ -85,7 +85,7 @@ public class ClearColorBuffer extends AbstractInjector Instructions ins = instr.getInstructions(); ins.replace(instr, new InvokeStatic(ins, CLEARBUFFER)); - log.debug("Injected drawRectangle at {}", methodContext.getMethod().getPoolMethod()); + log.debug("[DEBUG] Injected drawRectangle at {}", methodContext.getMethod().getPoolMethod()); } } } diff --git a/src/main/java/com/openosrs/injector/injectors/raw/DrawAfterWidgets.java b/src/main/java/com/openosrs/injector/injectors/raw/DrawAfterWidgets.java index 7c36bcd..a171c26 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/DrawAfterWidgets.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/DrawAfterWidgets.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import static com.openosrs.injector.injection.InjectData.HOOKS; import com.openosrs.injector.injectors.AbstractInjector; @@ -57,7 +57,7 @@ public class DrawAfterWidgets extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { /* * This call has to be injected using raw injection because the @@ -107,7 +107,7 @@ public class DrawAfterWidgets extends AbstractInjector if (noClip == null) { - throw new Injexception("Mapped method \"Rasterizer2D_resetClip\" could not be found."); + throw new InjectException("Mapped method \"Rasterizer2D_resetClip\" could not be found."); } net.runelite.asm.pool.Method poolNoClip = noClip.getPoolMethod(); @@ -162,7 +162,7 @@ public class DrawAfterWidgets extends AbstractInjector { // If we get here, we're either in the wrong method // or Jagex has removed the "if (535573958 * kl != -1)" - // log.debug("Could not find the label for jumping to the " + noClip + " call in " + m); + // log.debug("[DEBUG] Could not find the label for jumping to the " + noClip + " call in " + m); continue; } @@ -245,7 +245,7 @@ public class DrawAfterWidgets extends AbstractInjector instructions.addInstruction(instructions.getInstructions().indexOf(l) + 1, invoke); - log.debug("injectDrawAfterWidgets injected a call after " + l); + log.debug("[DEBUG] injectDrawAfterWidgets injected a call after " + l); injected = true; } @@ -254,7 +254,7 @@ public class DrawAfterWidgets extends AbstractInjector if (!injected) { - throw new Injexception("injectDrawAfterWidgets failed to inject!"); + throw new InjectException("injectDrawAfterWidgets failed to inject!"); } } } diff --git a/src/main/java/com/openosrs/injector/injectors/raw/DrawMenu.java b/src/main/java/com/openosrs/injector/injectors/raw/DrawMenu.java index 5db6cc2..342fc97 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/DrawMenu.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/DrawMenu.java @@ -8,7 +8,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import static com.openosrs.injector.injection.InjectData.HOOKS; import com.openosrs.injector.injectors.AbstractInjector; @@ -42,7 +42,7 @@ public class DrawMenu extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { /* * The drawMenu method can be inlined, so we need this raw injector to find where to inject. @@ -118,7 +118,7 @@ public class DrawMenu extends AbstractInjector } if (injectInvokeAfter == null || labelToJumpTo == null) - throw new Injexception("Couldn't find the right location for DrawMenu to inject"); + throw new InjectException("Couldn't find the right location for DrawMenu to inject"); final Instructions instrs = mc.getMethod().getCode().getInstructions(); int idx = instrs.getInstructions().indexOf(injectInvokeAfter); @@ -126,6 +126,6 @@ public class DrawMenu extends AbstractInjector instrs.addInstruction(++idx, new InvokeStatic(instrs, DRAWMENU)); instrs.addInstruction(++idx, new IfNe(instrs, labelToJumpTo)); - log.info("DrawMenu injected a method call at index {} in method {}. With a comparison jumping to {}", idx, drawLoggedIn, labelToJumpTo); + log.info("[INFO] DrawMenu injected a method call at index {} in method {}. With a comparison jumping to {}", idx, drawLoggedIn, labelToJumpTo); } } diff --git a/src/main/java/com/openosrs/injector/injectors/raw/Occluder.java b/src/main/java/com/openosrs/injector/injectors/raw/Occluder.java index 6718dba..94dd99e 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/Occluder.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/Occluder.java @@ -7,7 +7,7 @@ */ package com.openosrs.injector.injectors.raw; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.AbstractInjector; import java.util.ListIterator; @@ -27,7 +27,7 @@ public class Occluder extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { /* * This class the max view distance length, higher than this is useless though @@ -64,6 +64,6 @@ public class Occluder extends AbstractInjector } if (replaced != 10) - throw new Injexception("Only found " + replaced + " 25's to replace in occlude instead of expected 10"); + throw new InjectException("Only found " + replaced + " 25's to replace in occlude instead of expected 10"); } } diff --git a/src/main/java/com/openosrs/injector/injectors/raw/RasterizerAlpha.java b/src/main/java/com/openosrs/injector/injectors/raw/RasterizerAlpha.java index e099947..d68727b 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/RasterizerAlpha.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/RasterizerAlpha.java @@ -9,7 +9,7 @@ package com.openosrs.injector.injectors.raw; import com.google.common.collect.Lists; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.AbstractInjector; import net.runelite.asm.ClassFile; @@ -59,7 +59,7 @@ public class RasterizerAlpha extends AbstractInjector /* * This class exists to allow transparency in overlays */ - public void inject() throws Injexception + public void inject() throws InjectException { final Field r2dPx = InjectUtil.findField(inject, "Rasterizer2D_pixels", "Rasterizer2D"); final Method draw = InjectUtil.findMethod(inject, "drawLoggedIn", "Client"); @@ -187,17 +187,17 @@ public class RasterizerAlpha extends AbstractInjector if (orCount != 0) { counts[0] += orCount; - log.info("Added {} OR's into {}", orCount, mc.getMethod()); + log.info("[INFO] Added {} OR's into {}", orCount, mc.getMethod()); } if (count != 0) { counts[1] += count; - log.info("Injected {} DrawAlpha invokes into {}", count, mc.getMethod()); + log.info("[INFO] Injected {} DrawAlpha invokes into {}", count, mc.getMethod()); } }); ex.run(); - log.info("Injected {} DrawAlpha invokes and {} ors", counts[1], counts[0]); + log.info("[INFO] Injected {} DrawAlpha invokes and {} ors", counts[1], counts[0]); } private static boolean pushesToSameVar(InstructionContext cA, InstructionContext cB) diff --git a/src/main/java/com/openosrs/injector/injectors/raw/RenderDraw.java b/src/main/java/com/openosrs/injector/injectors/raw/RenderDraw.java index ce0d6df..9a0c57b 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/RenderDraw.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/RenderDraw.java @@ -8,7 +8,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import static com.openosrs.injector.injection.InjectData.HOOKS; import com.openosrs.injector.injectors.AbstractInjector; @@ -36,7 +36,7 @@ public class RenderDraw extends AbstractInjector } @Override - public void inject() throws Injexception + public void inject() throws InjectException { int replaced = 0; @@ -57,13 +57,13 @@ public class RenderDraw extends AbstractInjector if (((InvokeVirtual) i).getMethod().equals(draw)) { iterator.set(new InvokeStatic(ins, RENDERDRAW)); - log.debug("Replaced method call at {}", i); + log.debug("[DEBUG] Replaced method call at {}", i); ++replaced; } } } if (replaced != EXPECTED) - throw new Injexception("Didn't replace the expected amount of method calls"); + throw new InjectException("Didn't replace the expected amount of method calls"); } } diff --git a/src/main/java/com/openosrs/injector/injectors/raw/ScriptVM.java b/src/main/java/com/openosrs/injector/injectors/raw/ScriptVM.java index 85cbb08..2486a84 100644 --- a/src/main/java/com/openosrs/injector/injectors/raw/ScriptVM.java +++ b/src/main/java/com/openosrs/injector/injectors/raw/ScriptVM.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors.raw; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.AbstractInjector; import java.util.HashSet; @@ -71,7 +71,7 @@ public class ScriptVM extends AbstractInjector super(inject); } - public void inject() throws Injexception + public void inject() throws InjectException { final ClassGroup vanilla = inject.getVanilla(); @@ -188,7 +188,7 @@ public class ScriptVM extends AbstractInjector // This has to run after the first loop because it relies on instructionArrayLocalVar being set if (instructionArrayLocalVar == null) { - throw new Injexception("Unable to find local instruction array"); + throw new InjectException("Unable to find local instruction array"); } for (InstructionContext instrCtx : methodContext.getInstructionContexts()) { @@ -227,8 +227,8 @@ public class ScriptVM extends AbstractInjector int outerSciptIdx = scriptStores.stream() .mapToInt(AStore::getVariableIndex) .reduce(Math::min) - .orElseThrow(() -> new Injexception("Unable to find any Script AStores in runScript")); - log.debug("Found script index {}", outerSciptIdx); + .orElseThrow(() -> new InjectException("Unable to find any Script AStores in runScript")); + log.debug("[DEBUG] Found script index {}", outerSciptIdx); ListIterator instrIter = instrs.getInstructions().listIterator(); while (instrIter.hasNext()) @@ -253,9 +253,9 @@ public class ScriptVM extends AbstractInjector { if (pcLocalVar == null) { - throw new Injexception("Unable to find ILoad for invokedFromPc IStore"); + throw new InjectException("Unable to find ILoad for invokedFromPc IStore"); } - log.debug("Found pc index {}", pcLocalVar); + log.debug("[DEBUG] Found pc index {}", pcLocalVar); ListIterator instrIter = instrs.getInstructions().listIterator(); while (instrIter.hasNext()) @@ -287,10 +287,10 @@ public class ScriptVM extends AbstractInjector } // Inject call to vmExecuteOpcode - log.debug("Found instruction array index {}", instructionArrayLocalVar); + log.debug("[DEBUG] Found instruction array index {}", instructionArrayLocalVar); if (currentOpcodeStore == null) { - throw new Injexception("Unable to find IStore for current opcode"); + throw new InjectException("Unable to find IStore for current opcode"); } int istorepc = instrs.getInstructions().indexOf(currentOpcodeStore); diff --git a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectGetter.java b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectGetter.java index e738e92..38f7bb4 100644 --- a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectGetter.java +++ b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectGetter.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors.rsapi; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.rsapi.RSApiMethod; import java.util.List; import net.runelite.asm.ClassFile; @@ -47,10 +47,11 @@ import net.runelite.asm.signature.Signature; public class InjectGetter { - public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Field field, Number getter) throws Injexception + public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Field field, Number getter) throws + InjectException { if (targetClass.findMethod(apiMethod.getName(), apiMethod.getSignature()) != null) - throw new Injexception("Duplicate getter method " + apiMethod.getMethod().toString()); + throw new InjectException("Duplicate getter method " + apiMethod.getMethod().toString()); final String name = apiMethod.getName(); final Signature sig = apiMethod.getSignature(); diff --git a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectInvoke.java b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectInvoke.java index 490547c..25c57d7 100644 --- a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectInvoke.java +++ b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectInvoke.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors.rsapi; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.rsapi.RSApiMethod; import java.util.List; import net.runelite.asm.ClassFile; @@ -51,11 +51,12 @@ import net.runelite.asm.signature.Signature; public class InjectInvoke { - public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Method vanillaMethod, String garbage) throws Injexception + public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Method vanillaMethod, String garbage) throws + InjectException { if (targetClass.findMethod(apiMethod.getName(), apiMethod.getSignature()) != null) { - throw new Injexception("Duplicate invoker method " + apiMethod.getMethod().toString()); + throw new InjectException("Duplicate invoker method " + apiMethod.getMethod().toString()); } final Method method = new Method(targetClass, apiMethod.getName(), apiMethod.getSignature()); diff --git a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectSetter.java b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectSetter.java index 6510af1..e2841ce 100644 --- a/src/main/java/com/openosrs/injector/injectors/rsapi/InjectSetter.java +++ b/src/main/java/com/openosrs/injector/injectors/rsapi/InjectSetter.java @@ -31,7 +31,7 @@ package com.openosrs.injector.injectors.rsapi; import com.openosrs.injector.InjectUtil; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.rsapi.RSApiMethod; import java.util.List; import net.runelite.asm.ClassFile; @@ -50,10 +50,11 @@ import net.runelite.asm.signature.Signature; public class InjectSetter { - public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Field field, Number getter) throws Injexception + public static void inject(ClassFile targetClass, RSApiMethod apiMethod, Field field, Number getter) throws + InjectException { if (targetClass.findMethod(apiMethod.getName(), apiMethod.getSignature()) != null) - throw new Injexception("Duplicate setter method " + apiMethod.getMethod().toString()); + throw new InjectException("Duplicate setter method " + apiMethod.getMethod().toString()); final String name = apiMethod.getName(); final Signature sig = apiMethod.getSignature(); diff --git a/src/main/java/com/openosrs/injector/rsapi/RSApi.java b/src/main/java/com/openosrs/injector/rsapi/RSApi.java index 694ea86..a79ffc2 100644 --- a/src/main/java/com/openosrs/injector/rsapi/RSApi.java +++ b/src/main/java/com/openosrs/injector/rsapi/RSApi.java @@ -9,7 +9,7 @@ package com.openosrs.injector.rsapi; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import java.io.File; import java.io.FileInputStream; import java.io.IOException; @@ -40,7 +40,7 @@ public class RSApi implements Iterable private ImmutableMap map; - public RSApi(FileTree classes) throws Injexception + public RSApi(FileTree classes) throws InjectException { for (File file : classes) { @@ -62,7 +62,7 @@ public class RSApi implements Iterable } catch (IOException e) { - throw new Injexception(e); + throw new InjectException(e); } } diff --git a/src/main/java/com/openosrs/injector/transformers/SourceChanger.java b/src/main/java/com/openosrs/injector/transformers/SourceChanger.java index c53b87a..7e56e46 100644 --- a/src/main/java/com/openosrs/injector/transformers/SourceChanger.java +++ b/src/main/java/com/openosrs/injector/transformers/SourceChanger.java @@ -26,14 +26,14 @@ public class SourceChanger extends InjectTransformer void transformImpl() { inject.forEachPair(this::rename); - log.info("Changed source file debug information for {} classes", n); + log.info("[INFO] Changed source file debug information for {} classes", n); } private void rename(ClassFile rsclient, ClassFile vanilla) { ++n; final String newSrc = rsclient.getSource(); - log.debug("Changing src from {} to {}", vanilla.getSource(), newSrc); + log.debug("[DEBUG] Changing src from {} to {}", vanilla.getSource(), newSrc); vanilla.setSource(newSrc); } } diff --git a/src/test/java/com/openosrs/injector/TestInjection.java b/src/test/java/com/openosrs/injector/TestInjection.java index 9d58b2c..14631cb 100644 --- a/src/test/java/com/openosrs/injector/TestInjection.java +++ b/src/test/java/com/openosrs/injector/TestInjection.java @@ -20,7 +20,7 @@ public class TestInjection extends InjectData } @Override - public void runChildInjector(Injector injector) throws Injexception + public void runChildInjector(Injector injector) throws InjectException { injector.inject(); } diff --git a/src/test/java/com/openosrs/injector/transformers/SourceChangerTest.java b/src/test/java/com/openosrs/injector/transformers/SourceChangerTest.java index 1ad48b5..18a1fcc 100644 --- a/src/test/java/com/openosrs/injector/transformers/SourceChangerTest.java +++ b/src/test/java/com/openosrs/injector/transformers/SourceChangerTest.java @@ -7,7 +7,7 @@ */ package com.openosrs.injector.transformers; -import com.openosrs.injector.Injexception; +import com.openosrs.injector.InjectException; import com.openosrs.injector.injection.InjectData; import com.openosrs.injector.injectors.Injector; import com.openosrs.injector.transformers.srcchangeclasses.NewName; @@ -37,7 +37,8 @@ public class SourceChangerTest new SourceChanger( new InjectData(new ClassGroup(), new ClassGroup(), null, null) { - public void runChildInjector(Injector injector) throws Injexception {} + public void runChildInjector(Injector injector) throws InjectException + {} @Override public void forEachPair(BiConsumer consumer)