mrkirby153

Untitled

Sep 9th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. AbstractInsnNode insertPoint = targetNode;
  2. LabelNode nweLabelNode = new LabelNode();
  3. InsnList toInsert = new InsnList();
  4. Type chatHandlerType = Type.getType(ChatHandler.class);
  5. String handlerDescriptor;
  6. try {
  7. handlerDescriptor = Type.getMethodDescriptor(ChatHandler.class.getMethod("hasHandledChat", IChatComponent.class));
  8. } catch (Exception e){
  9. logger.catching(e);
  10. return;
  11. }
  12. toInsert.add(new VarInsnNode(ALOAD, 1));
  13. toInsert.add(new MethodInsnNode(INVOKESTATIC, chatHandlerType.getClassName(), "hasHandledChat", handlerDescriptor, false));
  14. toInsert.add(new JumpInsnNode(IFNE, nweLabelNode));
  15. toInsert.add(nweLabelNode);
  16. toInsert.add(new InsnNode(RETURN));
  17. targetMethod.instructions.insert(insertPoint, toInsert);
Advertisement
Add Comment
Please, Sign In to add comment