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 510b63e7a..460d6ac1e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/BukkitQueueCoordinator.java @@ -67,7 +67,6 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { private org.bukkit.World bukkitWorld; @Inject private ChunkCoordinatorBuilderFactory chunkCoordinatorBuilderFactory; @Inject private ChunkCoordinatorFactory chunkCoordinatorFactory; - private Runnable whenDone; private ChunkCoordinator chunkCoordinator; @Inject public BukkitQueueCoordinator(@Nonnull World world) { @@ -198,7 +197,7 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { } chunkCoordinator = chunkCoordinatorBuilderFactory.create(chunkCoordinatorFactory).inWorld(getWorld()).withChunks(getBlockChunks().keySet()).withChunks(read) - .withInitialBatchSize(3).withMaxIterationTime(40).withThrowableConsumer(Throwable::printStackTrace).withFinalAction(whenDone) + .withInitialBatchSize(3).withMaxIterationTime(40).withThrowableConsumer(Throwable::printStackTrace).withFinalAction(getCompleteTask()) .withConsumer(consumer).unloadAfter(isUnloadAfter()).build(); return super.enqueue(); } @@ -239,8 +238,4 @@ public class BukkitQueueCoordinator extends BasicQueueCoordinator { } } - @Override public void setCompleteTask(Runnable whenDone) { - this.whenDone = whenDone; - } - } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java index 195882d81..e9a22a575 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/queue/GenChunk.java @@ -71,6 +71,9 @@ public class GenChunk extends ScopedQueueCoordinator { return this.chunkData; } + /** + * Set the internal Bukkit chunk data + */ public void setChunkData(@Nonnull ChunkData chunkData) { this.chunkData = chunkData; } @@ -85,10 +88,17 @@ public class GenChunk extends ScopedQueueCoordinator { return chunk; } + /** + * Set the chunk being represented + */ public void setChunk(@Nonnull Chunk chunk) { this.chunk = chunk; } + + /** + * Set the world and XZ of the chunk being represented via {@link ChunkWrapper} + */ public void setChunk(@Nonnull ChunkWrapper wrap) { chunk = null; world = wrap.world; @@ -101,9 +111,11 @@ public class GenChunk extends ScopedQueueCoordinator { return; } Biome biome = BukkitAdapter.adapt(biomeType); - for (int x = 0; x < 16; x++) { - for (int z = 0; z < 16; z++) { - this.biomeGrid.setBiome(x, z, biome); + for (int y = 0; y < 256; y++) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + this.biomeGrid.setBiome(x, y, z, biome); + } } } } @@ -134,9 +146,22 @@ public class GenChunk extends ScopedQueueCoordinator { return setBiome(x, z, BukkitAdapter.adapt(biomeType)); } + /** + * Set the in the whole column of XZ + */ public boolean setBiome(int x, int z, @Nonnull Biome biome) { if (this.biomeGrid != null) { - this.biomeGrid.setBiome(x, z, biome); + for (int y = 0; y < 256; y++) { + this.setBiome(x, y, z, biome); + } + return true; + } + return false; + } + + public boolean setBiome(int x, int y, int z, @Nonnull Biome biome) { + if (this.biomeGrid != null) { + this.biomeGrid.setBiome(x, y, z, biome); return true; } return false; 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 f888f9bd9..1b42889ca 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java @@ -162,6 +162,8 @@ public class AugmentedUtils { new ScopedQueueCoordinator(secondaryMask, Location.at(world, blockX, 0, blockZ), Location.at(world, blockX + 15, 255, blockZ + 15)); generator.generateChunk(scoped, area); generator.populateChunk(scoped, area); + scoped.setForceSync(true); + scoped.enqueue(); } if (enqueue) { queue.enqueue(); diff --git a/Core/src/main/java/com/plotsquared/core/queue/AreaBoundDelegateQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/AreaBoundDelegateQueueCoordinator.java index beb1ae0ea..7d7c4aff6 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/AreaBoundDelegateQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/AreaBoundDelegateQueueCoordinator.java @@ -36,6 +36,9 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.util.Objects; +/** + * Queue Coordinator that only sets blocks with the specified PlotArea + */ public class AreaBoundDelegateQueueCoordinator extends DelegateQueueCoordinator { private final PlotArea area; @@ -45,6 +48,9 @@ public class AreaBoundDelegateQueueCoordinator extends DelegateQueueCoordinator this.area = Objects.requireNonNull(area); } + /** + * Gets the plot area block settings is limited to + */ public PlotArea getArea() { return this.area; } 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 8a4ae98ec..684eea7f6 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/BasicQueueCoordinator.java @@ -39,12 +39,16 @@ import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.entity.EntityTypes; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Consumer; +/** + * Standard block setting queue that allows block setting across numerous chunks, without limits. + */ public abstract class BasicQueueCoordinator extends QueueCoordinator { private final World world; @@ -62,6 +66,7 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { private CuboidRegion regenRegion = null; private Consumer consumer = null; private boolean unloadAfter = true; + private Runnable whenDone; public BasicQueueCoordinator(@Nonnull World world) { this.world = world; @@ -193,35 +198,61 @@ public abstract class BasicQueueCoordinator extends QueueCoordinator { this.unloadAfter = unloadAfter; } + /** + * Gets the int[x,z] chunk coordinates where regeneration should start from + */ public int[] getRegenStart() { return regenStart; } + /** + * Gets the int[x,z] chunk coordinates where regeneration should finish + */ public int[] getRegenEnd() { return regenEnd; } + /** + * Whether the queue has a start/end to chunk regeneration + */ public boolean isRegen() { return regen; } - public ConcurrentHashMap getBlockChunks() { + /** + * Gets the map of ChunkCoordinates in {@link BlockVector2} form against the {@link LocalChunk} of cached chunks to be written + */ + @Nonnull public ConcurrentHashMap getBlockChunks() { return this.blockChunks; } - public final void setChunk(LocalChunk chunk) { + /** + * Forces an {@link LocalChunk} into the list of chunks to be written. Overwrites existing chunks in the map + */ + public final void setChunk(@Nonnull LocalChunk chunk) { this.blockChunks.put(BlockVector2.at(chunk.getX(), chunk.getZ()), chunk); } - public final Consumer getChunkConsumer() { + @Override @Nullable public final Consumer getChunkConsumer() { return this.consumer; } - public final void setChunkConsumer(@Nonnull Consumer consumer) { + @Override public final void setChunkConsumer(@Nonnull Consumer consumer) { this.consumer = consumer; } - private LocalChunk getChunk(final int chunkX, final int chunkZ) { + @Override public Runnable getCompleteTask() { + return this.whenDone; + } + + @Override public void setCompleteTask(Runnable whenDone) { + this.whenDone = whenDone; + } + + /** + * Get the {@link LocalChunk} from the queue at the given chunk coordinates. Returns a new instance if one doesn't exist + */ + @Nonnull private LocalChunk getChunk(final int chunkX, final int chunkZ) { if (chunkX != lastX || chunkZ != lastZ) { lastX = chunkX; lastZ = chunkZ; diff --git a/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java b/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java index 2eac2ba2b..2ead29881 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ChunkCoordinatorBuilder.java @@ -40,6 +40,9 @@ import java.util.LinkedList; import java.util.List; import java.util.function.Consumer; +/** + * Builds a {@link ChunkCoordinator} instance + */ public class ChunkCoordinatorBuilder { private final List requestedChunks = new LinkedList<>(); @@ -57,21 +60,33 @@ public class ChunkCoordinatorBuilder { this.chunkCoordinatorFactory = chunkCoordinatorFactory; } + /** + * Set the world + */ @Nonnull public ChunkCoordinatorBuilder inWorld(@Nonnull final World world) { this.world = Preconditions.checkNotNull(world, "World may not be null"); return this; } + /** + * Add a chunk to be accessed + */ @Nonnull public ChunkCoordinatorBuilder withChunk(@Nonnull final BlockVector2 chunkLocation) { this.requestedChunks.add(Preconditions.checkNotNull(chunkLocation, "Chunk location may not be null")); return this; } + /** + * Add a Collection of chunks to be accessed + */ @Nonnull public ChunkCoordinatorBuilder withChunks(@Nonnull final Collection chunkLocations) { chunkLocations.forEach(this::withChunk); return this; } + /** + * Add chunks within a region to be accessed + */ @Nonnull public ChunkCoordinatorBuilder withRegion(@Nonnull Location pos1, @Nonnull Location pos2) { final int p1x = pos1.getX(); final int p1z = pos1.getZ(); @@ -93,11 +108,17 @@ public class ChunkCoordinatorBuilder { return this; } + /** + * Set the consumer to be used when a chunk is loaded + */ @Nonnull public ChunkCoordinatorBuilder withConsumer(@Nonnull final Consumer chunkConsumer) { this.chunkConsumer = Preconditions.checkNotNull(chunkConsumer, "Chunk consumer may not be null"); return this; } + /** + * Set the Runnable to run when all chunks have been accessed + */ @Nonnull public ChunkCoordinatorBuilder withFinalAction(@Nullable final Runnable whenDone) { if (whenDone == null) { return this; @@ -106,28 +127,44 @@ public class ChunkCoordinatorBuilder { return this; } + /** + * Set the max time taken while iterating over and accessing loaded chunks + */ @Nonnull public ChunkCoordinatorBuilder withMaxIterationTime(final long maxIterationTime) { Preconditions.checkArgument(maxIterationTime > 0, "Max iteration time must be positive"); this.maxIterationTime = maxIterationTime; return this; } + /** + * Set the initial batch size to be used for loading chunks + */ @Nonnull public ChunkCoordinatorBuilder withInitialBatchSize(final int initialBatchSize) { Preconditions.checkArgument(initialBatchSize > 0, "Initial batch size must be positive"); this.initialBatchSize = initialBatchSize; return this; } + /** + * Set the consumer to be used to handle {@link Throwable}s + */ @Nonnull public ChunkCoordinatorBuilder withThrowableConsumer(@Nonnull final Consumer throwableConsumer) { this.throwableConsumer = Preconditions.checkNotNull(throwableConsumer, "Throwable consumer may not be null"); return this; } + /** + * Set whether the chunks should be allow to unload after being accessed. This should only be used where the chunks are read from + * and then written to from a separate queue where they're consequently unloaded. + */ @Nonnull public ChunkCoordinatorBuilder unloadAfter(final boolean unloadAfter) { this.unloadAfter = unloadAfter; return this; } + /** + * Create a new {@link ChunkCoordinator} instance based on the values in the Builder instance. + */ @Nonnull public ChunkCoordinator build() { Preconditions.checkNotNull(this.world, "No world was supplied"); Preconditions.checkNotNull(this.chunkConsumer, "No chunk consumer was supplied"); 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 f03c8f25c..d04a0c798 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ChunkQueueCoordinator.java @@ -36,6 +36,9 @@ import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nonnull; import javax.annotation.Nullable; +/** + * Queue that is limited to a single chunk + */ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { public final BiomeType[][][] biomeResult; @@ -127,7 +130,7 @@ public class ChunkQueueCoordinator extends ScopedQueueCoordinator { return null; } - @Override @Nonnull public World getWorld() { + @Override @Nullable public World getWorld() { return super.getWorld(); } 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 86a21c874..7a97f4c39 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/DelegateQueueCoordinator.java @@ -34,7 +34,6 @@ import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; -import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,6 +42,9 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; +/** + * Queue that delegates to a parent queue. + */ public class DelegateQueueCoordinator extends QueueCoordinator { private final QueueCoordinator parent; @@ -180,6 +182,13 @@ public class DelegateQueueCoordinator extends QueueCoordinator { } } + @Nullable @Override public Consumer getChunkConsumer() { + if (parent != null) { + return parent.getChunkConsumer(); + } + return null; + } + @Override public void setChunkConsumer(@Nonnull Consumer consumer) { if (parent != null) { parent.setChunkConsumer(consumer); diff --git a/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java b/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java index 23385bd65..a251aced7 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java +++ b/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java @@ -43,6 +43,9 @@ public class GlobalBlockQueue { this.activeQueues = new ConcurrentLinkedDeque<>(); } + /** + * Get a new {@link QueueCoordinator} for the given world. + */ @Nonnull public QueueCoordinator getNewQueue(@Nonnull World world) { QueueCoordinator queue = provider.getNewQueue(world); // Auto-inject into the queue diff --git a/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateQueueCoordinator.java index c2f95a875..fd86f7eb2 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/LocationOffsetDelegateQueueCoordinator.java @@ -35,6 +35,9 @@ import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nonnull; import javax.annotation.Nullable; +/** + * Offsets input coordinates and delegates to a parent queue + */ public class LocationOffsetDelegateQueueCoordinator extends DelegateQueueCoordinator { private final boolean[][] canPlace; diff --git a/Core/src/main/java/com/plotsquared/core/queue/OffsetQueueCoordinator.java b/Core/src/main/java/com/plotsquared/core/queue/OffsetQueueCoordinator.java deleted file mode 100644 index c352efd4c..000000000 --- a/Core/src/main/java/com/plotsquared/core/queue/OffsetQueueCoordinator.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * _____ _ _ _____ _ - * | __ \| | | | / ____| | | - * | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| | - * | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` | - * | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| | - * |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_| - * | | - * |_| - * PlotSquared plot management system for Minecraft - * Copyright (C) 2020 IntellectualSites - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package com.plotsquared.core.queue; - -import com.sk89q.jnbt.CompoundTag; -import com.sk89q.worldedit.function.pattern.Pattern; -import com.sk89q.worldedit.world.biome.BiomeType; -import com.sk89q.worldedit.world.block.BaseBlock; - -import javax.annotation.Nonnull; - -public class OffsetQueueCoordinator extends DelegateQueueCoordinator { - private final int ox; - private final int oy; - private final int oz; - - public OffsetQueueCoordinator(@Nonnull QueueCoordinator parent, int ox, int oy, int oz) { - super(parent); - this.ox = ox; - this.oy = oy; - this.oz = oz; - } - - @Override public boolean setBiome(int x, int z, @Nonnull BiomeType biome) { - return super.setBiome(ox + x, oz + z, biome); - } - - @Override public boolean setBiome(int x, int y, int z, @Nonnull BiomeType biome) { - return super.setBiome(ox + x, oy + y, oz + z, biome); - } - - @Override public boolean setBlock(int x, int y, int z, @Nonnull BaseBlock id) { - return super.setBlock(ox + x, oy + y, oz + z, id); - } - - @Override public boolean setBlock(int x, int y, int z, @Nonnull Pattern pattern) { - return super.setBlock(ox + x, oy + y, oz + z, pattern); - } - - @Override public boolean setTile(int x, int y, int z, @Nonnull CompoundTag tag) { - return super.setTile(ox + x, oy + y, oz + z, tag); - } -} 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 0dc596cb6..91738bd40 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueCoordinator.java @@ -56,6 +56,9 @@ public abstract class QueueCoordinator { PlotSquared.platform().getInjector().injectMembers(this); } + /** + * Get a {@link ScopedQueueCoordinator} limited to the chunk at the specific chunk Coordinates + */ public ScopedQueueCoordinator getForChunk(int x, int z) { int bx = x << 4; int bz = z << 4; @@ -63,22 +66,40 @@ public abstract class QueueCoordinator { Location.at(getWorld().getName(), bx + 15, 255, bz + 255)); } + /** + * Get the size of the queue in chunks + */ public abstract int size(); + /** + * Set when the queue was last modified + */ public abstract void setModified(long modified); + /** + * Returns true if the queue should be forced to be synchronous when enqueued. + */ public boolean isForceSync() { return forceSync; } + /** + * Set whether the queue should be forced to be synchronous + */ public void setForceSync(boolean forceSync) { this.forceSync = forceSync; } + /** + * Get the Chunk Object set to the queue + */ @Nullable public Object getChunkObject() { return chunkObject; } + /** + * Set a chunk object (e.g. the Bukkit Chunk object) to the queue + */ public void setChunkObject(@Nonnull Object chunkObject) { this.chunkObject = chunkObject; } @@ -89,70 +110,173 @@ public abstract class QueueCoordinator { * @param x the x coordinate from from 0 to 15 inclusive * @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive) * @param z the z coordinate from 0 to 15 inclusive - * @param id the id to set the block to + * @param id the BlockState to set the block to */ public abstract boolean setBlock(final int x, final int y, final int z, @Nonnull final BlockState id); + /** + * Sets the block at the coordinates provided to the given id. + * + * @param x the x coordinate from from 0 to 15 inclusive + * @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive) + * @param z the z coordinate from 0 to 15 inclusive + * @param id the BaseBlock to set the block to + */ public abstract boolean setBlock(final int x, final int y, final int z, @Nonnull final BaseBlock id); + /** + * Sets the block at the coordinates provided to the given id. + * + * @param x the x coordinate from from 0 to 15 inclusive + * @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive) + * @param z the z coordinate from 0 to 15 inclusive + * @param pattern the pattern to set the block to + */ public boolean setBlock(final int x, final int y, final int z, @Nonnull final Pattern pattern) { return setBlock(x, y, z, PatternUtil.apply(pattern, x, y, z)); } + /** + * Sets a tile entity at the coordinates provided to the given CompoundTag + * + * @param x the x coordinate from from 0 to 15 inclusive + * @param y the y coordinate from from 0 (inclusive) - maxHeight(exclusive) + * @param z the z coordinate from 0 to 15 inclusive + * @param tag the CompoundTag to set the tile to + */ public abstract boolean setTile(int x, int y, int z, @Nonnull CompoundTag tag); + /** + * Whether the queue has any tiles being set + */ public abstract boolean isSettingTiles(); + /** + * Get a block at the given coordinates. + */ @Nullable public abstract BlockState getBlock(int x, int y, int z); + /** + * Set a biome in XZ. This will likely set to the whole column + */ @Deprecated public abstract boolean setBiome(int x, int z, @Nonnull BiomeType biome); + /** + * Set a biome in XYZ + */ public abstract boolean setBiome(int x, int y, int z, @Nonnull BiomeType biome); + /** + * Whether the queue has any biomes to be set + */ public abstract boolean isSettingBiomes(); + /** + * Add entities to be created + */ public void addEntities(@Nonnull List entities) { for (Entity e : entities) { this.setEntity(e); } } + /** + * Add an entity to be created + */ public abstract boolean setEntity(@Nonnull Entity entity); + /** + * Get the list of chunks that are added manually. This usually indicated the queue is "read only". + */ @Nonnull public abstract List getReadChunks(); + /** + * Add a set of {@link BlockVector2} Chunk coordinates to the Read Chunks list + */ public abstract void addReadChunks(@Nonnull Set readChunks); + /** + * Add a {@link BlockVector2} Chunk coordinate to the Read Chunks list + */ public abstract void addReadChunk(@Nonnull BlockVector2 chunk); + /** + * Whether chunks should be unloaded after being accessed + */ public abstract boolean isUnloadAfter(); + /** + * Set whether chunks should be unloaded after being accessed + */ public abstract void setUnloadAfter(boolean unloadAfter); + /** + * Get the {@link CuboidRegion} designated for direct regeneration + */ @Nullable public abstract CuboidRegion getRegenRegion(); + /** + * Set the {@link CuboidRegion} designated for direct regeneration + */ public abstract void setRegenRegion(@Nonnull CuboidRegion regenRegion); + /** + * Set a specific chunk at the chunk coordinates XZ to be regenerated. + */ public abstract void regenChunk(int x, int z); + /** + * Get the world the queue is writing to + */ @Nullable public abstract World getWorld(); + /** + * Set the queue as having been modified now + */ public final void setModified() { setModified(System.currentTimeMillis()); } + /** + * Enqueue the queue with the {@link GlobalBlockQueue} + */ public boolean enqueue() { return blockQueue.enqueue(this); } + /** + * Start the queue + */ public abstract void start(); + /** + * Cancel the queue. Not yet implemented. + */ public abstract void cancel(); + /** + * Get the task to be run when all chunks have been accessed + */ + public abstract Runnable getCompleteTask(); + + /** + * Set the task to be run when all chunks have been accessed + */ public abstract void setCompleteTask(@Nullable Runnable whenDone); + /** + * Return the chunk consumer set to the queue or null if one is not set + */ + @Nullable public abstract Consumer getChunkConsumer(); + + /** + * Set the Consumer that will + */ public abstract void setChunkConsumer(@Nonnull Consumer consumer); + /** + * Fill a cuboid between two positions with a BlockState + */ public void setCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull BlockState block) { int yMin = Math.min(pos1.getY(), pos2.getY()); int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY())); @@ -169,6 +293,9 @@ public abstract class QueueCoordinator { } } + /** + * Fill a cuboid between two positions with a Pattern + */ public void setCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull Pattern blocks) { int yMin = Math.min(pos1.getY(), pos2.getY()); int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY())); @@ -185,6 +312,9 @@ public abstract class QueueCoordinator { } } + /** + * Fill a cuboid between two positions with a BiomeType + */ public void setBiomeCuboid(@Nonnull Location pos1, @Nonnull Location pos2, @Nonnull BiomeType biome) { int yMin = Math.min(pos1.getY(), pos2.getY()); int yMax = Math.min(255, Math.max(pos1.getY(), pos2.getY())); diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java b/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java index 412883f0b..d1ee80029 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java @@ -44,5 +44,8 @@ public abstract class QueueProvider { }; } + /** + * Get a queue for the given world + */ public abstract QueueCoordinator getNewQueue(@Nonnull World world); } 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 396119763..b4fbc5e40 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java +++ b/Core/src/main/java/com/plotsquared/core/queue/ScopedQueueCoordinator.java @@ -35,6 +35,9 @@ import com.sk89q.worldedit.world.block.BlockState; import javax.annotation.Nonnull; import javax.annotation.Nullable; +/** + * Queue that only sets blocks with a designated area + */ public class ScopedQueueCoordinator extends DelegateQueueCoordinator { private final int minX; private final int minY;