From 9f3507ea85e8de117d6a171f9e7419e1715e493a Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 10 May 2022 01:39:16 +0100 Subject: [PATCH] Actually implement chunkObject into queueing - This should only be used in generation - The chunk will be used as fallback to set to using bukkit API if WNA fails --- .../plotsquared/bukkit/queue/BukkitQueueCoordinator.java | 9 ++++++++- .../com/plotsquared/core/queue/QueueCoordinator.java | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java index f7e6f16a3..ed6275750 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java @@ -51,6 +51,7 @@ import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import org.bukkit.Bukkit; +import org.bukkit.Chunk; import org.bukkit.block.Block; import org.bukkit.block.Container; import org.bukkit.block.data.BlockData; @@ -266,7 +267,13 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { } catch (WorldEditException ignored) { // Fallback to not so nice method BlockData blockData = BukkitAdapter.adapt(block); - Block existing = getBukkitWorld().getBlockAt(x, y, z); + Block existing; + // Assume a chunk object has been given only when it should have been. + if (getChunkObject() instanceof Chunk) { + existing = ((Chunk) getChunkObject()).getBlock(x & 15, y, z & 15); + } else { + existing = getBukkitWorld().getBlockAt(x, y, z); + } final BlockState existingBaseBlock = BukkitAdapter.adapt(existing.getBlockData()); if (BukkitBlockUtil.get(existing).equals(existingBaseBlock) && existing.getBlockData().matches(blockData)) { return; diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java index 7853f89eb..609434174 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -143,7 +143,8 @@ public abstract class QueueCoordinator { } /** - * Set a chunk object (e.g. the Bukkit Chunk object) to the queue + * Set a chunk object (e.g. the Bukkit Chunk object) to the queue. This will be used as fallback in case of WNA failure. + * Should ONLY be used in specific cases (i.e. generation, where a chunk is being populated) * * @param chunkObject chunk object. Usually the implementation-specific chunk (e.g. bukkit Chunk) */