Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void reset(int arenaID) {
- final Arena arena = this.getArena(arenaID);
- new BukkitRunnable() {
- @Override
- public void run() {
- final YamlConfiguration config = Plae.getConfigManager().getArenaConfig(arena.getID());
- 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"));
- 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"));
- final int minX = Math.min(loc1.getBlockX(), loc2.getBlockX());
- final int minY = Math.min(loc1.getBlockY(), loc2.getBlockY());
- final int minZ = Math.min(loc1.getBlockZ(), loc2.getBlockZ());
- final int maxX = Math.max(loc1.getBlockX(), loc2.getBlockX());
- final int maxY = Math.max(loc1.getBlockY(), loc2.getBlockY());
- final int maxZ = Math.max(loc1.getBlockZ(), loc2.getBlockZ());
- double tick = 0;
- for (int x = minX; x <= maxX; x++) {
- for (int y = minY; y <= maxY; y++) {
- for (int z = minZ; z <= maxZ; z++) {
- if (!loc1.getWorld().getChunkAt(x, z).isLoaded()) {
- loc1.getWorld().getChunkAt(x, z).load();
- }
- final Block block = loc1.getWorld().getBlockAt(x, y, z);
- if (block.getType() == Material.WATER || block.getType() == Material.STATIONARY_WATER || block.getType() == Material.LAVA || block.getType() == Material.STATIONARY_LAVA) {
- block.setType(Material.AIR);
- }
- }
- }
- }
- for (int x = minX; x <= maxX; x++) {
- for (int y = minY; y <= maxY; y++) {
- for (int z = minZ; z <= maxZ; z++) {
- //if (!loc1.getWorld().getChunkAt(x, z).isLoaded())
- // loc1.getWorld().getChunkAt(x, z).load();
- final Block block = loc1.getWorld().getBlockAt(x, y, z);
- if (block.getType() != Material.AIR) {
- tick = tick + 0.001;
- long tickInt = (long) tick;
- if (tickInt % 2 == 0) {
- tickInt = tickInt - 1;
- }
- final long tickF = tickInt;
- new BukkitRunnable() {
- @Override
- public void run() {
- block.setType(Material.AIR);
- }
- }.runTaskLater(Plae.getInstance(), tickF);
- }
- }
- }
- }
- tick = tick + 60;
- Plae.getMessageUtil().debug("Arena " + arena.getID() + " reset will be completed in " + tick / 20 + " seconds!");
- final int tickF = (int) tick;
- new BukkitRunnable() {
- @Override
- public void run() {
- File file = new File("Plae Settings/Schematics/" + Plae.getConfigManager().getArenaConfig(arena.getID()).getString("Lobby.ResetWorld.File"));
- World world = Bukkit.getWorld(Plae.getConfigManager().getArenaConfig(arena.getID()).getString("Lobby.GameWorld"));
- try {
- 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"));
- final BukkitWorld BWf = new BukkitWorld(world);
- final EditSession es = new EditSession(BWf, 9999999);
- final CuboidClipboard c1 = SchematicFormat.MCEDIT.load(file);
- for (Entity entity : world.getEntities()) {
- if (!(entity instanceof Player)) {
- entity.remove();
- }
- }
- c1.place(es, v, true);
- } catch (Exception ex) {
- }
- }
- }.runTaskLater(Plae.getInstance(), (long) tick);
- }
- }.runTaskLater(Plae.getInstance(), 80);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement