Add getters for before-ly-hooked fields
This commit is contained in:
@@ -303,7 +303,7 @@ public class Inject
|
|||||||
apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false);
|
apiMethod = findImportMethodOnApi(targetApiClass, exportedName, false);
|
||||||
if (apiMethod == null)
|
if (apiMethod == null)
|
||||||
{
|
{
|
||||||
// logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName);
|
//logger.debug("Unable to find import method on api class {} with imported name {}, not injecting getter", targetApiClass, exportedName);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,9 +41,11 @@ import net.runelite.asm.attributes.code.instruction.types.SetFieldInstruction;
|
|||||||
import net.runelite.asm.attributes.code.instructions.ArrayStore;
|
import net.runelite.asm.attributes.code.instructions.ArrayStore;
|
||||||
import net.runelite.asm.attributes.code.instructions.CheckCast;
|
import net.runelite.asm.attributes.code.instructions.CheckCast;
|
||||||
import net.runelite.asm.attributes.code.instructions.Dup;
|
import net.runelite.asm.attributes.code.instructions.Dup;
|
||||||
|
import net.runelite.asm.attributes.code.instructions.IMul;
|
||||||
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
import net.runelite.asm.attributes.code.instructions.InvokeStatic;
|
||||||
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
|
import net.runelite.asm.attributes.code.instructions.InvokeVirtual;
|
||||||
import net.runelite.asm.attributes.code.instructions.LDC;
|
import net.runelite.asm.attributes.code.instructions.LDC;
|
||||||
|
import net.runelite.asm.attributes.code.instructions.LMul;
|
||||||
import net.runelite.asm.attributes.code.instructions.PutField;
|
import net.runelite.asm.attributes.code.instructions.PutField;
|
||||||
import net.runelite.asm.attributes.code.instructions.Swap;
|
import net.runelite.asm.attributes.code.instructions.Swap;
|
||||||
import net.runelite.asm.execution.Execution;
|
import net.runelite.asm.execution.Execution;
|
||||||
@@ -63,6 +65,7 @@ public class InjectHook
|
|||||||
String clazz;
|
String clazz;
|
||||||
Method method;
|
Method method;
|
||||||
boolean before;
|
boolean before;
|
||||||
|
Number getter;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String HOOK_METHOD_SIGNATURE = "(I)V";
|
private static final String HOOK_METHOD_SIGNATURE = "(I)V";
|
||||||
@@ -154,7 +157,7 @@ public class InjectHook
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// idx + 1 to insert after the set
|
// idx + 1 to insert after the set
|
||||||
injectCallback(ins, idx + 1, hookInfo, null, objectStackContext);
|
injectCallback(ins, idx + 1, hookInfo, null, objectStackContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -262,6 +265,22 @@ public class InjectHook
|
|||||||
ins.getInstructions().add(idx++, new Dup(ins)); // dup value
|
ins.getInstructions().add(idx++, new Dup(ins)); // dup value
|
||||||
idx = recursivelyPush(ins, idx, object);
|
idx = recursivelyPush(ins, idx, object);
|
||||||
ins.getInstructions().add(idx++, new Swap(ins));
|
ins.getInstructions().add(idx++, new Swap(ins));
|
||||||
|
if (hookInfo.getter != null)
|
||||||
|
{
|
||||||
|
assert hookInfo.getter instanceof Integer || hookInfo.getter instanceof Long;
|
||||||
|
|
||||||
|
if (hookInfo.getter instanceof Integer)
|
||||||
|
{
|
||||||
|
ins.getInstructions().add(new LDC(ins, (int) hookInfo.getter));
|
||||||
|
ins.getInstructions().add(new IMul(ins));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ins.getInstructions().add(new LDC(ins, (long) hookInfo.getter));
|
||||||
|
ins.getInstructions().add(new LMul(ins));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
if (!value.type.equals(methodArgumentType))
|
if (!value.type.equals(methodArgumentType))
|
||||||
{
|
{
|
||||||
CheckCast checkCast = new CheckCast(ins);
|
CheckCast checkCast = new CheckCast(ins);
|
||||||
|
|||||||
@@ -909,6 +909,13 @@ public class MixinInjector
|
|||||||
throw new InjectionException("Field hook for nonexistent field " + hookName + " on " + method);
|
throw new InjectionException("Field hook for nonexistent field " + hookName + " on " + method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Annotation an = targetField.getAnnotations().find(DeobAnnotations.OBFUSCATED_GETTER);
|
||||||
|
Number getter = null;
|
||||||
|
if (an != null)
|
||||||
|
{
|
||||||
|
getter = (Number) an.getElement().getValue();
|
||||||
|
}
|
||||||
|
|
||||||
Field obField = inject.toObField(targetField);
|
Field obField = inject.toObField(targetField);
|
||||||
|
|
||||||
if (method.isStatic() != targetField.isStatic())
|
if (method.isStatic() != targetField.isStatic())
|
||||||
@@ -922,6 +929,7 @@ public class MixinInjector
|
|||||||
hookInfo.fieldName = hookName;
|
hookInfo.fieldName = hookName;
|
||||||
hookInfo.method = method;
|
hookInfo.method = method;
|
||||||
hookInfo.before = before;
|
hookInfo.before = before;
|
||||||
|
hookInfo.getter = getter;
|
||||||
injectHook.hook(obField, hookInfo);
|
injectHook.hook(obField, hookInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -448,9 +448,7 @@ public class SpellbookPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CHECKSTYLE:OFF
|
// CHECKSTYLE:OFF
|
||||||
Collection<Spell> gson = GSON.fromJson(cfg, new TypeToken<List<Spell>>()
|
Collection<Spell> gson = GSON.fromJson(cfg, new TypeToken<List<Spell>>() {}.getType());
|
||||||
{
|
|
||||||
}.getType());
|
|
||||||
// CHECKSTYLE:ON
|
// CHECKSTYLE:ON
|
||||||
gson.stream().filter(Objects::nonNull).forEach(s -> spells.put(s.getWidget(), s));
|
gson.stream().filter(Objects::nonNull).forEach(s -> spells.put(s.getWidget(), s));
|
||||||
|
|
||||||
@@ -465,7 +463,7 @@ public class SpellbookPlugin extends Plugin
|
|||||||
|
|
||||||
private void saveSpells()
|
private void saveSpells()
|
||||||
{
|
{
|
||||||
if (spells.isEmpty())
|
if (spells.isEmpty() || tmp == null || tmp.isEmpty())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,6 +258,11 @@ public abstract class RSWidgetMixin implements RSWidget
|
|||||||
|
|
||||||
for (int i = 0; i < itemIds.length; ++i)
|
for (int i = 0; i < itemIds.length; ++i)
|
||||||
{
|
{
|
||||||
|
if (itemIds[i] <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
WidgetItem item = getWidgetItem(i);
|
WidgetItem item = getWidgetItem(i);
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
@@ -287,19 +292,17 @@ public abstract class RSWidgetMixin implements RSWidget
|
|||||||
int itemId = itemIds[index];
|
int itemId = itemIds[index];
|
||||||
int itemQuantity = itemQuantities[index];
|
int itemQuantity = itemQuantities[index];
|
||||||
|
|
||||||
Point widgetCanvasLocation = getCanvasLocation();
|
if (columns <= 0)
|
||||||
|
|
||||||
if (itemId <= 0 || itemQuantity <= 0 || columns <= 0)
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
int row = index / columns;
|
int row = index / columns;
|
||||||
int col = index % columns;
|
int col = index % columns;
|
||||||
int itemX = widgetCanvasLocation.getX() + ((ITEM_SLOT_SIZE + xPitch) * col);
|
int itemX = rl$x + ((ITEM_SLOT_SIZE + xPitch) * col);
|
||||||
int itemY = widgetCanvasLocation.getY() + ((ITEM_SLOT_SIZE + yPitch) * row);
|
int itemY = rl$y + ((ITEM_SLOT_SIZE + yPitch) * row);
|
||||||
|
|
||||||
Rectangle bounds = new Rectangle(itemX - 1, itemY - 1, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
Rectangle bounds = new Rectangle(itemX, itemY, ITEM_SLOT_SIZE, ITEM_SLOT_SIZE);
|
||||||
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
return new WidgetItem(itemId - 1, itemQuantity, index, bounds, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4710,7 +4710,7 @@ public final class Client extends GameShell implements Usernamed {
|
|||||||
int var8;
|
int var8;
|
||||||
if(!isMenuOpen) {
|
if(!isMenuOpen) {
|
||||||
if(__client_lq != -1) {
|
if(__client_lq != -1) {
|
||||||
class39.method741(__client_lq, __client_ln);
|
class39.drawMenuActionTextAt(__client_lq, __client_ln);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var1 = class25.menuX;
|
var1 = class25.menuX;
|
||||||
|
|||||||
@@ -767,7 +767,8 @@ public class class39 extends class21 {
|
|||||||
signature = "(IIB)V",
|
signature = "(IIB)V",
|
||||||
garbageValue = "3"
|
garbageValue = "3"
|
||||||
)
|
)
|
||||||
static final void method741(int var0, int var1) {
|
@Export("drawMenuActionTextAt")
|
||||||
|
static final void drawMenuActionTextAt(int var0, int var1) {
|
||||||
if(Client.menuOptionsCount >= 2 || Client.isItemSelected != 0 || Client.isSpellSelected) {
|
if(Client.menuOptionsCount >= 2 || Client.isItemSelected != 0 || Client.isSpellSelected) {
|
||||||
if(Client.showMouseOverText) {
|
if(Client.showMouseOverText) {
|
||||||
int var2 = Client.menuOptionsCount - 1;
|
int var2 = Client.menuOptionsCount - 1;
|
||||||
@@ -790,10 +791,10 @@ public class class39 extends class21 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(Client.menuOptionsCount > 2) {
|
if(Client.menuOptionsCount > 2) {
|
||||||
var4 = var4 + BufferedFile.colorStartTag(16777215) + " " + '/' + " " + (Client.menuOptionsCount - 2) + " more options";
|
var4 = var4 + BufferedFile.colorStartTag(0xffffff) + " " + '/' + " " + (Client.menuOptionsCount - 2) + " more options";
|
||||||
}
|
}
|
||||||
|
|
||||||
class2.fontBold12.drawRandomAlphaAndSpacing(var4, var0 + 4, var1 + 15, 16777215, 0, Client.cycle / 1000);
|
class2.fontBold12.drawRandomAlphaAndSpacing(var4, var0 + 4, var1 + 15, 0xffffff, 0, Client.cycle / 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user