Ejemplo n.º 1
0
  @EventHandler(priority = EventPriority.NORMAL)
  public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.isCancelled()) return;

    if (event.getAction() == org.bukkit.event.block.Action.LEFT_CLICK_BLOCK
        || event.getAction() == org.bukkit.event.block.Action.RIGHT_CLICK_BLOCK) {
      PlayerEvent playerEvent;
      if (SignUtil.isSign(event.getClickedBlock())) {
        playerEvent =
            new PlayerEvent(
                SignUtil.getSign(event.getClickedBlock()),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      } else {
        playerEvent =
            new PlayerEvent(
                event.getClickedBlock(),
                event.getAction() == Action.LEFT_CLICK_BLOCK
                    ? PlayerEvent.Action.LEFT_CLICK
                    : PlayerEvent.Action.RIGHT_CLICK,
                event.getPlayer(),
                event);
      }
      mechanicsHandler.callPlayerEvent(playerEvent);
    }
  }
Ejemplo n.º 2
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onBlockBreak(BlockBreakEvent event) {
   if (event.isCancelled()) return;
   PlayerEvent playerEvent;
   if (SignUtil.isSign(event.getBlock())) {
     playerEvent =
         new PlayerEvent(
             SignUtil.getSign(event.getBlock()),
             PlayerEvent.Action.BREAK,
             event.getPlayer(),
             event);
   } else {
     playerEvent =
         new PlayerEvent(event.getBlock(), PlayerEvent.Action.BREAK, event.getPlayer(), event);
   }
   mechanicsHandler.callPlayerEvent(playerEvent);
   event.setCancelled(playerEvent.isCancelled());
 }