mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 12:16:44 +01:00
Address deprecations in queue/generation code (#3658)
This commit is contained in:
parent
8afcaccb8a
commit
27ffe4fcdc
@ -26,7 +26,7 @@ import com.plotsquared.core.location.UncheckedWorldLocation;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.LimitedRegion;
|
import org.bukkit.generator.LimitedRegion;
|
||||||
import org.bukkit.generator.WorldInfo;
|
import org.bukkit.generator.WorldInfo;
|
||||||
@ -80,7 +80,7 @@ final class BlockStatePopulator extends BlockPopulator {
|
|||||||
worldInfo.getMaxHeight(),
|
worldInfo.getMaxHeight(),
|
||||||
(chunkZ << 4) + 15
|
(chunkZ << 4) + 15
|
||||||
);
|
);
|
||||||
ScopedQueueCoordinator offsetChunkQueue = new ScopedQueueCoordinator(wrapped, min, max);
|
ZeroedDelegateScopedQueueCoordinator offsetChunkQueue = new ZeroedDelegateScopedQueueCoordinator(wrapped, min, max);
|
||||||
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ import com.plotsquared.core.generator.SingleWorldGenerator;
|
|||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -204,7 +204,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
return result.getChunkData();
|
return result.getChunkData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generate(BlockVector2 loc, World world, ScopedQueueCoordinator result) {
|
private void generate(BlockVector2 loc, World world, ZeroedDelegateScopedQueueCoordinator result) {
|
||||||
// Load if improperly loaded
|
// Load if improperly loaded
|
||||||
if (!this.loaded) {
|
if (!this.loaded) {
|
||||||
checkLoaded(world);
|
checkLoaded(world);
|
||||||
|
@ -24,7 +24,7 @@ import com.plotsquared.core.generator.IndependentPlotGenerator;
|
|||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -60,7 +60,7 @@ final class DelegatePlotGenerator extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(final ScopedQueueCoordinator result, PlotArea settings) {
|
public void generateChunk(final ZeroedDelegateScopedQueueCoordinator result, PlotArea settings) {
|
||||||
World world = BukkitUtil.getWorld(this.world);
|
World world = BukkitUtil.getWorld(this.world);
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
int chunkX = min.getX() >> 4;
|
int chunkX = min.getX() >> 4;
|
||||||
|
@ -26,7 +26,7 @@ import com.plotsquared.core.location.UncheckedWorldLocation;
|
|||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
import com.sk89q.worldedit.bukkit.BukkitWorld;
|
||||||
import com.sk89q.worldedit.util.SideEffectSet;
|
import com.sk89q.worldedit.util.SideEffectSet;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
@ -66,7 +66,7 @@ final class LegacyBlockStatePopulator extends BlockPopulator {
|
|||||||
queue.setChunkObject(source);
|
queue.setChunkObject(source);
|
||||||
Location min = UncheckedWorldLocation.at(world.getName(), chunkMinX, world.getMinHeight(), chunkMinZ);
|
Location min = UncheckedWorldLocation.at(world.getName(), chunkMinX, world.getMinHeight(), chunkMinZ);
|
||||||
Location max = UncheckedWorldLocation.at(world.getName(), chunkMinX + 15, world.getMaxHeight(), chunkMinZ + 15);
|
Location max = UncheckedWorldLocation.at(world.getName(), chunkMinX + 15, world.getMaxHeight(), chunkMinZ + 15);
|
||||||
ScopedQueueCoordinator offsetChunkQueue = new ScopedQueueCoordinator(queue, min, max);
|
ZeroedDelegateScopedQueueCoordinator offsetChunkQueue = new ZeroedDelegateScopedQueueCoordinator(queue, min, max);
|
||||||
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
this.plotGenerator.populateChunk(offsetChunkQueue, area);
|
||||||
queue.enqueue();
|
queue.enqueue();
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.plotsquared.bukkit.util.BukkitBlockUtil;
|
|||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.location.ChunkWrapper;
|
import com.plotsquared.core.location.ChunkWrapper;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.AnnotationHelper;
|
import com.plotsquared.core.util.AnnotationHelper;
|
||||||
import com.plotsquared.core.util.ChunkUtil;
|
import com.plotsquared.core.util.ChunkUtil;
|
||||||
import com.plotsquared.core.util.PatternUtil;
|
import com.plotsquared.core.util.PatternUtil;
|
||||||
@ -45,7 +45,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to changes at any time.")
|
||||||
public class GenChunk extends ScopedQueueCoordinator {
|
public class GenChunk extends ZeroedDelegateScopedQueueCoordinator {
|
||||||
|
|
||||||
public final Biome[] biomes;
|
public final Biome[] biomes;
|
||||||
public BlockState[][] result;
|
public BlockState[][] result;
|
||||||
|
@ -30,7 +30,7 @@ import com.plotsquared.core.plot.PlotArea;
|
|||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
@ -257,9 +257,9 @@ public class BukkitRegionManager extends RegionManager {
|
|||||||
map.saveEntitiesOut(Bukkit.getWorld(world.getName()).getChunkAt(x, z), currentPlotClear);
|
map.saveEntitiesOut(Bukkit.getWorld(world.getName()).getChunkAt(x, z), currentPlotClear);
|
||||||
AugmentedUtils.bypass(
|
AugmentedUtils.bypass(
|
||||||
ignoreAugment,
|
ignoreAugment,
|
||||||
() -> ChunkManager.setChunkInPlotArea(null, new RunnableVal<ScopedQueueCoordinator>() {
|
() -> ChunkManager.setChunkInPlotArea(null, new RunnableVal<ZeroedDelegateScopedQueueCoordinator>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(ScopedQueueCoordinator value) {
|
public void run(ZeroedDelegateScopedQueueCoordinator value) {
|
||||||
Location min = value.getMin();
|
Location min = value.getMin();
|
||||||
int bx = min.getX();
|
int bx = min.getX();
|
||||||
int bz = min.getZ();
|
int bz = min.getZ();
|
||||||
|
@ -423,8 +423,7 @@ public class Area extends SubCommand {
|
|||||||
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
|
player.sendMessage(TranslatableCaption.of("setup.setup_finished"));
|
||||||
if (area.getTerrain() != PlotAreaTerrainType.ALL) {
|
if (area.getTerrain() != PlotAreaTerrainType.ALL) {
|
||||||
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world));
|
||||||
queue.setChunkConsumer(chunk -> AugmentedUtils.generate(
|
queue.setChunkConsumer(chunk -> AugmentedUtils.generateChunk(
|
||||||
null,
|
|
||||||
world,
|
world,
|
||||||
chunk.getX(),
|
chunk.getX(),
|
||||||
chunk.getZ(),
|
chunk.getZ(),
|
||||||
@ -796,8 +795,7 @@ public class Area extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
|
QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
|
||||||
queue.setChunkConsumer(chunk -> AugmentedUtils.generate(
|
queue.setChunkConsumer(chunk -> AugmentedUtils.generateChunk(
|
||||||
null,
|
|
||||||
area.getWorldName(),
|
area.getWorldName(),
|
||||||
chunk.getX(),
|
chunk.getX(),
|
||||||
chunk.getZ(),
|
chunk.getZ(),
|
||||||
|
@ -27,7 +27,7 @@ import com.plotsquared.core.plot.PlotManager;
|
|||||||
import com.plotsquared.core.queue.AreaBoundDelegateQueueCoordinator;
|
import com.plotsquared.core.queue.AreaBoundDelegateQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.LocationOffsetDelegateQueueCoordinator;
|
import com.plotsquared.core.queue.LocationOffsetDelegateQueueCoordinator;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.RegionUtil;
|
import com.plotsquared.core.util.RegionUtil;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -161,8 +161,8 @@ public class AugmentedUtils {
|
|||||||
|
|
||||||
// This queue should not be enqueued as it is simply used to restrict block setting, and then delegate to the
|
// This queue should not be enqueued as it is simply used to restrict block setting, and then delegate to the
|
||||||
// actual queue
|
// actual queue
|
||||||
ScopedQueueCoordinator scoped =
|
ZeroedDelegateScopedQueueCoordinator scoped =
|
||||||
new ScopedQueueCoordinator(
|
new ZeroedDelegateScopedQueueCoordinator(
|
||||||
secondaryMask,
|
secondaryMask,
|
||||||
Location.at(world, blockX, area.getMinGenHeight(), blockZ),
|
Location.at(world, blockX, area.getMinGenHeight(), blockZ),
|
||||||
Location.at(world, blockX + 15, area.getMaxGenHeight(), blockZ + 15)
|
Location.at(world, blockX + 15, area.getMaxGenHeight(), blockZ + 15)
|
||||||
@ -176,19 +176,4 @@ public class AugmentedUtils {
|
|||||||
return generationResult;
|
return generationResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated Use {@link AugmentedUtils#generateChunk(String, int, int, QueueCoordinator)} as chunkObject is not required
|
|
||||||
* in the above method
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "6.8.0")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import com.plotsquared.core.inject.factory.HybridPlotWorldFactory;
|
|||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
@ -59,7 +59,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
|
|
||||||
private void placeSchem(
|
private void placeSchem(
|
||||||
HybridPlotWorld world,
|
HybridPlotWorld world,
|
||||||
ScopedQueueCoordinator result,
|
ZeroedDelegateScopedQueueCoordinator result,
|
||||||
short relativeX,
|
short relativeX,
|
||||||
short relativeZ,
|
short relativeZ,
|
||||||
int x,
|
int x,
|
||||||
@ -90,7 +90,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(@NonNull ScopedQueueCoordinator result, @NonNull PlotArea settings) {
|
public void generateChunk(@NonNull ZeroedDelegateScopedQueueCoordinator result, @NonNull PlotArea settings) {
|
||||||
Preconditions.checkNotNull(result, "result cannot be null");
|
Preconditions.checkNotNull(result, "result cannot be null");
|
||||||
Preconditions.checkNotNull(settings, "settings cannot be null");
|
Preconditions.checkNotNull(settings, "settings cannot be null");
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean populateChunk(final ScopedQueueCoordinator result, final PlotArea settings) {
|
public boolean populateChunk(final ZeroedDelegateScopedQueueCoordinator result, final PlotArea settings) {
|
||||||
HybridPlotWorld hybridPlotWorld = (HybridPlotWorld) settings;
|
HybridPlotWorld hybridPlotWorld = (HybridPlotWorld) settings;
|
||||||
if (!hybridPlotWorld.populationNeeded()) {
|
if (!hybridPlotWorld.populationNeeded()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -587,20 +587,6 @@ public class HybridUtils {
|
|||||||
return ey;
|
return ey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Regenerate the road in a chunk in a plot area.
|
|
||||||
*
|
|
||||||
* @param area Plot area to regenerate road for
|
|
||||||
* @param chunk Chunk location to regenerate
|
|
||||||
* @param extend How far to extend setting air above the road
|
|
||||||
* @return if successful
|
|
||||||
* @deprecated use {@link HybridUtils#regenerateRoad(PlotArea, BlockVector2, int, QueueCoordinator)}
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
|
||||||
public boolean regenerateRoad(final PlotArea area, final BlockVector2 chunk, int extend) {
|
|
||||||
return regenerateRoad(area, chunk, extend, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regenerate the road in a chunk in a plot area.
|
* Regenerate the road in a chunk in a plot area.
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@ package com.plotsquared.core.generator;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
@ -44,21 +44,10 @@ public abstract class IndependentPlotGenerator {
|
|||||||
*
|
*
|
||||||
* @param result queue
|
* @param result queue
|
||||||
* @param settings PlotArea (settings)
|
* @param settings PlotArea (settings)
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
public abstract void generateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea settings);
|
||||||
public abstract void generateChunk(ScopedQueueCoordinator result, PlotArea settings);
|
|
||||||
|
|
||||||
/**
|
public boolean populateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea setting) {
|
||||||
* Populates the queue representing a chunk area with tile entities and entities
|
|
||||||
*
|
|
||||||
* @param result Queue to write to
|
|
||||||
* @param settings PlotArea (settings)
|
|
||||||
* @return True if any population occurred
|
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
|
||||||
public boolean populateChunk(ScopedQueueCoordinator result, PlotArea settings) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
@ -52,7 +52,7 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateChunk(ScopedQueueCoordinator result, PlotArea settings) {
|
public void generateChunk(ZeroedDelegateScopedQueueCoordinator result, PlotArea settings) {
|
||||||
SinglePlotArea area = (SinglePlotArea) settings;
|
SinglePlotArea area = (SinglePlotArea) settings;
|
||||||
if (area.VOID) {
|
if (area.VOID) {
|
||||||
Location min = result.getMin();
|
Location min = result.getMin();
|
||||||
|
@ -38,7 +38,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
|||||||
* {@link BlockArrayCacheScopedQueueCoordinator#setOffsetZ(int)}
|
* {@link BlockArrayCacheScopedQueueCoordinator#setOffsetZ(int)}
|
||||||
*/
|
*/
|
||||||
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to change at any time and created for specific use cases.")
|
@AnnotationHelper.ApiDescription(info = "Internal use only. Subject to change at any time and created for specific use cases.")
|
||||||
public class BlockArrayCacheScopedQueueCoordinator extends ScopedQueueCoordinator {
|
public class BlockArrayCacheScopedQueueCoordinator extends ZeroedDelegateScopedQueueCoordinator {
|
||||||
|
|
||||||
private final BlockState[][][] blockStates;
|
private final BlockState[][][] blockStates;
|
||||||
private final int height;
|
private final int height;
|
||||||
|
@ -1,163 +0,0 @@
|
|||||||
/*
|
|
||||||
* PlotSquared, a land and world management plugin for Minecraft.
|
|
||||||
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
|
||||||
* Copyright (C) IntellectualSites team and contributors
|
|
||||||
*
|
|
||||||
* 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 <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.plotsquared.core.queue;
|
|
||||||
|
|
||||||
import com.plotsquared.core.location.Location;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
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.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Queue that is limited to a single chunk. It does not allow a delegate queue and should be treated as a cache for changes to
|
|
||||||
* be set to. Does not support tile entities or entities.
|
|
||||||
*
|
|
||||||
* @deprecated This class is poorly designed and will no longer be used in PlotSquared
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "6.8.0")
|
|
||||||
public class ChunkQueueCoordinator extends ScopedQueueCoordinator {
|
|
||||||
|
|
||||||
public final BiomeType[][][] biomeResult;
|
|
||||||
public final BlockState[][][] result;
|
|
||||||
private final int width;
|
|
||||||
private final int length;
|
|
||||||
private final BlockVector3 bot;
|
|
||||||
private final BlockVector3 top;
|
|
||||||
private final World weWorld;
|
|
||||||
|
|
||||||
public ChunkQueueCoordinator(
|
|
||||||
final @NonNull World weWorld,
|
|
||||||
@NonNull BlockVector3 bot,
|
|
||||||
@NonNull BlockVector3 top,
|
|
||||||
boolean biomes
|
|
||||||
) {
|
|
||||||
super(null, Location.at("", 0, weWorld.getMinY(), 0), Location.at("", 15, weWorld.getMaxY(), 15));
|
|
||||||
this.weWorld = weWorld;
|
|
||||||
this.width = top.getX() - bot.getX() + 1;
|
|
||||||
this.length = top.getZ() - bot.getZ() + 1;
|
|
||||||
this.result = new BlockState[weWorld.getMaxY() - weWorld.getMinY() + 1][width][length];
|
|
||||||
this.biomeResult = biomes ? new BiomeType[weWorld.getMaxY() - weWorld.getMinY() + 1][width][length] : null;
|
|
||||||
this.bot = bot;
|
|
||||||
this.top = top;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NonNull BlockState[][][] getBlocks() {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(int x, int z, @NonNull BiomeType biomeType) {
|
|
||||||
if (this.biomeResult != null) {
|
|
||||||
for (int y = weWorld.getMinY(); y <= weWorld.getMaxY(); y++) {
|
|
||||||
this.storeCacheBiome(x, y, z, biomeType);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(int x, int y, int z, @NonNull BiomeType biomeType) {
|
|
||||||
if (this.biomeResult != null) {
|
|
||||||
this.storeCacheBiome(x, y, z, biomeType);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(int x, int y, int z, @NonNull BlockState id) {
|
|
||||||
this.storeCache(x, y, z, id);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(int x, int y, int z, @NonNull Pattern pattern) {
|
|
||||||
this.storeCache(x, y, z, pattern.applyBlock(BlockVector3.at(x, y, z)).toImmutableState());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void storeCache(final int x, final int y, final int z, final @NonNull BlockState id) {
|
|
||||||
int yIndex = getYIndex(y);
|
|
||||||
BlockState[][] resultY = result[yIndex];
|
|
||||||
if (resultY == null) {
|
|
||||||
result[yIndex] = resultY = new BlockState[length][];
|
|
||||||
}
|
|
||||||
BlockState[] resultYZ = resultY[z];
|
|
||||||
if (resultYZ == null) {
|
|
||||||
resultY[z] = resultYZ = new BlockState[width];
|
|
||||||
}
|
|
||||||
resultYZ[x] = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void storeCacheBiome(final int x, final int y, final int z, final @NonNull BiomeType id) {
|
|
||||||
int yIndex = getYIndex(y);
|
|
||||||
BiomeType[][] resultY = biomeResult[yIndex];
|
|
||||||
if (resultY == null) {
|
|
||||||
biomeResult[yIndex] = resultY = new BiomeType[length][];
|
|
||||||
}
|
|
||||||
BiomeType[] resultYZ = resultY[z];
|
|
||||||
if (resultYZ == null) {
|
|
||||||
resultY[z] = resultYZ = new BiomeType[width];
|
|
||||||
}
|
|
||||||
resultYZ[x] = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(int x, int y, int z, final @NonNull BaseBlock id) {
|
|
||||||
this.storeCache(x, y, z, id.toImmutableState());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable BlockState getBlock(int x, int y, int z) {
|
|
||||||
BlockState[][] blocksY = result[getYIndex(y)];
|
|
||||||
if (blocksY != null) {
|
|
||||||
BlockState[] blocksYZ = blocksY[z];
|
|
||||||
if (blocksYZ != null) {
|
|
||||||
return blocksYZ[x];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @Nullable World getWorld() {
|
|
||||||
return weWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull Location getMax() {
|
|
||||||
return Location.at(getWorld().getName(), top.getX(), top.getY(), top.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NonNull Location getMin() {
|
|
||||||
return Location.at(getWorld().getName(), bot.getX(), bot.getY(), bot.getZ());
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getYIndex(int y) {
|
|
||||||
return y - weWorld.getMinY();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -62,35 +62,17 @@ public abstract class QueueCoordinator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@link ScopedQueueCoordinator} limited to the chunk at the specific chunk Coordinates
|
* Get a {@link ZeroedDelegateScopedQueueCoordinator} limited to the chunk at the specific chunk Coordinates
|
||||||
*
|
*
|
||||||
* @param x chunk x coordinate
|
* @param x chunk x coordinate
|
||||||
* @param z chunk z coordinate
|
* @param z chunk z coordinate
|
||||||
* @return a new {@link ScopedQueueCoordinator}
|
* @return a new {@link ZeroedDelegateScopedQueueCoordinator}
|
||||||
* @deprecated Use {@link ScopedQueueCoordinator#getForChunk(int, int, int, int)}
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.6.0")
|
public ZeroedDelegateScopedQueueCoordinator getForChunk(int x, int z, int minY, int maxY) {
|
||||||
public ScopedQueueCoordinator getForChunk(int x, int z) {
|
|
||||||
if (getWorld() == null) {
|
|
||||||
return getForChunk(x, z, PlotSquared.platform().versionMinHeight(), PlotSquared.platform().versionMaxHeight());
|
|
||||||
}
|
|
||||||
return getForChunk(x, z, getWorld().getMinY(), getWorld().getMaxY());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a {@link ScopedQueueCoordinator} limited to the chunk at the specific chunk Coordinates
|
|
||||||
*
|
|
||||||
* @param x chunk x coordinate
|
|
||||||
* @param z chunk z coordinate
|
|
||||||
* @return a new {@link ScopedQueueCoordinator}
|
|
||||||
* @since 6.6.0
|
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
|
||||||
*/
|
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
|
||||||
public ScopedQueueCoordinator getForChunk(int x, int z, int minY, int maxY) {
|
|
||||||
int bx = x << 4;
|
int bx = x << 4;
|
||||||
int bz = z << 4;
|
int bz = z << 4;
|
||||||
return new ScopedQueueCoordinator(this, Location.at(getWorld().getName(), bx, minY, bz),
|
return new ZeroedDelegateScopedQueueCoordinator(this, Location.at(getWorld().getName(), bx, minY, bz),
|
||||||
Location.at(getWorld().getName(), bx + 15, maxY, bz + 15)
|
Location.at(getWorld().getName(), bx + 15, maxY, bz + 15)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -28,13 +28,13 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
|||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue that only sets blocks with a designated X-Z area, will accept any Y values. Requires all blocks be set normalized in
|
* Queue that only sets blocks with a designated X-Z area, will accept any Y values. Requires all blocks be set normalized to
|
||||||
* the x and z directions, i.e. starting from 0,0. An offset of the minimum point of the region will then be applied to x and z.
|
* zero in the x and z directions, i.e. starting from 0,0. An offset of the minimum point of the region will then be applied to
|
||||||
|
* x and z.
|
||||||
*
|
*
|
||||||
* @deprecated This should be renamed to NormalizedScopedQueueCoordinator or something.
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.8.0")
|
public class ZeroedDelegateScopedQueueCoordinator extends DelegateQueueCoordinator {
|
||||||
public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
|
||||||
|
|
||||||
private final Location min;
|
private final Location min;
|
||||||
private final Location max;
|
private final Location max;
|
||||||
@ -49,8 +49,10 @@ public class ScopedQueueCoordinator extends DelegateQueueCoordinator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new ScopedQueueCoordinator instance that delegates to a given QueueCoordinator. Locations are inclusive.
|
* Create a new ScopedQueueCoordinator instance that delegates to a given QueueCoordinator. Locations are inclusive.
|
||||||
|
*
|
||||||
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
public ScopedQueueCoordinator(@Nullable QueueCoordinator parent, @NonNull Location min, @NonNull Location max) {
|
public ZeroedDelegateScopedQueueCoordinator(@Nullable QueueCoordinator parent, @NonNull Location min, @NonNull Location max) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
@ -21,7 +21,7 @@ package com.plotsquared.core.util;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.queue.QueueCoordinator;
|
import com.plotsquared.core.queue.QueueCoordinator;
|
||||||
import com.plotsquared.core.queue.ScopedQueueCoordinator;
|
import com.plotsquared.core.queue.ZeroedDelegateScopedQueueCoordinator;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
@ -32,16 +32,16 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
|
|
||||||
public abstract class ChunkManager {
|
public abstract class ChunkManager {
|
||||||
|
|
||||||
private static final Map<BlockVector2, RunnableVal<ScopedQueueCoordinator>> forceChunks = new ConcurrentHashMap<>();
|
private static final Map<BlockVector2, RunnableVal<ZeroedDelegateScopedQueueCoordinator>> forceChunks = new ConcurrentHashMap<>();
|
||||||
private static final Map<BlockVector2, RunnableVal<ScopedQueueCoordinator>> addChunks = new ConcurrentHashMap<>();
|
private static final Map<BlockVector2, RunnableVal<ZeroedDelegateScopedQueueCoordinator>> addChunks = new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
@Deprecated(forRemoval = true, since = "6.9.0")
|
||||||
public static void setChunkInPlotArea(
|
public static void setChunkInPlotArea(
|
||||||
RunnableVal<ScopedQueueCoordinator> force,
|
RunnableVal<ZeroedDelegateScopedQueueCoordinator> force,
|
||||||
RunnableVal<ScopedQueueCoordinator> add,
|
RunnableVal<ZeroedDelegateScopedQueueCoordinator> add,
|
||||||
String world,
|
String world,
|
||||||
BlockVector2 loc
|
BlockVector2 loc
|
||||||
) {
|
) {
|
||||||
@ -50,8 +50,8 @@ public abstract class ChunkManager {
|
|||||||
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
||||||
int blockX = loc.getX() << 4;
|
int blockX = loc.getX() << 4;
|
||||||
int blockZ = loc.getZ() << 4;
|
int blockZ = loc.getZ() << 4;
|
||||||
ScopedQueueCoordinator scoped =
|
ZeroedDelegateScopedQueueCoordinator scoped =
|
||||||
new ScopedQueueCoordinator(
|
new ZeroedDelegateScopedQueueCoordinator(
|
||||||
queue,
|
queue,
|
||||||
Location.at(world, blockX, weWorld.getMinY(), blockZ),
|
Location.at(world, blockX, weWorld.getMinY(), blockZ),
|
||||||
Location.at(world, blockX + 15, weWorld.getMaxY(), blockZ + 15)
|
Location.at(world, blockX + 15, weWorld.getMaxY(), blockZ + 15)
|
||||||
@ -77,11 +77,10 @@ public abstract class ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
public static boolean preProcessChunk(BlockVector2 loc, ZeroedDelegateScopedQueueCoordinator queue) {
|
||||||
public static boolean preProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
final RunnableVal<ZeroedDelegateScopedQueueCoordinator> forceChunk = forceChunks.get(loc);
|
||||||
final RunnableVal<ScopedQueueCoordinator> forceChunk = forceChunks.get(loc);
|
|
||||||
if (forceChunk != null) {
|
if (forceChunk != null) {
|
||||||
forceChunk.run(queue);
|
forceChunk.run(queue);
|
||||||
forceChunks.remove(loc);
|
forceChunks.remove(loc);
|
||||||
@ -91,11 +90,10 @@ public abstract class ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated {@link ScopedQueueCoordinator} will be renamed in v7.
|
* @since TODO
|
||||||
*/
|
*/
|
||||||
@Deprecated(forRemoval = true, since = "6.9.0")
|
public static boolean postProcessChunk(BlockVector2 loc, ZeroedDelegateScopedQueueCoordinator queue) {
|
||||||
public static boolean postProcessChunk(BlockVector2 loc, ScopedQueueCoordinator queue) {
|
final RunnableVal<ZeroedDelegateScopedQueueCoordinator> addChunk = forceChunks.get(loc);
|
||||||
final RunnableVal<ScopedQueueCoordinator> addChunk = forceChunks.get(loc);
|
|
||||||
if (addChunk != null) {
|
if (addChunk != null) {
|
||||||
addChunk.run(queue);
|
addChunk.run(queue);
|
||||||
addChunks.remove(loc);
|
addChunks.remove(loc);
|
||||||
|
Loading…
Reference in New Issue
Block a user