Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.supertree.tree;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.EventPriority;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.BlockBreakEvent;
- public class WoodCut implements Listener {
- @SuppressWarnings("deprecation")
- @EventHandler(priority = EventPriority.NORMAL)
- public void onCut(BlockBreakEvent e) {
- if(e.getBlock().getType() == Material.LOG || e.getBlock().getType() == Material.LOG_2) {
- e.setCancelled(true);
- boolean inWood = false;
- int count = 0;
- for(int y = -13;y<= 13; y++) {
- Location loc = e.getBlock().getLocation().add(0, y, 0);
- if(loc.getBlock().getType() == Material.LOG || loc.getBlock().getType() == Material.LOG_2) {
- count++;
- if(!inWood) {
- inWood = true;
- }
- loc.getBlock().breakNaturally();
- } else {
- if(count >= 1) {
- if(inWood) {
- loc.getWorld().spawnFallingBlock(loc.subtract(0, 1, 0), Material.SAPLING, (byte)0);
- return;
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement