diff --git a/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java b/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java deleted file mode 100644 index 08419927..00000000 --- a/src/main/java/com/songoda/skyblock/biome/ChunkBiomeSplitter.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.songoda.skyblock.biome; - -import com.songoda.skyblock.SkyBlock; -import com.songoda.skyblock.blockscanner.BlockInfo; -import com.songoda.skyblock.blockscanner.BlockScanner; -import org.bukkit.Bukkit; -import org.bukkit.Chunk; -import org.bukkit.ChunkSnapshot; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; -import org.bukkit.scheduler.BukkitRunnable; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.concurrent.CompletableFuture; - -public class ChunkBiomeSplitter extends BukkitRunnable { - - private final Map> snapshots; - private Queue blocks; - private final Biome biome; - private Chunk lastChunk; - private ChunkBiomeTask task; - - private ChunkBiomeSplitter(Map> snapshots, Biome biome, ChunkBiomeTask task) { - this.task = task; - this.snapshots = snapshots; - this.biome = biome; - lastChunk = null; - start(); - } - - private void start() { - Bukkit.getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), () -> { - BlockScanner.startScanner(snapshots, true, true, true, (blocks) -> { - this.blocks = blocks; - this.runTaskTimer(SkyBlock.getInstance(), 2L, 2L); - }); - }); - } - - @Override - public void run() { - - int updateAmount = 0; - - for (Iterator it = blocks.iterator(); it.hasNext();) { - - if (updateAmount == 3500) break; - - final BlockInfo pair = it.next(); - final Block block = pair.getWorld().getBlockAt(pair.getX(), pair.getY(), pair.getZ()); - - if(!block.getChunk().equals(lastChunk)){ - lastChunk = block.getChunk(); - task.onChunkComplete(lastChunk); - } - - block.setBiome(biome); - - updateAmount++; - it.remove(); - } - - Bukkit.broadcastMessage("Amount: " + blocks.size() + " Empty: " + blocks.isEmpty()); - - if (blocks.isEmpty()) { - super.cancel(); - } - } - - public static void startUpdating(Map> snapshots, Biome biome, ChunkBiomeTask task) { - new ChunkBiomeSplitter(snapshots, biome, task); - } - - public interface ChunkBiomeTask { - - void onChunkComplete(Chunk chunk); - - } - -} diff --git a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java index 4caf43c3..5f8034f6 100644 --- a/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java +++ b/src/main/java/com/songoda/skyblock/blockscanner/BlockScanner.java @@ -58,11 +58,13 @@ public final class BlockScanner extends BukkitRunnable { private final int threadCount; private final Queue blocks; private final ScannerTasks tasks; - + private boolean ignoreLiquids; + private boolean ignoreLiquidsY; private boolean ignoreAir; - private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + private BlockScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + this.ignoreLiquidsY = ignoreLiquidsY; this.ignoreLiquids = ignoreLiquids; this.ignoreAir = ignoreAir; this.blocks = new ConcurrentLinkedQueue<>(); @@ -99,7 +101,7 @@ public final class BlockScanner extends BukkitRunnable { if(ignoreY){ startY = 255; } else { - startY = !ignoreLiquids && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0; + startY = !ignoreLiquidsY && liquidSection.getBoolean("Enable") && !config.getBoolean("Island.Levelling.ScanLiquid") ? liquidSection.getInt("Height") + 1 : 0; } for (List sub : parts) { @@ -161,12 +163,12 @@ public final class BlockScanner extends BukkitRunnable { cancel(); } - public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { + public static void startScanner(Map> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) { if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null"); if (tasks == null) throw new IllegalArgumentException("tasks cannot be null"); - final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreAir, ignoreY, tasks); + final BlockScanner scanner = new BlockScanner(snapshots, ignoreLiquids, ignoreLiquidsY, ignoreAir, ignoreY, tasks); scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5); } diff --git a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java index 1c3f7491..318b728b 100644 --- a/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java +++ b/src/main/java/com/songoda/skyblock/island/removal/ChunkDeleteSplitter.java @@ -27,7 +27,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable { } private void start() { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, false, true, true, false, (blocks) -> { this.blocks = blocks; this.runTaskTimer(SkyBlock.getInstance(), 20, 20); }); diff --git a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java index 0a2805d4..f41b88b9 100644 --- a/src/main/java/com/songoda/skyblock/levelling/IslandScan.java +++ b/src/main/java/com/songoda/skyblock/levelling/IslandScan.java @@ -82,7 +82,7 @@ public final class IslandScan extends BukkitRunnable { populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> { if (hasEnd) { populate(snapshots, IslandWorld.End, skyblock.isPaperAsync(), () -> { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -90,7 +90,7 @@ public final class IslandScan extends BukkitRunnable { }); }); } else { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20); @@ -99,7 +99,7 @@ public final class IslandScan extends BukkitRunnable { } }); } else { - BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> { + BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> { this.blocks = blocks; this.blocksSize = blocks.size(); this.runTaskTimer(SkyBlock.getInstance(), 20, 20);