mirror of
https://github.com/songoda/FabledSkyBlock.git
synced 2025-01-21 06:51:29 +01:00
Fixed water not being removed on island deletion
This commit is contained in:
parent
214756e41e
commit
27b9f8ba66
@ -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<World, List<ChunkSnapshot>> snapshots;
|
|
||||||
private Queue<BlockInfo> blocks;
|
|
||||||
private final Biome biome;
|
|
||||||
private Chunk lastChunk;
|
|
||||||
private ChunkBiomeTask task;
|
|
||||||
|
|
||||||
private ChunkBiomeSplitter(Map<World, List<ChunkSnapshot>> 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<BlockInfo> 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<World, List<ChunkSnapshot>> snapshots, Biome biome, ChunkBiomeTask task) {
|
|
||||||
new ChunkBiomeSplitter(snapshots, biome, task);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ChunkBiomeTask {
|
|
||||||
|
|
||||||
void onChunkComplete(Chunk chunk);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -58,11 +58,13 @@ public final class BlockScanner extends BukkitRunnable {
|
|||||||
private final int threadCount;
|
private final int threadCount;
|
||||||
private final Queue<BlockInfo> blocks;
|
private final Queue<BlockInfo> blocks;
|
||||||
private final ScannerTasks tasks;
|
private final ScannerTasks tasks;
|
||||||
|
|
||||||
private boolean ignoreLiquids;
|
private boolean ignoreLiquids;
|
||||||
|
private boolean ignoreLiquidsY;
|
||||||
private boolean ignoreAir;
|
private boolean ignoreAir;
|
||||||
|
|
||||||
private BlockScanner(Map<World, List<ChunkSnapshot>> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
private BlockScanner(Map<World, List<ChunkSnapshot>> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
||||||
|
this.ignoreLiquidsY = ignoreLiquidsY;
|
||||||
this.ignoreLiquids = ignoreLiquids;
|
this.ignoreLiquids = ignoreLiquids;
|
||||||
this.ignoreAir = ignoreAir;
|
this.ignoreAir = ignoreAir;
|
||||||
this.blocks = new ConcurrentLinkedQueue<>();
|
this.blocks = new ConcurrentLinkedQueue<>();
|
||||||
@ -99,7 +101,7 @@ public final class BlockScanner extends BukkitRunnable {
|
|||||||
if(ignoreY){
|
if(ignoreY){
|
||||||
startY = 255;
|
startY = 255;
|
||||||
} else {
|
} 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<ChunkSnapshot> sub : parts) {
|
for (List<ChunkSnapshot> sub : parts) {
|
||||||
@ -161,12 +163,12 @@ public final class BlockScanner extends BukkitRunnable {
|
|||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void startScanner(Map<World, List<ChunkSnapshot>> snapshots, boolean ignoreLiquids, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
public static void startScanner(Map<World, List<ChunkSnapshot>> snapshots, boolean ignoreLiquids, boolean ignoreLiquidsY, boolean ignoreAir, boolean ignoreY, ScannerTasks tasks) {
|
||||||
|
|
||||||
if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null");
|
if (snapshots == null) throw new IllegalArgumentException("snapshots cannot be null");
|
||||||
if (tasks == null) throw new IllegalArgumentException("tasks 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);
|
scanner.runTaskTimer(SkyBlock.getInstance(), 5, 5);
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class ChunkDeleteSplitter extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void start() {
|
private void start() {
|
||||||
BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> {
|
BlockScanner.startScanner(snapshots, false, true, true, false, (blocks) -> {
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||||
});
|
});
|
||||||
|
@ -82,7 +82,7 @@ public final class IslandScan extends BukkitRunnable {
|
|||||||
populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> {
|
populate(snapshots, IslandWorld.Nether, skyblock.isPaperAsync(), () -> {
|
||||||
if (hasEnd) {
|
if (hasEnd) {
|
||||||
populate(snapshots, IslandWorld.End, skyblock.isPaperAsync(), () -> {
|
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.blocks = blocks;
|
||||||
this.blocksSize = blocks.size();
|
this.blocksSize = blocks.size();
|
||||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||||
@ -90,7 +90,7 @@ public final class IslandScan extends BukkitRunnable {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> {
|
BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> {
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.blocksSize = blocks.size();
|
this.blocksSize = blocks.size();
|
||||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||||
@ -99,7 +99,7 @@ public final class IslandScan extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
BlockScanner.startScanner(snapshots, true, true, false, (blocks) -> {
|
BlockScanner.startScanner(snapshots, true, true, true, false, (blocks) -> {
|
||||||
this.blocks = blocks;
|
this.blocks = blocks;
|
||||||
this.blocksSize = blocks.size();
|
this.blocksSize = blocks.size();
|
||||||
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
this.runTaskTimer(SkyBlock.getInstance(), 20, 20);
|
||||||
|
Loading…
Reference in New Issue
Block a user