Advertisement
Mysteryem

Treefeller like behaviour for Bukkit listener

May 12th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1.   // You may want to specify the priority for this listener
  2.   @EventHandler
  3.   public void onblockBreak(BlockBreakEvent event) {
  4.     if (!event.isCancelled()) {
  5.       Block brokenBlock = event.getBlock();
  6.        if (brokenBlock.getType() == Material.LOG || brokenBlock.getType() == Material.LOG_2) {
  7.         breakAboveLogs(brokenBlock);
  8.       }
  9.     }
  10.   }
  11.  
  12.   private void breakAboveLogs(Block block) {
  13.     Location loc = block.getLocation();
  14.     loc.add(0, 1, 0);
  15.     Block aboveBlock = block.getWorld().getBlockAt(loc);
  16.     if (aboveBlock.getType() == Material.LOG || aboveBlock.getType() == Material.LOG_2) {
  17.       aboveBlock.breakNaturally();
  18.       breakAboveLogs(aboveBlock);
  19.     }
  20.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement