Advertisement
Guest User

BlockRegen

a guest
May 30th, 2016
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package blockregen;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.block.Block;
  7. import org.bukkit.block.BlockState;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.entity.EntityExplodeEvent;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13.  
  14. public class BlockRegen extends JavaPlugin implements Listener {
  15.  
  16. public void onEnable(){
  17. Bukkit.getServer().getLogger().info(ChatColor.RED + "BlockRegen v1.1 enabled");
  18. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  19. }
  20.  
  21. @EventHandler
  22. public void onEntityExplode(EntityExplodeEvent e) {
  23. for (Block b : e.blockList()){
  24. final BlockState state = b.getState();
  25.  
  26. b.setType(Material.AIR);
  27.  
  28. int delay = 100;
  29.  
  30. if ((b.getType() == Material.SAND) || (b.getType() == Material.GRAVEL)){
  31. delay += 1;
  32. if ((b.getType() == Material.SIGN))
  33. delay +=1;
  34.  
  35. }
  36. Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
  37.  
  38. public void run(){
  39. state.update(true, false);
  40.  
  41. }
  42. }
  43.  
  44. , delay);
  45. }
  46. }
  47. }
Advertisement
RAW Paste Data Copied
Advertisement