Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (event.getAction().equals(Action.RIGHT_CLICK_AIR) || event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- ItemStack stack = event.getItem();
- if (stack == null)
- return;
- int actionId = ItemManager.getActionId(stack);
- if (actionId == ItemManager.INVALID_ITEM_ID)
- return;
- // Execute the class
- for (Method m : this.getClass().getMethods()) {
- Annotation[] methodAnnotations = m.getDeclaredAnnotations();
- for (Annotation a : methodAnnotations) {
- if (a instanceof ItemAction) {
- ItemAction action = (ItemAction) a;
- if (action.actionId() == actionId) {
- try {
- event.setCancelled(true);
- m.invoke(this);
- return;
- } catch (Exception e) {
- event.getPlayer().sendMessage(ChatColor.RED + "We were unable to process that action! Please contact a developer");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment