Esempio n. 1
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());
 }
Esempio n. 2
0
 @Override
 public void onPlayerRightClickSign(PlayerEvent event) {
   String activator = event.getMechanicIdentifier();
   BlockFace direction =
       activator.equals("[Lift Up]")
           ? BlockFace.UP
           : (activator.equals("[Lift Down]") ? BlockFace.DOWN : null);
   int maxSearchHeight = config.getMaxSearchHeight();
   if (direction == BlockFace.DOWN || direction == BlockFace.UP) {
     Block block;
     for (int dy = 1; dy < maxSearchHeight; dy++) {
       block = event.getBlock().getRelative(0, (direction == BlockFace.UP ? dy : -dy), 0);
       if (SignUtil.isSign(block)) {
         String id = SignUtil.getMechanicsIdentifier(SignUtil.getSign(block));
         if (id.equals("[Lift]") || id.equals("[Lift Up]") || id.equals("[Lift Down]")) {
           movePlayer(block, event.getPlayer());
         }
       }
     }
   }
 }