From 4433892431d1904f5cced1159d83210ecc04120a Mon Sep 17 00:00:00 2001 From: Bernhard Date: Mon, 16 May 2022 14:20:03 +0200 Subject: [PATCH 1/7] fix: Block Endermites from spawning if mob spawning is disabled (#3623) --- .../com/plotsquared/bukkit/listener/EntityEventListener.java | 1 + .../main/java/com/plotsquared/bukkit/listener/PaperListener.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java index 8c10850e7..bd4c485f4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/EntityEventListener.java @@ -168,6 +168,7 @@ public class EntityEventListener implements Listener { case "RAID": case "SHEARED": case "SILVERFISH_BLOCK": + case "ENDER_PEARL": case "TRAP": case "VILLAGE_DEFENSE": case "VILLAGE_INVASION": diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index 079d04fe3..27e44d57f 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -196,6 +196,7 @@ public class PaperListener implements Listener { case "RAID": case "SHEARED": case "SILVERFISH_BLOCK": + case "ENDER_PEARL": case "TRAP": case "VILLAGE_DEFENSE": case "VILLAGE_INVASION": From 171d2e5e99cae4628ea51ca634d7457684ecc979 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 16 May 2022 13:21:43 +0100 Subject: [PATCH 2/7] Fix generation of augmented/partial worlds when single worlds are enabled (#3615) --- .../java/com/plotsquared/bukkit/util/BukkitSetupUtils.java | 3 ++- Core/src/main/java/com/plotsquared/core/util/SetupUtils.java | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java index 1efd58a5c..e74553201 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java @@ -76,7 +76,7 @@ public class BukkitSetupUtils extends SetupUtils { @Override public void updateGenerators(final boolean force) { - if (!SetupUtils.generators.isEmpty() && !force) { + if (loaded && !SetupUtils.generators.isEmpty() && !force) { return; } String testWorld = "CheckingPlotSquaredGenerator"; @@ -100,6 +100,7 @@ public class BukkitSetupUtils extends SetupUtils { e.printStackTrace(); } } + loaded = true; } @Override diff --git a/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java b/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java index 7ac32e333..edb46f3d0 100644 --- a/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java +++ b/Core/src/main/java/com/plotsquared/core/util/SetupUtils.java @@ -34,6 +34,7 @@ import java.util.HashMap; public abstract class SetupUtils { public static HashMap> generators = new HashMap<>(); + protected boolean loaded = false; /** * @since 6.1.0 From 96dfc2741123c494431bc1543ad0925f2c5fd686 Mon Sep 17 00:00:00 2001 From: Jordan Date: Mon, 16 May 2022 13:27:41 +0100 Subject: [PATCH 3/7] Fix lag caused when generating augmented worlds with roads (#3614) - Begin by implementing forceSync to the queue system as we know the chunk will be accessible to edits in some cases (i.e. population). - Also implement custom SideEffectSets to override any decided by the default chunk consumer, as we do NOT want to update neighbours in population (this caused infinite generation to be required causing the lag and server death). We also do not want to enqueue the QueueCoordinator in AugmentedUtils as this would write to the world and update neighbours before we might want to (plus it's just used to restrict and offset the blocks being set) - Then implement disabling any biomes from being saved/set to the queue to prevent augmented worlds having their biomes overridden in roads - Consequently fix ScopedQueueCoordinator, preventing the y value of blocks being set from needlessly being changed, fixing road heights in augmented worlds - Finally we do not need a method with chunkObject in the signature in AugmentedUtils as this is no longer used by the method --- .../generator/BukkitAugmentedGenerator.java | 13 +++- .../bukkit/queue/BukkitChunkCoordinator.java | 31 ++++++--- .../bukkit/queue/BukkitQueueCoordinator.java | 63 +++++++++++++------ .../core/generator/AugmentedUtils.java | 45 ++++++++----- .../core/queue/BasicQueueCoordinator.java | 40 +++++++++++- .../core/queue/DelegateQueueCoordinator.java | 23 +++++++ .../core/queue/QueueCoordinator.java | 23 +++++++ .../core/queue/ScopedQueueCoordinator.java | 23 ++----- 8 files changed, 201 insertions(+), 60 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java index 0f3733c11..b63b4f9fb 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java @@ -25,7 +25,11 @@ */ package com.plotsquared.bukkit.generator; +import com.plotsquared.core.PlotSquared; import com.plotsquared.core.generator.AugmentedUtils; +import com.plotsquared.core.queue.QueueCoordinator; +import com.sk89q.worldedit.bukkit.BukkitAdapter; +import com.sk89q.worldedit.util.SideEffectSet; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.generator.BlockPopulator; @@ -52,7 +56,14 @@ public class BukkitAugmentedGenerator extends BlockPopulator { @Override public void populate(@NonNull World world, @NonNull Random random, @NonNull Chunk source) { - AugmentedUtils.generate(source, world.getName(), source.getX(), source.getZ(), null); + QueueCoordinator queue = PlotSquared.platform().globalBlockQueue().getNewQueue(BukkitAdapter.adapt(world)); + // The chunk is already loaded and we do not want to load the chunk in "fully" by using any PaperLib methods. + queue.setForceSync(true); + queue.setSideEffectSet(SideEffectSet.none()); + queue.setBiomesEnabled(false); + queue.setChunkObject(source); + AugmentedUtils.generateChunk(world.getName(), source.getX(), source.getZ(), queue); + queue.enqueue(); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java index 3f78bf39e..2ed483ee1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitChunkCoordinator.java @@ -76,10 +76,11 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { private final int totalSize; private final AtomicInteger expectedSize; private final AtomicInteger loadingChunks = new AtomicInteger(); + private final boolean forceSync; private int batchSize; private PlotSquaredTask task; - private boolean shouldCancel; + private volatile boolean shouldCancel; private boolean finished; @Inject @@ -92,7 +93,8 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { @Assisted final @NonNull Runnable whenDone, @Assisted final @NonNull Consumer throwableConsumer, @Assisted final boolean unloadAfter, - @Assisted final @NonNull Collection progressSubscribers + @Assisted final @NonNull Collection progressSubscribers, + @Assisted final boolean forceSync ) { this.requestedChunks = new LinkedBlockingQueue<>(requestedChunks); this.availableChunks = new LinkedBlockingQueue<>(); @@ -107,14 +109,27 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { this.plugin = JavaPlugin.getPlugin(BukkitPlatform.class); this.bukkitWorld = Bukkit.getWorld(world.getName()); this.progressSubscribers.addAll(progressSubscribers); + this.forceSync = forceSync; } @Override public void start() { - // Request initial batch - this.requestBatch(); - // Wait until next tick to give the chunks a chance to be loaded - TaskManager.runTaskLater(() -> task = TaskManager.runTaskRepeat(this, TaskTime.ticks(1)), TaskTime.ticks(1)); + if (!forceSync) { + // Request initial batch + this.requestBatch(); + // Wait until next tick to give the chunks a chance to be loaded + TaskManager.runTaskLater(() -> task = TaskManager.runTaskRepeat(this, TaskTime.ticks(1)), TaskTime.ticks(1)); + } else { + try { + while (!shouldCancel && !requestedChunks.isEmpty()) { + chunkConsumer.accept(requestedChunks.poll()); + } + } catch (Throwable t) { + throwableConsumer.accept(t); + } finally { + finish(); + } + } } @Override @@ -131,7 +146,9 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator { for (final ProgressSubscriber subscriber : this.progressSubscribers) { subscriber.notifyEnd(); } - task.cancel(); + if (task != null) { + task.cancel(); + } finished = true; } } 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 d639f74ad..aadc888fd 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java @@ -63,10 +63,27 @@ import java.util.function.Consumer; public class BukkitQueueCoordinator extends BasicQueueCoordinator { - private final SideEffectSet noSideEffectSet; - private final SideEffectSet lightingSideEffectSet; - private final SideEffectSet edgeSideEffectSet; - private final SideEffectSet edgeLightingSideEffectSet; + private static final SideEffectSet NO_SIDE_EFFECT_SET; + private static final SideEffectSet EDGE_SIDE_EFFECT_SET; + private static final SideEffectSet LIGHTING_SIDE_EFFECT_SET; + private static final SideEffectSet EDGE_LIGHTING_SIDE_EFFECT_SET; + + static { + NO_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.LIGHTING, SideEffect.State.OFF).with( + SideEffect.NEIGHBORS, + SideEffect.State.OFF + ); + EDGE_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.UPDATE, SideEffect.State.ON).with( + SideEffect.NEIGHBORS, + SideEffect.State.ON + ); + LIGHTING_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.NEIGHBORS, SideEffect.State.OFF); + EDGE_LIGHTING_SIDE_EFFECT_SET = SideEffectSet.none().with(SideEffect.UPDATE, SideEffect.State.ON).with( + SideEffect.NEIGHBORS, + SideEffect.State.ON + ); + } + private org.bukkit.World bukkitWorld; @Inject private ChunkCoordinatorBuilderFactory chunkCoordinatorBuilderFactory; @@ -77,19 +94,6 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { @Inject public BukkitQueueCoordinator(@NonNull World world) { super(world); - noSideEffectSet = SideEffectSet.none().with(SideEffect.LIGHTING, SideEffect.State.OFF).with( - SideEffect.NEIGHBORS, - SideEffect.State.OFF - ); - lightingSideEffectSet = SideEffectSet.none().with(SideEffect.NEIGHBORS, SideEffect.State.OFF); - edgeSideEffectSet = noSideEffectSet.with(SideEffect.UPDATE, SideEffect.State.ON).with( - SideEffect.NEIGHBORS, - SideEffect.State.ON - ); - edgeLightingSideEffectSet = noSideEffectSet.with(SideEffect.UPDATE, SideEffect.State.ON).with( - SideEffect.NEIGHBORS, - SideEffect.State.ON - ); } @Override @@ -202,7 +206,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { localChunk.getTiles().forEach((blockVector3, tag) -> { try { BaseBlock block = getWorld().getBlock(blockVector3).toBaseBlock(tag); - getWorld().setBlock(blockVector3, block, noSideEffectSet); + getWorld().setBlock(blockVector3, block, getSideEffectSet(SideEffectState.NONE)); } catch (WorldEditException ignored) { StateWrapper sw = new StateWrapper(tag); sw.restoreTag(getWorld().getName(), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); @@ -259,9 +263,9 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { } SideEffectSet sideEffectSet; if (lighting) { - sideEffectSet = edge ? edgeLightingSideEffectSet : lightingSideEffectSet; + sideEffectSet = getSideEffectSet(edge ? SideEffectState.EDGE_LIGHTING : SideEffectState.LIGHTING); } else { - sideEffectSet = edge ? edgeSideEffectSet : noSideEffectSet; + sideEffectSet = getSideEffectSet(edge ? SideEffectState.EDGE : SideEffectState.NONE); } getWorld().setBlock(loc, block, sideEffectSet); } catch (WorldEditException ignored) { @@ -382,4 +386,23 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { return false; } + private SideEffectSet getSideEffectSet(SideEffectState state) { + if (getSideEffectSet() != null) { + return getSideEffectSet(); + } + return switch (state) { + case NONE -> NO_SIDE_EFFECT_SET; + case EDGE -> EDGE_SIDE_EFFECT_SET; + case LIGHTING -> LIGHTING_SIDE_EFFECT_SET; + case EDGE_LIGHTING -> EDGE_LIGHTING_SIDE_EFFECT_SET; + }; + } + + private enum SideEffectState { + NONE, + EDGE, + LIGHTING, + EDGE_LIGHTING + } + } diff --git a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java index 349d06b89..f2bcb7ceb 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java @@ -54,12 +54,23 @@ public class AugmentedUtils { enabled = true; } - public static boolean generate( - @Nullable Object chunkObject, + /** + * Generate an augmented world chunk at the given location. If a queue is given, the data will be written to it, else a new + * queue will be created and written to world. Returns true if generation occurred. + * + * @param world World name to generate data for. Must be a PlotSquared world containing one or more areas else nothing will + * happen. + * @param chunkX Chunk X position + * @param chunkZ Chunk Z position + * @param queue Queue to write to, if desired. + * @return true if generation occurred. + * @since TODO + */ + public static boolean generateChunk( final @NonNull String world, final int chunkX, final int chunkZ, - QueueCoordinator queue + @Nullable QueueCoordinator queue ) { if (!enabled) { return false; @@ -97,9 +108,6 @@ public class AugmentedUtils { .platform() .worldUtil() .getWeWorld(world)); - if (chunkObject != null) { - queue.setChunkObject(chunkObject); - } } QueueCoordinator primaryMask; // coordinates @@ -157,13 +165,9 @@ public class AugmentedUtils { } generationResult = true; } - if (chunkObject != null) { - primaryMask.setChunkObject(chunkObject); - } - if (chunkObject != null) { - secondaryMask.setChunkObject(chunkObject); - } + // This queue should not be enqueued as it is simply used to restrict block setting, and then delegate to the + // actual queue ScopedQueueCoordinator scoped = new ScopedQueueCoordinator( secondaryMask, @@ -172,8 +176,6 @@ public class AugmentedUtils { ); generator.generateChunk(scoped, area); generator.populateChunk(scoped, area); - scoped.setForceSync(true); - scoped.enqueue(); } if (enqueue) { queue.enqueue(); @@ -181,4 +183,19 @@ public class AugmentedUtils { return generationResult; } + /** + * @deprecated Use {@link AugmentedUtils#generateChunk(String, int, int, QueueCoordinator)} as chunkObject is not required + * in the above method + */ + @Deprecated(forRemoval = true, since = "TODO") + public static boolean generate( + @Nullable Object chunkObject, + final @NonNull String world, + final int chunkX, + final int chunkZ, + QueueCoordinator queue + ) { + return generateChunk(world, chunkX, chunkZ, queue); + } + } diff --git a/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java index 1f6d6371c..957ca441d 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java @@ -34,6 +34,7 @@ import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; @@ -61,6 +62,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { private int lastX = Integer.MIN_VALUE; private int lastZ = Integer.MIN_VALUE; private boolean settingBiomes = false; + private boolean disableBiomes = false; private boolean settingTiles = false; private boolean regen = false; private int[] regenStart; @@ -68,7 +70,8 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { private CuboidRegion regenRegion = null; private Consumer consumer = null; private boolean unloadAfter = true; - private Runnable whenDone; + private Runnable whenDone = null; + private SideEffectSet sideEffectSet = null; @Nullable private LightingMode lightingMode = LightingMode.valueOf(Settings.QUEUE.LIGHTING_MODE); @@ -120,6 +123,9 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { @SuppressWarnings("removal") @Override public boolean setBiome(int x, int z, @NonNull BiomeType biomeType) { + if (disableBiomes) { + return false; + } LocalChunk chunk = getChunk(x >> 4, z >> 4); for (int y = world.getMinY(); y <= world.getMaxY(); y++) { chunk.setBiome(x & 15, y, z & 15, biomeType); @@ -130,6 +136,9 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { @Override public final boolean setBiome(int x, int y, int z, @NonNull BiomeType biomeType) { + if (disableBiomes) { + return false; + } LocalChunk chunk = getChunk(x >> 4, z >> 4); chunk.setBiome(x & 15, y, z & 15, biomeType); settingBiomes = true; @@ -141,6 +150,12 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { return this.settingBiomes; } + @Override + public void setBiomesEnabled(boolean settingBiomes) { + this.settingBiomes = settingBiomes; + this.disableBiomes = true; + } + @Override public boolean setTile(int x, int y, int z, @NonNull CompoundTag tag) { LocalChunk chunk = getChunk(x >> 4, z >> 4); @@ -315,6 +330,29 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { this.whenDone = whenDone; } + @Override + public SideEffectSet getSideEffectSet() { + return sideEffectSet; + } + + @Override + public void setSideEffectSet(SideEffectSet sideEffectSet) { + this.sideEffectSet = sideEffectSet; + } + + // Don't ask about the @NonNull placement. That's how it needs to be else it errors. + @Override + public void setBiomeCuboid( + final com.plotsquared.core.location.@NonNull Location pos1, + final com.plotsquared.core.location.@NonNull Location pos2, + @NonNull final BiomeType biome + ) { + if (disableBiomes) { + return; + } + super.setBiomeCuboid(pos1, pos2, biome); + } + /** * Get the {@link LocalChunk} from the queue at the given chunk coordinates. Returns a new instance if one doesn't exist */ diff --git a/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java index 0dd83c39e..b0c827ff1 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java @@ -32,6 +32,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; @@ -135,6 +136,13 @@ public class DelegateQueueCoordinator extends QueueCoordinator { return false; } + @Override + public void setBiomesEnabled(final boolean enabled) { + if (parent != null) { + parent.setBiomesEnabled(enabled); + } + } + @Override public boolean setEntity(@NonNull Entity entity) { if (parent != null) { @@ -248,6 +256,21 @@ public class DelegateQueueCoordinator extends QueueCoordinator { } } + @Override + public SideEffectSet getSideEffectSet() { + if (parent != null) { + return parent.getSideEffectSet(); + } + return null; + } + + @Override + public void setSideEffectSet(final SideEffectSet sideEffectSet) { + if (parent != null) { + parent.setSideEffectSet(sideEffectSet); + } + } + @Override public @NonNull List getReadChunks() { if (parent != null) { 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 609434174..8c40fe0bb 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -35,6 +35,7 @@ import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.regions.CuboidRegion; +import com.sk89q.worldedit.util.SideEffectSet; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; @@ -248,6 +249,14 @@ public abstract class QueueCoordinator { */ public abstract boolean isSettingBiomes(); + /** + * If the queue should accept biome placement + * + * @param enabled If biomes should be enabled + * @since TODO + */ + public abstract void setBiomesEnabled(boolean enabled); + /** * Add entities to be created * @@ -413,6 +422,20 @@ public abstract class QueueCoordinator { */ public abstract void setLightingMode(@Nullable LightingMode mode); + /** + * Get the overriding {@link SideEffectSet} to be used by the queue if it exists, else null + * + * @return Overriding {@link SideEffectSet} or null + */ + public abstract @Nullable SideEffectSet getSideEffectSet(); + + /** + * Set the overriding {@link SideEffectSet} to be used by the queue. Null to use default side effects. + * + * @param sideEffectSet side effects to override with, or null to use default + */ + public abstract void setSideEffectSet(@Nullable SideEffectSet sideEffectSet); + /** * Fill a cuboid between two positions with a BlockState * diff --git a/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java index 0eda75df2..496ac1406 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java @@ -46,15 +46,12 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator { private final Location min; private final Location max; private final int minX; - private final int minY; private final int minZ; private final int maxX; - private final int maxY; private final int maxZ; private final int dx; - private final int dy; private final int dz; /** @@ -65,15 +62,12 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator { this.min = min; this.max = max; this.minX = min.getX(); - this.minY = min.getY(); this.minZ = min.getZ(); this.maxX = max.getX(); - this.maxY = max.getY(); this.maxZ = max.getZ(); this.dx = maxX - minX; - this.dy = maxY - minY; this.dz = maxZ - minZ; } @@ -84,11 +78,11 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator { @Override public boolean setBiome(int x, int y, int z, @NonNull BiomeType biome) { - return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super.setBiome(x + minX, y + minY, z + minZ, biome); + return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBiome(x + minX, y, z + minZ, biome); } public void fillBiome(BiomeType biome) { - for (int y = 0; y <= dy; y++) { + for (int y = min.getY(); y <= max.getY(); y++) { for (int x = 0; x <= dx; x++) { for (int z = 0; z < dz; z++) { setBiome(x, y, z, biome); @@ -99,27 +93,22 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator { @Override public boolean setBlock(int x, int y, int z, @NonNull BaseBlock id) { - return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super.setBlock(x + minX, y + minY, z + minZ, id); + return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBlock(x + minX, y, z + minZ, id); } @Override public boolean setBlock(int x, int y, int z, @NonNull BlockState id) { - return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super.setBlock(x + minX, y + minY, z + minZ, id); + return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBlock(x + minX, y, z + minZ, id); } @Override public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) { - return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super.setBlock( - x + minX, - y + minY, - z + minZ, - pattern - ); + return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setBlock(x + minX, y, z + minZ, pattern); } @Override public boolean setTile(int x, int y, int z, @NonNull CompoundTag tag) { - return x >= 0 && x <= dx && y >= 0 && y <= dy && z >= 0 && z <= dz && super.setTile(x + minX, y + minY, z + minZ, tag); + return x >= 0 && x <= dx && z >= 0 && z <= dz && super.setTile(x + minX, y, z + minZ, tag); } public @NonNull Location getMin() { From dc2d08c67e33a3f335c43dd32d611f305724d75e Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 18 May 2022 17:19:23 +0200 Subject: [PATCH 4/7] build: Update release-drafter/release-drafter action to v5.20.0 (#3624) * build: Update release-drafter/release-drafter action to v5.20.0 * Update release-drafter.yml Co-authored-by: Renovate Bot Co-authored-by: Alexander Brandes --- .github/workflows/release-drafter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index aab6e89f9..6fa4b5347 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -14,6 +14,6 @@ jobs: if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5.19.0 + - uses: release-drafter/release-drafter@v5 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From d037da33cbe616404f59160fe82c454cb44c6bd0 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Wed, 18 May 2022 21:59:09 +0200 Subject: [PATCH 5/7] chore: Ignore .DS_Store files --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index d1add4d55..2f3f35088 100644 --- a/.gitignore +++ b/.gitignore @@ -133,3 +133,5 @@ classes/ *.bat docs/ build/ + +.DS_Store From 41f546ca6b89d83a136d4e2b0fe427e502a9a8b7 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Wed, 18 May 2022 22:05:31 +0200 Subject: [PATCH 6/7] build: Release 6.8.0 --- .lift.toml | 4 ---- .../java/com/plotsquared/core/generator/AugmentedUtils.java | 4 ++-- .../core/queue/BlockArrayCacheScopedQueueCoordinator.java | 2 +- .../com/plotsquared/core/queue/ChunkQueueCoordinator.java | 2 +- .../java/com/plotsquared/core/queue/QueueCoordinator.java | 2 +- .../com/plotsquared/core/queue/ScopedQueueCoordinator.java | 2 +- build.gradle.kts | 2 +- 7 files changed, 7 insertions(+), 11 deletions(-) delete mode 100644 .lift.toml diff --git a/.lift.toml b/.lift.toml deleted file mode 100644 index 1501777dd..000000000 --- a/.lift.toml +++ /dev/null @@ -1,4 +0,0 @@ -jdkVersion = "17" -build = "gradle clean build -x test" -tools = ["findsecbugs", "ErrorProne", "Semgrep", "Detekt", "Infer"] -ignoreRules = ["CatchAndPrintStackTrace", "ReferenceEquality", "FallThrough", "FutureReturnValueIgnored", "MixedMutabilityReturnType", "EmptyCatch", "MissingCasesInEnumSwitch", "OperatorPrecedence", "StaticAssignmentInConstructor", "ReferenceEquality", "EqualsHashCode", "EqualsGetClass", "TypeParameterUnusedInFormals", "StringSplitter", "InlineMeSuggester", "NULL_DEREFERENCE"] diff --git a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java index f2bcb7ceb..366d01ef0 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java @@ -64,7 +64,7 @@ public class AugmentedUtils { * @param chunkZ Chunk Z position * @param queue Queue to write to, if desired. * @return true if generation occurred. - * @since TODO + * @since 6.8.0 */ public static boolean generateChunk( final @NonNull String world, @@ -187,7 +187,7 @@ public class AugmentedUtils { * @deprecated Use {@link AugmentedUtils#generateChunk(String, int, int, QueueCoordinator)} as chunkObject is not required * in the above method */ - @Deprecated(forRemoval = true, since = "TODO") + @Deprecated(forRemoval = true, since = "6.8.0") public static boolean generate( @Nullable Object chunkObject, final @NonNull String world, diff --git a/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java index 043e6e0ff..6202ddc30 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/BlockArrayCacheScopedQueueCoordinator.java @@ -64,7 +64,7 @@ public class BlockArrayCacheScopedQueueCoordinator extends ScopedQueueCoordinato * * @param min Inclusive location of the minimum point to limit the scope to. * @param max Inclusive location of the maximum point to limit the scope to. - * @since TODO + * @since 6.8.0 */ public BlockArrayCacheScopedQueueCoordinator(Location min, Location max) { super(null, min, max); diff --git a/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java index 65b35e8da..bfb405d42 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java @@ -41,7 +41,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; * * @deprecated This class is poorly designed and will no longer be used in P2 */ -@Deprecated(forRemoval = true, since = "TODO") +@Deprecated(forRemoval = true, since = "6.8.0") public class ChunkQueueCoordinator extends ScopedQueueCoordinator { public final BiomeType[][][] biomeResult; 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 8c40fe0bb..7622bb05d 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -253,7 +253,7 @@ public abstract class QueueCoordinator { * If the queue should accept biome placement * * @param enabled If biomes should be enabled - * @since TODO + * @since 6.8.0 */ public abstract void setBiomesEnabled(boolean enabled); diff --git a/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java index 496ac1406..464d27343 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java @@ -40,7 +40,7 @@ import org.checkerframework.checker.nullness.qual.Nullable; * * @deprecated This should be renamed to NormalizedScopedQueueCoordinator or something. */ -@Deprecated(forRemoval = true, since = "TODO") +@Deprecated(forRemoval = true, since = "6.8.0") public class ScopedQueueCoordinator extends DelegateQueueCoordinator { private final Location min; diff --git a/build.gradle.kts b/build.gradle.kts index 2e6b65b31..c78fe4be9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { idea } -version = "6.7.1-SNAPSHOT" +version = "6.8.0" allprojects { group = "com.plotsquared" From fc9fe1462f3d46a96ee07852f321582bcbfaa249 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Wed, 18 May 2022 22:07:22 +0200 Subject: [PATCH 7/7] build: Back to snapshot for development --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index c78fe4be9..cf6113d36 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -18,7 +18,7 @@ plugins { idea } -version = "6.8.0" +version = "6.8.1-SNAPSHOT" allprojects { group = "com.plotsquared"