Address some deprecations for regions and biome setting

This commit is contained in:
dordsor21
2022-02-07 13:57:10 +00:00
committed by Jordan
parent c4db968830
commit c8327bfa40
11 changed files with 40 additions and 96 deletions

View File

@ -371,7 +371,8 @@ public class Area extends SubCommand {
int lower = (area.ROAD_WIDTH & 1) == 0 ? area.ROAD_WIDTH / 2 - 1 : area.ROAD_WIDTH / 2;
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
// Height doesn't matter for this region
final CuboidRegion region = RegionUtil.createRegion(bx, tx, 0, 0, bz, tz);
final Set<PlotArea> areas = this.plotAreaManager.getPlotAreasSet(area.getWorldName(), region);
if (!areas.isEmpty()) {
player.sendMessage(

View File

@ -180,12 +180,12 @@ public class Trim extends SubCommand {
int bx = cbx << 4;
int bz = cbz << 4;
CuboidRegion region =
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
RegionUtil.createRegion(bx, bx + 511, 0, 0, bz, bz + 511);
for (Plot plot : PlotQuery.newQuery().inWorld(world)) {
Location bot = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs();
CuboidRegion plotReg = RegionUtil
.createRegion(bot.getX(), top.getX(), bot.getZ(), top.getZ());
.createRegion(bot.getX(), top.getX(), 0, 0, bot.getZ(), top.getZ());
if (!RegionUtil.intersects(region, plotReg)) {
continue;
}

View File

@ -70,7 +70,7 @@ public class AugmentedUtils {
final int blockZ = chunkZ << 4;
// Create a region that contains the
// entire chunk
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, 0, 0, blockZ, blockZ + 15);
// Query for plot areas in the chunk
final Set<PlotArea> areas = PlotSquared.get().getPlotAreaManager().getPlotAreasSet(world, region);
if (areas.isEmpty()) {

View File

@ -148,7 +148,7 @@ public class HybridPlotManager extends ClassicPlotManager {
(pos1.getX() + pos2.getX()) / 2,
(pos1.getZ() + pos2.getZ()) / 2
), biome)) {
WorldUtil.setBiome(hybridPlotWorld, pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(), biome);
WorldUtil.setBiome(hybridPlotWorld.getWorldName(), new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3()), biome);
}
}

View File

@ -89,11 +89,15 @@ public class PlotCluster {
}
private void setRegion() {
this.region = RegionUtil.createRegion(this.pos1.getX(), this.pos2.getX(),
this.region = RegionUtil.createRegion(this.pos1.getX(), this.pos2.getX(), 0, 0,
this.pos1.getY(), this.pos2.getY()
);
}
/**
* Returns a region of PlotIDs
*/
@Deprecated
public CuboidRegion getRegion() {
return this.region;
}

View File

@ -407,36 +407,12 @@ public abstract class RegionManager {
final PlotArea area,
final Runnable whenDone
) {
Location pos1 = Location
.at(
area.getWorldName(),
region.getMinimumPoint().getX() - extendBiome,
region.getMinimumPoint().getY(),
region.getMinimumPoint().getZ() - extendBiome
);
Location pos2 = Location
.at(
area.getWorldName(),
region.getMaximumPoint().getX() + extendBiome,
region.getMaximumPoint().getY(),
region.getMaximumPoint().getZ() + extendBiome
);
final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(area.getWorldName()));
final int minX = pos1.getX();
final int minZ = pos1.getZ();
final int maxX = pos2.getX();
final int maxZ = pos2.getZ();
queue.addReadChunks(region.getChunks());
queue.setChunkConsumer(blockVector2 -> {
final int cx = blockVector2.getX() << 4;
final int cz = blockVector2.getZ() << 4;
WorldUtil.setBiome(
area,
Math.max(minX, cx),
Math.max(minZ, cz),
Math.min(maxX, cx + 15),
Math.min(maxZ, cz + 15),
area.getWorldName(),
region,
biome
);
worldUtil.refreshChunk(blockVector2.getBlockX(), blockVector2.getBlockZ(), area.getWorldName());

View File

@ -25,6 +25,7 @@
*/
package com.plotsquared.core.util;
import com.fastasyncworldedit.core.regions.RegionWrapper;
import com.plotsquared.core.PlotSquared;
import com.plotsquared.core.configuration.Settings;
import com.plotsquared.core.location.Location;
@ -91,10 +92,7 @@ public class WEManager {
Location location = player.getLocation();
String world = location.getWorldName();
if (!PlotSquared.get().getPlotAreaManager().hasPlotArea(world)) {
regions.add(RegionUtil
.createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
Integer.MAX_VALUE
));
regions.add(RegionWrapper.GLOBAL());
return regions;
}
PlotArea area = player.getApplicablePlotArea();

View File

@ -30,7 +30,6 @@ import com.plotsquared.core.configuration.caption.Caption;
import com.plotsquared.core.location.Location;
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea;
import com.plotsquared.core.util.task.RunnableVal;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag;
@ -40,6 +39,7 @@ import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType;
@ -79,12 +79,13 @@ public abstract class WorldUtil {
* @param p2x Max X
* @param p2z Max Z
* @param biome Biome
* @deprecated use {@link WorldUtil#setBiome(PlotArea, int, int, int, int, BiomeType)}
* @deprecated use {@link WorldUtil#setBiome(String, CuboidRegion, BiomeType)}
*/
@Deprecated(forRemoval = true)
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, BiomeType biome) {
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(255);
World weWorld = PlotSquared.platform().worldUtil().getWeWorld(world);
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3(weWorld.getMinY());
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(weWorld.getMaxY());
CuboidRegion region = new CuboidRegion(pos1, pos2);
PlotSquared.platform().worldUtil().setBiomes(world, region, biome);
}
@ -92,19 +93,13 @@ public abstract class WorldUtil {
/**
* Set the biome in a region
*
* @param area Plot area
* @param p1x Min X
* @param p1z Min Z
* @param p2x Max X
* @param p2z Max Z
* @param biome Biome
* @param world World name
* @param region Region
* @param biome Biome
* @since TODO
*/
public static void setBiome(PlotArea area, int p1x, int p1z, int p2x, int p2z, BiomeType biome) {
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3(area.getMinGenHeight());
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(area.getMaxGenHeight());
CuboidRegion region = new CuboidRegion(pos1, pos2);
PlotSquared.platform().worldUtil().setBiomes(area.getWorldName(), region, biome);
public static void setBiome(String world, final CuboidRegion region, BiomeType biome) {
PlotSquared.platform().worldUtil().setBiomes(world, region, biome);
}
/**
@ -238,11 +233,14 @@ public abstract class WorldUtil {
/**
* Set the biome in a region
*
* @param world World name
* @param region Region
* @param biome New biome
* @param worldName World name
* @param region Region
* @param biome New biome
*/
public abstract void setBiomes(@NonNull String world, @NonNull CuboidRegion region, @NonNull BiomeType biome);
public void setBiomes(@NonNull String worldName, @NonNull CuboidRegion region, @NonNull BiomeType biome) {
final World world = getWeWorld(worldName);
region.iterator().forEachRemaining(bv -> world.setBiome(bv, biome));
}
/**
* Get the WorldEdit {@link com.sk89q.worldedit.world.World} corresponding to a world name