mrkirby153

Untitled

May 31st, 2015
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1.  if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
  2.                 ItemStack stack = event.getItem();
  3.                 if (stack == null)
  4.                     return;
  5.                 int actionId = ItemManager.getActionId(stack);
  6.                 if (actionId == ItemManager.INVALID_ITEM_ID)
  7.                     return;
  8.                 // Execute the class
  9.                 for (Method m : this.getClass().getMethods()) {
  10.                     Annotation[] methodAnnotations = m.getDeclaredAnnotations();
  11.                     for (Annotation a : methodAnnotations) {
  12.                         if (a instanceof ItemAction) {
  13.                             ItemAction action = (ItemAction) a;
  14.                             if (action.actionId() == actionId) {
  15.                                 try {
  16.                                     event.setCancelled(true);
  17.                                     m.invoke(this);
  18.                                     return;
  19.                                 } catch (Exception e) {
  20.                                     event.getPlayer().sendMessage(ChatColor.RED + "We were unable to process that action! Please contact a developer");
  21.                                 }
  22.                             }
  23.                         }
  24.                     }
  25.                 }
  26.             }
Advertisement
Add Comment
Please, Sign In to add comment