Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. public class BlockRegen implements Listener {
  2.  
  3. public static ArrayList<Block> block = new ArrayList<Block>();
  4.  
  5. @EventHandler
  6. public void onBlockBreak(BlockBreakEvent e)
  7. {
  8. Player p = (Player) e.getPlayer();
  9. Block b = e.getBlock();
  10. timer(b, Material.GOLD_ORE);
  11. e.setCancelled(true);
  12. b.setType(Material.COBBLESTONE);
  13. block.add(b);
  14. for(ItemStack is : b.getDrops())
  15. {
  16. p.getInventory().addItem(is);
  17. }
  18. b.getDrops().clear();
  19. }
  20.  
  21. public void timer(final Block b, final Material m)
  22. {
  23. Bukkit.getScheduler().runTaskLater(TowerInvasion.plugin, new Runnable()
  24. {
  25. public void run()
  26. {
  27. b.setType(m);
  28. block.remove(b);
  29. }
  30. }
  31. , 600L);
  32. }
  33.  
  34. @EventHandler
  35. public void onBlockBreak2(BlockBreakEvent e)
  36. {
  37. Block b = e.getBlock();
  38. if(block.contains(b))
  39. e.setCancelled(true);
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement