use of net.runelite.api.events.ScriptCallbackEvent in project runelite by runelite.
the class ScriptVMMixin method vmExecuteOpcode.
// Call is injected into runScript by the ScriptVM raw injector
@Inject
static boolean vmExecuteOpcode(int opcode) {
if (opcode == RUNELITE_EXECUTE) {
assert currentScript.getInstructions()[currentScriptPC] == RUNELITE_EXECUTE;
int stringStackSize = client.getStringStackSize();
String stringOp = client.getStringStack()[--stringStackSize];
client.setStringStackSize(stringStackSize);
if ("debug".equals(stringOp)) {
int intStackSize = client.getIntStackSize();
String fmt = client.getStringStack()[--stringStackSize];
StringBuffer out = new StringBuffer();
Matcher m = Pattern.compile("%(.)").matcher(fmt);
for (; m.find(); ) {
m.appendReplacement(out, "");
switch(m.group(1).charAt(0)) {
case 'i':
case 'd':
out.append(client.getIntStack()[--intStackSize]);
break;
case 's':
out.append(client.getStringStack()[--stringStackSize]);
break;
default:
out.append(m.group(0)).append("=unknown");
}
}
m.appendTail(out);
Hooks.log.debug(out.toString());
client.setStringStackSize(stringStackSize);
client.setIntStackSize(intStackSize);
return true;
}
ScriptCallbackEvent event = new ScriptCallbackEvent();
event.setScript(currentScript);
event.setEventName(stringOp);
Hooks.eventBus.post(event);
return true;
}
return false;
}
Aggregations