Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AbstractInsnNode insertPoint = targetNode;
- LabelNode nweLabelNode = new LabelNode();
- InsnList toInsert = new InsnList();
- Type chatHandlerType = Type.getType(ChatHandler.class);
- String handlerDescriptor;
- try {
- handlerDescriptor = Type.getMethodDescriptor(ChatHandler.class.getMethod("hasHandledChat", IChatComponent.class));
- } catch (Exception e){
- logger.catching(e);
- return;
- }
- toInsert.add(new VarInsnNode(ALOAD, 1));
- toInsert.add(new MethodInsnNode(INVOKESTATIC, chatHandlerType.getClassName(), "hasHandledChat", handlerDescriptor, false));
- toInsert.add(new JumpInsnNode(IFNE, nweLabelNode));
- toInsert.add(nweLabelNode);
- toInsert.add(new InsnNode(RETURN));
- targetMethod.instructions.insert(insertPoint, toInsert);
Advertisement
Add Comment
Please, Sign In to add comment