Merge branch 'development' into feature/override-randoms

This commit is contained in:
Jeroen Ketelaar
2018-09-11 10:41:39 -05:00
committed by GitHub
3 changed files with 30 additions and 17 deletions
@@ -40,17 +40,19 @@ public class AddCallbackAdapter implements Injectable, Opcodes {
Label l0 = new Label();
inject.add(new LabelNode(l0));
int offset = 0;
for (int arg : args) {
if (Modifier.isStatic(method.access)) {
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
.getDescriptor());
inject.add(new VarInsnNode(loadOpcode, arg + offset));
if (loadOpcode == Opcodes.LLOAD) {
offset++;
if (args != null) {
for (int arg : args) {
if (Modifier.isStatic(method.access)) {
int loadOpcode = ASMUtils.getLoadOpcode(types[arg]
.getDescriptor());
inject.add(new VarInsnNode(loadOpcode, arg + offset));
if (loadOpcode == Opcodes.LLOAD) {
offset++;
}
} else {
inject.add(new VarInsnNode(ASMUtils.getLoadOpcode(types[arg]
.getDescriptor()), arg + 1));
}
} else {
inject.add(new VarInsnNode(ASMUtils.getLoadOpcode(types[arg]
.getDescriptor()), arg + 1));
}
}
inject.add(new MethodInsnNode(INVOKESTATIC,
@@ -26,14 +26,16 @@ public class Callback implements Injectable {
this.invokeMethod = callbackMethod;
this.desc = callbackDesc;
this.conditional = conditional;
if (args.contains(",")) {
final String[] strArgs = args.split(",");
this.args = new int[strArgs.length];
for (int i = 0; i < this.args.length; i++) {
this.args[i] = Integer.parseInt(strArgs[i]);
if (args.length() > 0) {
if (args.contains(",")) {
final String[] strArgs = args.split(",");
this.args = new int[strArgs.length];
for (int i = 0; i < this.args.length; i++) {
this.args[i] = Integer.parseInt(strArgs[i]);
}
} else {
this.args = new int[]{Integer.parseInt(args)};
}
} else {
this.args = new int[]{ Integer.parseInt(args) };
}
}
@@ -65,8 +65,17 @@ public class XMLHookParser extends HookParser {
}
private static final String getValue(String tag, Element element) {
if (element.getElementsByTagName(tag).item(0) == null) {
throw new NullPointerException("MISSING HOOK TAG: The '" + tag + "' xml tag is missing from one of the hooks of type: " + element.getParentNode().getNodeName());
}
NodeList nodes = element.getElementsByTagName(tag).item(0)
.getChildNodes();
if (nodes.getLength() == 0 || nodes.item(0) == null) {
if (Core.inVerboseMode()) {
System.err.println("WARNING: Invalid Hook " + tag + " subnode. Tag is missing or empty?");
}
return "";
}
Node node = (Node) nodes.item(0);
return node.getNodeValue();
}