Advertisement
Guest User

Minecraft Bukkit Coding Rgen One Block At A Time

a guest
May 24th, 2016
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public class BlockRegen extends JavaPlugin implements Listener {
  2.  
  3. public void onEnable() {
  4. Bukkit.getServer().getPluginManager().registerEvents(this, this);
  5. }
  6.  
  7. @EventHandler
  8. public void onEntityExplode(EntityExplodeEvent e) {
  9. if (!e.blockList().isEmpty()) {
  10. final List<BlockState> blocks = new ArrayList<BlockState>();
  11. for (Block b : e.blockList()) {
  12. if (b.getType() != Material.AIR) {
  13. if (!blocks.contains(b.getState())) {
  14. blocks.add(b.getState());
  15. b.setType(Material.AIR);
  16.  
  17.  
  18. }
  19. }
  20. }
  21. new BukkitRunnable() {
  22. int i = 17;
  23. public void run() {
  24. if (i>0){
  25. i--;
  26. }else{
  27. regen(blocks, false, 5);
  28. this.cancel();
  29. }
  30. }
  31. }.runTaskTimer(this, 3, 3);
  32. }
  33. }
  34.  
  35. protected void regen(List<BlockState> blocks, boolean effect, int speed) {
  36. new BukkitRunnable() {
  37. int i = -1;
  38. @SuppressWarnings("deprecation")
  39. public void run() {
  40. if (i != blocks.size()-1) {
  41. i++;
  42. BlockState bs = blocks.get(i);
  43. bs.getBlock().setType(bs.getType());
  44. bs.getBlock().setData(bs.getData().getData());
  45.  
  46. bs.getBlock().getWorld().playEffect(bs.getLocation(), Effect.STEP_SOUND, bs.getBlock().getType());
  47. bs.getBlock().getWorld().playEffect(bs.getLocation(), Effect.STEP_SOUND, bs.getBlock().getData());
  48.  
  49.  
  50.  
  51.  
  52. }
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement