Advertisement
Guest User

Untitled

a guest
Apr 26th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1. public void reset(int arenaID) {
  2. final Arena arena = this.getArena(arenaID);
  3. new BukkitRunnable() {
  4. @Override
  5. public void run() {
  6. final YamlConfiguration config = Plae.getConfigManager().getArenaConfig(arena.getID());
  7. final Location loc1 = new Location(Bukkit.getWorld(config.getString("Lobby.GameWorld")), config.getDouble("Lobby.ResetWorld.Point1.X"), config.getDouble("Lobby.ResetWorld.Point1.Y"), config.getDouble("Lobby.ResetWorld.Point1.Z"));
  8. final Location loc2 = new Location(Bukkit.getWorld(config.getString("Lobby.GameWorld")), config.getDouble("Lobby.ResetWorld.Point2.X"), config.getDouble("Lobby.ResetWorld.Point2.Y"), config.getDouble("Lobby.ResetWorld.Point2.Z"));
  9. final int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
  10. final int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
  11. final int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
  12. final int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
  13. final int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
  14. final int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
  15. double tick = 0;
  16.  
  17. for (int x = minX; x <= maxX; x++) {
  18. for (int y = minY; y <= maxY; y++) {
  19. for (int z = minZ; z <= maxZ; z++) {
  20. if (!loc1.getWorld().getChunkAt(x, z).isLoaded()) {
  21. loc1.getWorld().getChunkAt(x, z).load();
  22. }
  23. final Block block = loc1.getWorld().getBlockAt(x, y, z);
  24. if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) {
  25. block.setType(Material.AIR);
  26. }
  27. }
  28. }
  29. }
  30.  
  31. for (int x = minX; x <= maxX; x++) {
  32. for (int y = minY; y <= maxY; y++) {
  33. for (int z = minZ; z <= maxZ; z++) {
  34. //if (!loc1.getWorld().getChunkAt(x, z).isLoaded())
  35. // loc1.getWorld().getChunkAt(x, z).load();
  36. final Block block = loc1.getWorld().getBlockAt(x, y, z);
  37. if (block.getType() != Material.AIR) {
  38. tick = tick + 0.001;
  39. long tickInt = (long) tick;
  40. if (tickInt % 2 == 0) {
  41. tickInt = tickInt - 1;
  42. }
  43. final long tickF = tickInt;
  44. new BukkitRunnable() {
  45. @Override
  46. public void run() {
  47. block.setType(Material.AIR);
  48. }
  49. }.runTaskLater(Plae.getInstance(), tickF);
  50. }
  51. }
  52. }
  53. }
  54.  
  55. tick = tick + 60;
  56. Plae.getMessageUtil().debug("Arena " + arena.getID() + " reset will be completed in " + tick / 20 + " seconds!");
  57. final int tickF = (int) tick;
  58. new BukkitRunnable() {
  59. @Override
  60. public void run() {
  61. File file = new File("Plae Settings/Schematics/" + Plae.getConfigManager().getArenaConfig(arena.getID()).getString("Lobby.ResetWorld.File"));
  62. World world = Bukkit.getWorld(Plae.getConfigManager().getArenaConfig(arena.getID()).getString("Lobby.GameWorld"));
  63. try {
  64. final Vector v = new Vector(Plae.getConfigManager().getArenaConfig(arena.getID()).getInt("Lobby.ResetWorld.X"), Plae.getConfigManager().getArenaConfig(arena.getID()).getInt("Lobby.ResetWorld.Y"), Plae.getConfigManager().getArenaConfig(arena.getID()).getInt("Lobby.ResetWorld.Z"));
  65. final BukkitWorld BWf = new BukkitWorld(world);
  66. final EditSession es = new EditSession(BWf, 9999999);
  67. final CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file);
  68. for (Entity entity : world.getEntities()) {
  69. if (!(entity instanceof Player)) {
  70. entity.remove();
  71. }
  72. }
  73. c1.place(es, v, true);
  74.  
  75. } catch (Exception ex) {
  76. }
  77. }
  78. }.runTaskLater(Plae.getInstance(), (long) tick);
  79. }
  80. }.runTaskLater(Plae.getInstance(), 80);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement