Пример #1
0
 @EventHandler
 public void onBlockBreak(BlockChangeEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getCause() instanceof PlayerBreakCause)) {
     return;
   }
   PlayerCause pcause = (PlayerCause) event.getCause();
   BlockBreakEvent breakEvent =
       new BlockBreakEvent(
           BukkitUtil.fromBlock(event.getBlock()), new BridgePlayer(pcause.getSource()));
   Bukkit.getPluginManager().callEvent(breakEvent);
   event.setCancelled(breakEvent.isCancelled());
   // TODO finish onBlockBreak, exp drops and such!
 }
Пример #2
0
 @EventHandler
 public void onBlockPlace(BlockChangeEvent event) {
   if (event.isCancelled()) {
     return;
   }
   if (!(event.getCause() instanceof PlayerPlacementCause)) {
     return;
   }
   PlayerPlacementCause pcause = (PlayerPlacementCause) event.getCause();
   // todo finish onBlockPlace
   // PlayerInventory pinv = pcause.getSource().get(PlayerInventory.class);
   // BlockPlaceEvent breakEvent = new BlockPlaceEvent(BukkitUtil.fromBlock(event.getBlock()),
   // null,null,BukkitUtil.fromItemStack(pinv.getQuickbar().getCurrentItem()), new
   // BridgePlayer(pcause.getSource()), event.isCancelled());
   // Bukkit.getPluginManager().callEvent(breakEvent);
   // event.setCancelled(breakEvent.isCancelled());
 }