Use CuboidRegion instead of RegionWrapper

This commit is contained in:
Jesse Boyd 2019-11-04 21:08:33 +00:00
parent ba3ff08d6c
commit 88732bb88c
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
45 changed files with 357 additions and 348 deletions

View File

@ -22,7 +22,7 @@ public final class Reflection {
/** /**
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages). * Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
*/ */
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<>(); private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<>();
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<>(); private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<>();
@ -40,10 +40,10 @@ import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil;
/** /**
* Gets the version string from the package name of the CraftBukkit server implementation. * Gets the version string from the package name of the CraftBukkit server implementation.
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
* This is needed to bypass the JAR package name changing on each update. * This is needed to bypass the JAR package name changing on each update.
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
* *
* @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>. * @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>.
*/ */
@ -86,7 +86,7 @@ import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil;
* *
* @param className The name of the class, excluding the package, within OBC. This name may contain a subpackage name, such as {@code inventory.CraftItemStack}. * @param className The name of the class, excluding the package, within OBC. This name may contain a subpackage name, such as {@code inventory.CraftItemStack}.
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
* @return The class instance representing the specified OBC class, or {@code null} if it could not be loaded. * @return The class instance representing the specified OBC class, or {@code null} if it could not be loaded.
*/ */
public synchronized static Class<?> getOBCClass(String className) { public synchronized static Class<?> getOBCClass(String className) {

View File

@ -9,7 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.bukkit.World; import org.bukkit.World;

View File

@ -9,11 +9,12 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotLoc; import com.github.intellectualsites.plotsquared.plot.object.PlotLoc;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
@ -44,15 +45,15 @@ import java.util.concurrent.CompletableFuture;
public class BukkitChunkManager extends ChunkManager { public class BukkitChunkManager extends ChunkManager {
public static boolean isIn(RegionWrapper region, int x, int z) { public static boolean isIn(CuboidRegion region, int x, int z) {
return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ; return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX() && z >= region.getMinimumPoint().getZ() && z <= region.getMaximumPoint().getZ();
} }
public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2,
RegionWrapper r1, RegionWrapper r2) { CuboidRegion r1, CuboidRegion r2) {
ContentMap map = new ContentMap(); ContentMap map = new ContentMap();
int relX = r2.minX - r1.minX; int relX = r2.getMinimumPoint().getX() - r1.getMinimumPoint().getX();
int relZ = r2.minZ - r1.minZ; int relZ = r2.getMinimumPoint().getZ() - r1.getMinimumPoint().getZ();
map.saveEntitiesIn(pos1, r1, relX, relZ, true); map.saveEntitiesIn(pos1, r1, relX, relZ, true);
map.saveEntitiesIn(pos2, r2, -relX, -relZ, true); map.saveEntitiesIn(pos2, r2, -relX, -relZ, true);
@ -69,8 +70,8 @@ public class BukkitChunkManager extends ChunkManager {
LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false); LocalBlockQueue queue1 = GlobalBlockQueue.IMP.getNewQueue(worldName1, false);
LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false); LocalBlockQueue queue2 = GlobalBlockQueue.IMP.getNewQueue(worldName2, false);
for (int x = Math.max(r1.minX, sx); x <= Math.min(r1.maxX, sx + 15); x++) { for (int x = Math.max(r1.getMinimumPoint().getX(), sx); x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) {
for (int z = Math.max(r1.minZ, sz); z <= Math.min(r1.maxZ, sz + 15); z++) { for (int z = Math.max(r1.getMinimumPoint().getZ(), sz); z <= Math.min(r1.getMaximumPoint().getZ(), sz + 15); z++) {
for (int y = 0; y < 256; y++) { for (int y = 0; y < 256; y++) {
Block block1 = world1.getBlockAt(x, y, z); Block block1 = world1.getBlockAt(x, y, z);
BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z)); BaseBlock baseBlock1 = bukkitWorld1.getFullBlock(BlockVector3.at(x, y, z));
@ -198,8 +199,8 @@ public class BukkitChunkManager extends ChunkManager {
final int relX = newPos.getX() - pos1.getX(); final int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ(); final int relZ = newPos.getZ() - pos1.getZ();
final RegionWrapper region = final CuboidRegion region =
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final World oldWorld = Bukkit.getWorld(pos1.getWorld()); final World oldWorld = Bukkit.getWorld(pos1.getWorld());
final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld); final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld);
final World newWorld = Bukkit.getWorld(newPos.getWorld()); final World newWorld = Bukkit.getWorld(newPos.getWorld());
@ -350,8 +351,8 @@ public class BukkitChunkManager extends ChunkManager {
if (checkX2 && checkZ2) { if (checkX2 && checkZ2) {
map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); // map.saveRegion(bukkitWorldObj, xxt2, xxt, zzt2, zzt); //
} }
RegionWrapper currentPlotClear = CuboidRegion currentPlotClear =
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
map.saveEntitiesOut(chunkObj, currentPlotClear); map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment, AugmentedUtils.bypass(ignoreAugment,
() -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() { () -> setChunkInPlotArea(null, new RunnableVal<ScopedLocalBlockQueue>() {
@ -434,10 +435,10 @@ public class BukkitChunkManager extends ChunkManager {
@Override public void swap(Location bot1, Location top1, Location bot2, Location top2, @Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
final Runnable whenDone) { final Runnable whenDone) {
RegionWrapper region1 = CuboidRegion region1 =
new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ()); RegionUtil.createRegion(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
RegionWrapper region2 = CuboidRegion region2 =
new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ()); RegionUtil.createRegion(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
final World world1 = Bukkit.getWorld(bot1.getWorld()); final World world1 = Bukkit.getWorld(bot1.getWorld());
World world2 = Bukkit.getWorld(bot2.getWorld()); World world2 = Bukkit.getWorld(bot2.getWorld());
@ -622,7 +623,7 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
void saveEntitiesOut(Chunk chunk, RegionWrapper region) { void saveEntitiesOut(Chunk chunk, CuboidRegion region) {
for (Entity entity : chunk.getEntities()) { for (Entity entity : chunk.getEntities()) {
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);
int x = location.getX(); int x = location.getX();
@ -639,11 +640,11 @@ public class BukkitChunkManager extends ChunkManager {
} }
} }
void saveEntitiesIn(Chunk chunk, RegionWrapper region) { void saveEntitiesIn(Chunk chunk, CuboidRegion region) {
saveEntitiesIn(chunk, region, 0, 0, false); saveEntitiesIn(chunk, region, 0, 0, false);
} }
void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, void saveEntitiesIn(Chunk chunk, CuboidRegion region, int offsetX, int offsetZ,
boolean delete) { boolean delete) {
for (Entity entity : chunk.getEntities()) { for (Entity entity : chunk.getEntities()) {
Location location = BukkitUtil.getLocation(entity); Location location = BukkitUtil.getLocation(entity);

View File

@ -8,7 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.HybridUtils;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@ -34,7 +34,7 @@ import java.util.Set;
public class BukkitHybridUtils extends HybridUtils { public class BukkitHybridUtils extends HybridUtils {
@Override public void analyzeRegion(final String world, final RegionWrapper region, @Override public void analyzeRegion(final String world, final CuboidRegion region,
final RunnableVal<PlotAnalysis> whenDone) { final RunnableVal<PlotAnalysis> whenDone) {
// int diff, int variety, int vertices, int rotation, int height_sd // int diff, int variety, int vertices, int rotation, int height_sd
/* /*
@ -56,8 +56,8 @@ public class BukkitHybridUtils extends HybridUtils {
return; return;
} }
final Location bot = new Location(world, region.minX, region.minY, region.minZ); final Location bot = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
final Location top = new Location(world, region.maxX, region.maxY, region.maxZ); final Location top = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
final int bx = bot.getX(); final int bx = bot.getX();
final int bz = bot.getZ(); final int bz = bot.getZ();

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.bukkit.util;
import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper; import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler;
@ -35,7 +35,7 @@ import java.util.stream.IntStream;
*/ */
public class BukkitSchematicHandler extends SchematicHandler { public class BukkitSchematicHandler extends SchematicHandler {
@Override public void getCompoundTag(final String world, final Set<RegionWrapper> regions, @Override public void getCompoundTag(final String world, final Set<CuboidRegion> regions,
final RunnableVal<CompoundTag> whenDone) { final RunnableVal<CompoundTag> whenDone) {
// async // async
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@ -74,7 +74,7 @@ public class BukkitSchematicHandler extends SchematicHandler {
List<CompoundTag> tileEntities = new ArrayList<>(); List<CompoundTag> tileEntities = new ArrayList<>();
ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length); ByteArrayOutputStream buffer = new ByteArrayOutputStream(width * height * length);
// Queue // Queue
final ArrayDeque<RegionWrapper> queue = new ArrayDeque<>(regions); final ArrayDeque<CuboidRegion> queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override public void run() { @Override public void run() {
if (queue.isEmpty()) { if (queue.isEmpty()) {
@ -95,9 +95,9 @@ public class BukkitSchematicHandler extends SchematicHandler {
return; return;
} }
final Runnable regionTask = this; final Runnable regionTask = this;
RegionWrapper region = queue.poll(); CuboidRegion region = queue.poll();
Location pos1 = new Location(world, region.minX, region.minY, region.minZ); Location pos1 = new Location(world, region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ); Location pos2 = new Location(world, region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int sy = pos1.getY(); final int sy = pos1.getY();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();

View File

@ -6,14 +6,14 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem; import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.StringComparison; import com.github.intellectualsites.plotsquared.plot.util.StringComparison;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -428,12 +428,12 @@ import java.util.Set;
} }
@Override @Override
public void setBiomes(@NonNull final String worldName, @NonNull final RegionWrapper region, public void setBiomes(@NonNull final String worldName, @NonNull final CuboidRegion region,
@NonNull final String biomeString) { @NonNull final String biomeString) {
final World world = getWorld(worldName); final World world = getWorld(worldName);
final Biome biome = Biome.valueOf(biomeString.toUpperCase()); final Biome biome = Biome.valueOf(biomeString.toUpperCase());
for (int x = region.minX; x <= region.maxX; x++) { for (int x = region.getMinimumPoint().getX(); x <= region.getMaximumPoint().getX(); x++) {
for (int z = region.minZ; z <= region.maxZ; z++) { for (int z = region.getMinimumPoint().getZ(); z <= region.getMaximumPoint().getZ(); z++) {
world.setBiome(x, z, biome); world.setBiome(x, z, biome);
} }
} }

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.bukkit.object.schematic.StateWra
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.BasicLocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper; import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;

View File

@ -88,11 +88,11 @@ public interface IPlotMain extends ILogger {
/** /**
* Gets the NMS package prefix. * Gets the NMS package prefix.
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
* *
* @return The NMS package prefix * @return The NMS package prefix
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
*/ */
String getNMSPackage(); String getNMSPackage();

View File

@ -29,7 +29,7 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotFilter;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.StringWrapper; import com.github.intellectualsites.plotsquared.plot.object.StringWrapper;
import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.DefaultPlotAreaManager;
import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager; import com.github.intellectualsites.plotsquared.plot.object.worlds.PlotAreaManager;
@ -2008,7 +2008,7 @@ import java.util.zip.ZipInputStream;
return Collections.unmodifiableSet(result); return Collections.unmodifiableSet(result);
} }
public Set<PlotArea> getPlotAreas(final String world, final RegionWrapper region) { public Set<PlotArea> getPlotAreas(final String world, final CuboidRegion region) {
final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region); final PlotArea[] areas = plotAreaManager.getPlotAreas(world, region);
final Set<PlotArea> set = new HashSet<>(); final Set<PlotArea> set = new HashSet<>();
Collections.addAll(set, areas); Collections.addAll(set, areas);

View File

@ -12,7 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotMessage; import com.github.intellectualsites.plotsquared.plot.object.PlotMessage;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.object.SetupObject; import com.github.intellectualsites.plotsquared.plot.object.SetupObject;
@ -99,7 +100,7 @@ import java.util.Set;
area.ROAD_WIDTH / 2; area.ROAD_WIDTH / 2;
final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetX = bx - (area.ROAD_WIDTH == 0 ? 0 : lower);
final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower); final int offsetZ = bz - (area.ROAD_WIDTH == 0 ? 0 : lower);
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz); final CuboidRegion region = RegionUtil.createRegion(bx, tx, bz, tz);
Set<PlotArea> areas = Set<PlotArea> areas =
PlotSquared.get().getPlotAreas(area.worldname, region); PlotSquared.get().getPlotAreas(area.worldname, region);
if (!areas.isEmpty()) { if (!areas.isEmpty()) {
@ -460,10 +461,10 @@ import java.util.Set;
if (area.TYPE != 2) { if (area.TYPE != 2) {
center = WorldUtil.IMP.getSpawn(area.worldname); center = WorldUtil.IMP.getSpawn(area.worldname);
} else { } else {
RegionWrapper region = area.getRegion(); CuboidRegion region = area.getRegion();
center = center =
new Location(area.worldname, region.minX + (region.maxX - region.minX) / 2, new Location(area.worldname, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.minZ + (region.maxZ - region.minZ) / 2); 0, region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP center.setY(1 + WorldUtil.IMP
.getHighestBlock(area.worldname, center.getX(), center.getZ())); .getHighestBlock(area.worldname, center.getX(), center.getZ()));
} }

View File

@ -6,7 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
@ -176,18 +177,18 @@ import java.util.Set;
} }
int bx = cbx << 4; int bx = cbx << 4;
int bz = cbz << 4; int bz = cbz << 4;
RegionWrapper region = new RegionWrapper(bx, bx + 511, bz, bz + 511); CuboidRegion region = RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
for (Plot plot : PlotSquared.get().getPlots(world)) { for (Plot plot : PlotSquared.get().getPlots(world)) {
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs(); Location top = plot.getExtendedTopAbs();
RegionWrapper plotReg = CuboidRegion plotReg =
new RegionWrapper(bot.getX(), top.getX(), bot.getZ(), RegionUtil.createRegion(bot.getX(), top.getX(), bot.getZ(),
top.getZ()); top.getZ());
if (!region.intersects(plotReg)) { if (!RegionUtil.intersects(region, plotReg)) {
continue; continue;
} }
for (int x = plotReg.minX >> 4; x <= plotReg.maxX >> 4; x++) { for (int x = plotReg.getMinimumPoint().getX() >> 4; x <= plotReg.getMaximumPoint().getX() >> 4; x++) {
for (int z = plotReg.minZ >> 4; z <= plotReg.maxZ >> 4; z++) { for (int z = plotReg.getMinimumPoint().getZ() >> 4; z <= plotReg.getMaximumPoint().getZ() >> 4; z++) {
BlockVector2 loc = BlockVector2.at(x, z); BlockVector2 loc = BlockVector2.at(x, z);
chunks.remove(loc); chunks.remove(loc);
} }

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.flag;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;

View File

@ -4,7 +4,8 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.DelegateLocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
@ -33,7 +34,7 @@ public class AugmentedUtils {
final int blockX = chunkX << 4; final int blockX = chunkX << 4;
final int blockZ = chunkZ << 4; final int blockZ = chunkZ << 4;
RegionWrapper region = new RegionWrapper(blockX, blockX + 15, blockZ, blockZ + 15); CuboidRegion region = RegionUtil.createRegion(blockX, blockX + 15, blockZ, blockZ + 15);
Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region); Set<PlotArea> areas = PlotSquared.get().getPlotAreas(world, region);
if (areas.isEmpty()) { if (areas.isEmpty()) {
return false; return false;
@ -59,10 +60,10 @@ public class AugmentedUtils {
int tzz; int tzz;
// gen // gen
if (area.TYPE == 2) { if (area.TYPE == 2) {
bxx = Math.max(0, area.getRegion().minX - blockX); bxx = Math.max(0, area.getRegion().getMinimumPoint().getX() - blockX);
bzz = Math.max(0, area.getRegion().minZ - blockZ); bzz = Math.max(0, area.getRegion().getMinimumPoint().getZ() - blockZ);
txx = Math.min(15, area.getRegion().maxX - blockX); txx = Math.min(15, area.getRegion().getMaximumPoint().getX() - blockX);
tzz = Math.min(15, area.getRegion().maxZ - blockZ); tzz = Math.min(15, area.getRegion().getMaximumPoint().getZ() - blockZ);
primaryMask = new DelegateLocalBlockQueue(queue) { primaryMask = new DelegateLocalBlockQueue(queue) {
@Override public boolean setBlock(int x, int y, int z, BlockState id) { @Override public boolean setBlock(int x, int y, int z, BlockState id) {
if (area.contains(x, z)) { if (area.contains(x, z)) {

View File

@ -6,9 +6,9 @@ import com.github.intellectualsites.plotsquared.plot.object.Direction;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
@ -59,11 +59,11 @@ public class ClassicPlotManager extends SquarePlotManager {
Plot plot = classicPlotWorld.getPlotAbs(plotId); Plot plot = classicPlotWorld.getPlotAbs(plotId);
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT, region.minZ); new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), classicPlotWorld.PLOT_HEIGHT, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT, region.maxZ); new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), classicPlotWorld.PLOT_HEIGHT, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
} }
@ -77,9 +77,9 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -92,10 +92,10 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
int maxY = getWorldHeight(); int maxY = getWorldHeight();
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = Location pos1 =
new Location(classicPlotWorld.worldname, region.minX, classicPlotWorld.PLOT_HEIGHT + 1, region.minZ); new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), classicPlotWorld.PLOT_HEIGHT + 1, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -107,10 +107,10 @@ public class ClassicPlotManager extends SquarePlotManager {
return false; return false;
} }
LocalBlockQueue queue = classicPlotWorld.getQueue(false); LocalBlockQueue queue = classicPlotWorld.getQueue(false);
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, 1, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), 1, region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(classicPlotWorld.worldname, region.maxX, classicPlotWorld.PLOT_HEIGHT - 1, region.maxZ); new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), classicPlotWorld.PLOT_HEIGHT - 1, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
return queue.enqueue(); return queue.enqueue();
@ -173,9 +173,9 @@ public class ClassicPlotManager extends SquarePlotManager {
} }
} }
if (plot.isBasePlot()) { if (plot.isBasePlot()) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
Location pos1 = new Location(classicPlotWorld.worldname, region.minX, maxY, region.minZ); Location pos1 = new Location(classicPlotWorld.worldname, region.getMinimumPoint().getX(), maxY, region.getMinimumPoint().getZ());
Location pos2 = new Location(classicPlotWorld.worldname, region.maxX, maxY, region.maxZ); Location pos2 = new Location(classicPlotWorld.worldname, region.getMaximumPoint().getX(), maxY, region.getMaximumPoint().getZ());
queue.setCuboid(pos1, pos2, blocks); queue.setCuboid(pos1, pos2, blocks);
} }
} }

View File

@ -7,7 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.BlockBucket; import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Field; import java.lang.reflect.Field;

View File

@ -7,7 +7,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;

View File

@ -12,7 +12,7 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;

View File

@ -10,7 +10,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotManager; import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
@ -45,11 +46,11 @@ public abstract class HybridUtils {
public static PlotArea area; public static PlotArea area;
public static boolean UPDATE = false; public static boolean UPDATE = false;
public abstract void analyzeRegion(String world, RegionWrapper region, public abstract void analyzeRegion(String world, CuboidRegion region,
RunnableVal<PlotAnalysis> whenDone); RunnableVal<PlotAnalysis> whenDone);
public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) { public void analyzePlot(final Plot origin, final RunnableVal<PlotAnalysis> whenDone) {
final ArrayDeque<RegionWrapper> zones = new ArrayDeque<>(origin.getRegions()); final ArrayDeque<CuboidRegion> zones = new ArrayDeque<>(origin.getRegions());
final ArrayList<PlotAnalysis> analysis = new ArrayList<>(); final ArrayList<PlotAnalysis> analysis = new ArrayList<>();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
@ -97,7 +98,7 @@ public abstract class HybridUtils {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = zones.poll(); CuboidRegion region = zones.poll();
final Runnable task = this; final Runnable task = this;
analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() { analyzeRegion(origin.getWorldName(), region, new RunnableVal<PlotAnalysis>() {
@Override public void run(PlotAnalysis value) { @Override public void run(PlotAnalysis value) {
@ -271,10 +272,10 @@ public abstract class HybridUtils {
int tz = sz - 1; int tz = sz - 1;
int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy); int ty = get_ey(plotManager, queue, sx, ex, bz, tz, sy);
Set<RegionWrapper> sideRoad = Set<CuboidRegion> sideRoad =
new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ey, sz, ez))); new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ey, sz, ez)));
final Set<RegionWrapper> intersection = final Set<CuboidRegion> intersection =
new HashSet<>(Collections.singletonList(new RegionWrapper(sx, ex, sy, ty, bz, tz))); new HashSet<>(Collections.singletonList(RegionUtil.createRegion(sx, ex, sy, ty, bz, tz)));
final String dir = final String dir =
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea() "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea()

View File

@ -6,13 +6,14 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; import com.github.intellectualsites.plotsquared.plot.util.ChunkManager;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set;
/** /**
* A plot manager with a square grid layout, with square shaped plots. * A plot manager with a square grid layout, with square shaped plots.
@ -28,20 +29,20 @@ public abstract class SquarePlotManager extends GridPlotManager {
@Override @Override
public boolean clearPlot(final Plot plot, final Runnable whenDone) { public boolean clearPlot(final Plot plot, final Runnable whenDone) {
final HashSet<RegionWrapper> regions = plot.getRegions(); final Set<CuboidRegion> regions = plot.getRegions();
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
if (regions.isEmpty()) { if (regions.isEmpty()) {
whenDone.run(); whenDone.run();
return; return;
} }
Iterator<RegionWrapper> iterator = regions.iterator(); Iterator<CuboidRegion> iterator = regions.iterator();
RegionWrapper region = iterator.next(); CuboidRegion region = iterator.next();
iterator.remove(); iterator.remove();
Location pos1 = Location pos1 =
new Location(plot.getWorldName(), region.minX, region.minY, region.minZ); new Location(plot.getWorldName(), region.getMinimumPoint().getX(), region.getMinimumPoint().getY(), region.getMinimumPoint().getZ());
Location pos2 = Location pos2 =
new Location(plot.getWorldName(), region.maxX, region.maxY, region.maxZ); new Location(plot.getWorldName(), region.getMaximumPoint().getX(), region.getMaximumPoint().getY(), region.getMaximumPoint().getZ());
ChunkManager.manager.regenerateRegion(pos1, pos2, false, this); ChunkManager.manager.regenerateRegion(pos1, pos2, false, this);
} }
}; };

View File

@ -20,7 +20,7 @@ import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.block.ItemUtil; import com.github.intellectualsites.plotsquared.plot.util.world.ItemUtil;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.listener;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.Captions; import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -20,10 +20,11 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class ProcessedWEExtent extends AbstractDelegateExtent { public class ProcessedWEExtent extends AbstractDelegateExtent {
private final HashSet<RegionWrapper> mask; private final Set<CuboidRegion> mask;
private final String world; private final String world;
private final int max; private final int max;
int BScount = 0; int BScount = 0;
@ -33,7 +34,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
private int count; private int count;
private Extent parent; private Extent parent;
public ProcessedWEExtent(String world, HashSet<RegionWrapper> mask, int max, Extent child, public ProcessedWEExtent(String world, Set<CuboidRegion> mask, int max, Extent child,
Extent parent) { Extent parent) {
super(child); super(child);
this.mask = mask; this.mask = mask;

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.plot.listener; package com.github.intellectualsites.plotsquared.plot.listener;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -16,14 +16,15 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class WEExtent extends AbstractDelegateExtent { public class WEExtent extends AbstractDelegateExtent {
public static BlockState AIRSTATE = BlockTypes.AIR.getDefaultState(); public static BlockState AIRSTATE = BlockTypes.AIR.getDefaultState();
public static BaseBlock AIRBASE = BlockTypes.AIR.getDefaultState().toBaseBlock(); public static BaseBlock AIRBASE = BlockTypes.AIR.getDefaultState().toBaseBlock();
private final HashSet<RegionWrapper> mask; private final Set<CuboidRegion> mask;
public WEExtent(HashSet<RegionWrapper> mask, Extent extent) { public WEExtent(Set<CuboidRegion> mask, Extent extent) {
super(extent); super(extent);
this.mask = mask; this.mask = mask;
} }

View File

@ -7,62 +7,65 @@ import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class WEManager { public class WEManager {
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int y, int z) { public static boolean maskContains(Set<CuboidRegion> mask, int x, int y, int z) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, y, z)) { if (RegionUtil.contains(region, x, y, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) { public static boolean maskContains(Set<CuboidRegion> mask, int x, int z) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, z)) { if (RegionUtil.contains(region, x, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, double dx, double dy, public static boolean maskContains(Set<CuboidRegion> mask, double dx, double dy,
double dz) { double dz) {
int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5)); int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5));
int y = Math.toIntExact(Math.round(dy - 0.5)); int y = Math.toIntExact(Math.round(dy - 0.5));
int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5)); int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5));
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, y, z)) { if (RegionUtil.contains(region, x, y, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static boolean maskContains(HashSet<RegionWrapper> mask, double dx, double dz) { public static boolean maskContains(Set<CuboidRegion> mask, double dx, double dz) {
int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5)); int x = Math.toIntExact(Math.round(dx >= 0 ? dx - 0.5 : dx + 0.5));
int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5)); int z = Math.toIntExact(Math.round(dz >= 0 ? dz - 0.5 : dz + 0.5));
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (region.isIn(x, z)) { if (RegionUtil.contains(region, x, z)) {
return true; return true;
} }
} }
return false; return false;
} }
public static HashSet<RegionWrapper> getMask(PlotPlayer player) { public static HashSet<CuboidRegion> getMask(PlotPlayer player) {
HashSet<RegionWrapper> regions = new HashSet<>(); HashSet<CuboidRegion> regions = new HashSet<>();
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
Location location = player.getLocation(); Location location = player.getLocation();
String world = location.getWorld(); String world = location.getWorld();
if (!PlotSquared.get().hasPlotArea(world)) { if (!PlotSquared.get().hasPlotArea(world)) {
regions.add(new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, regions.add(RegionUtil.createRegion(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE,
Integer.MAX_VALUE)); Integer.MAX_VALUE));
return regions; return regions;
} }
@ -78,10 +81,10 @@ public class WEManager {
if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && ( if (plot != null && (!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot)) && (
(allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot (allowMember && plot.isAdded(uuid)) || (!allowMember && (plot.isOwner(uuid)) || plot
.getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) { .getTrusted().contains(uuid))) && !(Flags.NO_WORLDEDIT.isTrue(plot))) {
for (RegionWrapper region : plot.getRegions()) { for (CuboidRegion region : plot.getRegions()) {
RegionWrapper copy = BlockVector3 pos1 = region.getMinimumPoint().withY(area.MIN_BUILD_HEIGHT);
new RegionWrapper(region.minX, region.maxX, area.MIN_BUILD_HEIGHT, BlockVector3 pos2 = region.getMaximumPoint().withY(area.MAX_BUILD_HEIGHT);
area.MAX_BUILD_HEIGHT, region.minZ, region.maxZ); CuboidRegion copy = new CuboidRegion(pos1, pos2);
regions.add(copy); regions.add(copy);
} }
player.setMeta("WorldEditRegionPlot", plot); player.setMeta("WorldEditRegionPlot", plot);
@ -89,12 +92,12 @@ public class WEManager {
return regions; return regions;
} }
public static boolean intersects(RegionWrapper region1, RegionWrapper region2) { public static boolean intersects(CuboidRegion region1, CuboidRegion region2) {
return region1.intersects(region2); return RegionUtil.intersects(region1, region2);
} }
public static boolean regionContains(RegionWrapper selection, HashSet<RegionWrapper> mask) { public static boolean regionContains(CuboidRegion selection, HashSet<CuboidRegion> mask) {
for (RegionWrapper region : mask) { for (CuboidRegion region : mask) {
if (intersects(region, selection)) { if (intersects(region, selection)) {
return true; return true;
} }

View File

@ -5,7 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.config.Captions;
import com.github.intellectualsites.plotsquared.plot.config.Settings; import com.github.intellectualsites.plotsquared.plot.config.Settings;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
@ -19,6 +19,7 @@ import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
public class WESubscriber { public class WESubscriber {
@ -37,7 +38,7 @@ public class WESubscriber {
if (actor != null && actor.isPlayer()) { if (actor != null && actor.isPlayer()) {
String name = actor.getName(); String name = actor.getName();
PlotPlayer plotPlayer = PlotPlayer.wrap(name); PlotPlayer plotPlayer = PlotPlayer.wrap(name);
HashSet<RegionWrapper> mask; Set<CuboidRegion> mask;
if (plotPlayer == null) { if (plotPlayer == null) {
Player player = (Player) actor; Player player = (Player) actor;
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -5,6 +5,7 @@ import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode; import com.github.intellectualsites.plotsquared.plot.util.PlotGameMode;
import com.github.intellectualsites.plotsquared.plot.util.PlotWeather; import com.github.intellectualsites.plotsquared.plot.util.PlotWeather;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -18,9 +19,9 @@ public class ConsolePlayer extends PlotPlayer {
PlotArea area = PlotSquared.get().getFirstPlotArea(); PlotArea area = PlotSquared.get().getFirstPlotArea();
Location location; Location location;
if (area != null) { if (area != null) {
RegionWrapper region = area.getRegion(); CuboidRegion region = area.getRegion();
location = new Location(area.worldname, region.minX + region.maxX / 2, 0, location = new Location(area.worldname, region.getMinimumPoint().getX() + region.getMaximumPoint().getX() / 2, 0,
region.minZ + region.maxZ / 2); region.getMinimumPoint().getZ() + region.getMaximumPoint().getZ() / 2);
} else { } else {
location = new Location("world", 0, 0, 0); location = new Location("world", 0, 0, 0);
} }

View File

@ -27,10 +27,6 @@ public class Location implements Cloneable, Comparable<Location> {
this.blockVector3 = BlockVector3.at(x, y, z); this.blockVector3 = BlockVector3.at(x, y, z);
} }
public Location() {
this.world = "";
}
public Location(String world, int x, int y, int z) { public Location(String world, int x, int y, int z) {
this(world, x, y, z, 0f, 0f); this(world, x, y, z, 0f, 0f);
} }

View File

@ -22,7 +22,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import com.github.intellectualsites.plotsquared.plot.util.WorldUtil; import com.github.intellectualsites.plotsquared.plot.util.WorldUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
@ -32,6 +32,8 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -66,13 +68,13 @@ import java.util.stream.Collectors;
*/ */
public class Plot { public class Plot {
private static final int MAX_HEIGHT = 256; public static final int MAX_HEIGHT = 256;
/** /**
* @deprecated raw access is deprecated * @deprecated raw access is deprecated
*/ */
@Deprecated private static HashSet<Plot> connected_cache; @Deprecated private static Set<Plot> connected_cache;
private static HashSet<RegionWrapper> regions_cache; private static Set<CuboidRegion> regions_cache;
@NotNull private final PlotId id; @NotNull private final PlotId id;
@ -865,7 +867,7 @@ public class Plot {
return false; return false;
} }
} }
final HashSet<RegionWrapper> regions = this.getRegions(); final Set<CuboidRegion> regions = this.getRegions();
final Set<Plot> plots = this.getConnectedPlots(); final Set<Plot> plots = this.getConnectedPlots();
final ArrayDeque<Plot> queue = new ArrayDeque<>(plots); final ArrayDeque<Plot> queue = new ArrayDeque<>(plots);
if (isDelete) { if (isDelete) {
@ -877,10 +879,10 @@ public class Plot {
@Override public void run() { @Override public void run() {
if (queue.isEmpty()) { if (queue.isEmpty()) {
Runnable run = () -> { Runnable run = () -> {
for (RegionWrapper region : regions) { // for (CuboidRegion region : regions) {
Location[] corners = region.getCorners(getWorldName()); // Location[] corners = MainUtil.getCorners(getWorldName(), region);
ChunkManager.manager.clearAllEntities(corners[0], corners[1]); // ChunkManager.manager.clearAllEntities(corners[0], corners[1]);
} // }
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
}; };
for (Plot current : plots) { for (Plot current : plots) {
@ -920,7 +922,7 @@ public class Plot {
* @param whenDone The task to run when finished, or null * @param whenDone The task to run when finished, or null
*/ */
public void setBiome(final String biome, final Runnable whenDone) { public void setBiome(final String biome, final Runnable whenDone) {
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
final int extendBiome; final int extendBiome;
if (area instanceof SquarePlotWorld) { if (area instanceof SquarePlotWorld) {
extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0; extendBiome = (((SquarePlotWorld) area).ROAD_WIDTH > 0) ? 1 : 0;
@ -934,11 +936,11 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location pos1 = new Location(getWorldName(), region.minX - extendBiome, region.minY, Location pos1 = new Location(getWorldName(), region.getMinimumPoint().getX() - extendBiome, region.getMinimumPoint().getY(),
region.minZ - extendBiome); region.getMinimumPoint().getZ() - extendBiome);
Location pos2 = new Location(getWorldName(), region.maxX + extendBiome, region.maxY, Location pos2 = new Location(getWorldName(), region.getMaximumPoint().getX() + extendBiome, region.getMaximumPoint().getY(),
region.maxZ + extendBiome); region.getMaximumPoint().getZ() + extendBiome);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() { ChunkManager.chunkTask(pos1, pos2, new RunnableVal<int[]>() {
@Override public void run(int[] value) { @Override public void run(int[] value) {
BlockVector2 loc = BlockVector2.at(value[0], value[1]); BlockVector2 loc = BlockVector2.at(value[0], value[1]);
@ -1254,9 +1256,9 @@ public class Plot {
} }
public Location getSide() { public Location getSide() {
RegionWrapper largest = getLargestRegion(); CuboidRegion largest = getLargestRegion();
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; int x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX();
int z = largest.minZ - 1; int z = largest.getMinimumPoint().getZ() - 1;
PlotManager manager = getManager(); PlotManager manager = getManager();
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62; int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(getWorldName(), x, z) : 62;
if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) { if (area.ALLOW_SIGNS && (y <= 0 || y >= 255)) {
@ -1328,9 +1330,9 @@ public class Plot {
int z; int z;
if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) { if (loc.getX() == Integer.MAX_VALUE && loc.getZ() == Integer.MAX_VALUE) {
// center // center
RegionWrapper largest = plot.getLargestRegion(); CuboidRegion largest = plot.getLargestRegion();
x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX; x = (largest.getMaximumPoint().getX() >> 1) - (largest.getMinimumPoint().getX() >> 1) + largest.getMinimumPoint().getX();
z = (largest.maxZ >> 1) - (largest.minZ >> 1) + largest.minZ; z = (largest.getMaximumPoint().getZ() >> 1) - (largest.getMinimumPoint().getZ() >> 1) + largest.getMinimumPoint().getZ();
} else { } else {
// specific // specific
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
@ -1348,9 +1350,9 @@ public class Plot {
public double getVolume() { public double getVolume() {
double count = 0; double count = 0;
for (RegionWrapper region : getRegions()) { for (CuboidRegion region : getRegions()) {
count += count +=
(region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1) (region.getMaximumPoint().getX() - (double) region.getMinimumPoint().getX() + 1) * (region.getMaximumPoint().getZ() - (double) region.getMinimumPoint().getZ() + 1)
* MAX_HEIGHT; * MAX_HEIGHT;
} }
return count; return count;
@ -1436,9 +1438,9 @@ public class Plot {
public void refreshChunks() { public void refreshChunks() {
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false); LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
HashSet<BlockVector2> chunks = new HashSet<>(); HashSet<BlockVector2> chunks = new HashSet<>();
for (RegionWrapper region : Plot.this.getRegions()) { for (CuboidRegion region : Plot.this.getRegions()) {
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) { for (int x = region.getMinimumPoint().getX() >> 4; x <= region.getMaximumPoint().getX() >> 4; x++) {
for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) { for (int z = region.getMinimumPoint().getZ() >> 4; z <= region.getMaximumPoint().getZ() >> 4; z++) {
if (chunks.add(BlockVector2.at(x, z))) { if (chunks.add(BlockVector2.at(x, z))) {
queue.refreshChunk(x, z); queue.refreshChunk(x, z);
} }
@ -2593,7 +2595,7 @@ public class Plot {
* *
* @return * @return
*/ */
@NotNull public HashSet<RegionWrapper> getRegions() { @NotNull public Set<CuboidRegion> getRegions() {
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) { if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
return regions_cache; return regions_cache;
} }
@ -2601,14 +2603,13 @@ public class Plot {
Location pos1 = this.getBottomAbs(); Location pos1 = this.getBottomAbs();
Location pos2 = this.getTopAbs(); Location pos2 = this.getTopAbs();
connected_cache = Sets.newHashSet(this); connected_cache = Sets.newHashSet(this);
regions_cache = Sets.newHashSet( CuboidRegion rg = new CuboidRegion(pos1.getBlockVector3(), pos2.getBlockVector3());
new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), regions_cache = Collections.singleton(rg);
pos2.getZ()));
return regions_cache; return regions_cache;
} }
Set<Plot> plots = this.getConnectedPlots(); Set<Plot> plots = this.getConnectedPlots();
HashSet<RegionWrapper> regions = regions_cache = new HashSet<>(); Set<CuboidRegion> regions = regions_cache = new HashSet<>();
HashSet<PlotId> visited = new HashSet<>(); Set<PlotId> visited = new HashSet<>();
for (Plot current : plots) { for (Plot current : plots) {
if (visited.contains(current.getId())) { if (visited.contains(current.getId())) {
continue; continue;
@ -2685,12 +2686,14 @@ public class Plot {
Location toploc = plot.getExtendedTopAbs(); Location toploc = plot.getExtendedTopAbs();
Location botabs = plot.getBottomAbs(); Location botabs = plot.getBottomAbs();
Location topabs = plot.getTopAbs(); Location topabs = plot.getTopAbs();
regions.add(new RegionWrapper(botabs.getX(), topabs.getX(), topabs.getZ() + 1, BlockVector3 pos1 = BlockVector3.at(botabs.getX(), 0, topabs.getZ() + 1);
toploc.getZ())); BlockVector3 pos2 = BlockVector3.at(topabs.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add(new CuboidRegion(pos1, pos2));
if (plot.getMerged(Direction.SOUTHEAST)) { if (plot.getMerged(Direction.SOUTHEAST)) {
pos1 = BlockVector3.at(topabs.getX() + 1, 0, topabs.getZ() + 1);
pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add( regions.add(
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, new CuboidRegion(pos1, pos2));
toploc.getZ()));
// intersection // intersection
} }
} }
@ -2703,18 +2706,22 @@ public class Plot {
Location toploc = plot.getExtendedTopAbs(); Location toploc = plot.getExtendedTopAbs();
Location botabs = plot.getBottomAbs(); Location botabs = plot.getBottomAbs();
Location topabs = plot.getTopAbs(); Location topabs = plot.getTopAbs();
regions.add(new RegionWrapper(topabs.getX() + 1, toploc.getX(), botabs.getZ(), BlockVector3 pos1 = BlockVector3.at(topabs.getX() + 1, 0, botabs.getZ());
topabs.getZ())); BlockVector3 pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, topabs.getZ());
regions.add(new CuboidRegion(pos1, pos2));
if (plot.getMerged(Direction.SOUTHEAST)) { if (plot.getMerged(Direction.SOUTHEAST)) {
pos1 = BlockVector3.at(topabs.getX() + 1, 0, topabs.getZ());
pos2 = BlockVector3.at(toploc.getX(), Plot.MAX_HEIGHT - 1, toploc.getZ());
regions.add( regions.add(
new RegionWrapper(topabs.getX() + 1, toploc.getX(), topabs.getZ() + 1, new CuboidRegion(pos1, pos2));
toploc.getZ()));
// intersection // intersection
} }
} }
} }
BlockVector3 pos1 = BlockVector3.at(gbotabs.getX() + 1, 0, gbotabs.getZ());
BlockVector3 pos2 = BlockVector3.at(gtopabs.getX(), Plot.MAX_HEIGHT - 1, gtopabs.getZ());
regions.add( regions.add(
new RegionWrapper(gbotabs.getX(), gtopabs.getX(), gbotabs.getZ(), gtopabs.getZ())); new CuboidRegion(pos1, pos2));
} }
return regions; return regions;
} }
@ -2724,13 +2731,13 @@ public class Plot {
* *
* @return * @return
*/ */
public RegionWrapper getLargestRegion() { public CuboidRegion getLargestRegion() {
HashSet<RegionWrapper> regions = this.getRegions(); Set<CuboidRegion> regions = this.getRegions();
RegionWrapper max = null; CuboidRegion max = null;
double area = Double.NEGATIVE_INFINITY; double area = Double.NEGATIVE_INFINITY;
for (RegionWrapper region : regions) { for (CuboidRegion region : regions) {
double current = double current =
(region.maxX - (double) region.minX + 1) * (region.maxZ - (double) region.minZ + 1); (region.getMaximumPoint().getX() - (double) region.getMinimumPoint().getX() + 1) * (region.getMaximumPoint().getZ() - (double) region.getMinimumPoint().getZ() + 1);
if (current > area) { if (current > area) {
max = region; max = region;
area = current; area = current;
@ -2759,9 +2766,9 @@ public class Plot {
*/ */
public List<Location> getAllCorners() { public List<Location> getAllCorners() {
Area area = new Area(); Area area = new Area();
for (RegionWrapper region : this.getRegions()) { for (CuboidRegion region : this.getRegions()) {
Rectangle2D rect = new Rectangle2D.Double(region.minX - 0.6, region.minZ - 0.6, Rectangle2D rect = new Rectangle2D.Double(region.getMinimumPoint().getX() - 0.6, region.getMinimumPoint().getZ() - 0.6,
region.maxX - region.minX + 1.2, region.maxZ - region.minZ + 1.2); region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + 1.2, region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + 1.2);
Area rectArea = new Area(rect); Area rectArea = new Area(rect);
area.add(rectArea); area.add(rectArea);
} }
@ -2976,7 +2983,7 @@ public class Plot {
} }
// world border // world border
destination.updateWorldBorder(); destination.updateWorldBorder();
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
// move / swap data // move / swap data
final PlotArea originArea = getArea(); final PlotArea originArea = getArea();
for (Plot plot : plots) { for (Plot plot : plots) {
@ -2991,8 +2998,8 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
Location pos3 = pos1.clone().add(offsetX, 0, offsetZ); Location pos3 = pos1.clone().add(offsetX, 0, offsetZ);
@ -3019,8 +3026,8 @@ public class Plot {
return; return;
} }
final Runnable task = this; final Runnable task = this;
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
final Location pos1 = corners[0]; final Location pos1 = corners[0];
final Location pos2 = corners[1]; final Location pos2 = corners[1];
Location newPos = pos1.clone().add(offsetX, 0, offsetZ); Location newPos = pos1.clone().add(offsetX, 0, offsetZ);
@ -3093,7 +3100,7 @@ public class Plot {
} }
} }
// copy terrain // copy terrain
final ArrayDeque<RegionWrapper> regions = new ArrayDeque<>(this.getRegions()); final ArrayDeque<CuboidRegion> regions = new ArrayDeque<>(this.getRegions());
Runnable run = new Runnable() { Runnable run = new Runnable() {
@Override public void run() { @Override public void run() {
if (regions.isEmpty()) { if (regions.isEmpty()) {
@ -3104,8 +3111,8 @@ public class Plot {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper region = regions.poll(); CuboidRegion region = regions.poll();
Location[] corners = region.getCorners(getWorldName()); Location[] corners = MainUtil.getCorners(getWorldName(), region);
Location pos1 = corners[0]; Location pos1 = corners[0];
Location pos2 = corners[1]; Location pos2 = corners[1];
Location newPos = pos1.clone().add(offsetX, 0, offsetZ); Location newPos = pos1.clone().add(offsetX, 0, offsetZ);

View File

@ -19,8 +19,12 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap; import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -79,7 +83,7 @@ public abstract class PlotArea {
public int MIN_BUILD_HEIGHT = 1; public int MIN_BUILD_HEIGHT = 1;
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE; public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
private int hash; private int hash;
private RegionWrapper region; private CuboidRegion region;
private ConcurrentHashMap<String, Object> meta; private ConcurrentHashMap<String, Object> meta;
private QuadMap<PlotCluster> clusters; private QuadMap<PlotCluster> clusters;
@ -128,16 +132,16 @@ public abstract class PlotArea {
} }
/** /**
* Returns the region for this PlotArea or a RegionWrapper encompassing * Returns the region for this PlotArea or a CuboidRegion encompassing
* the whole world if none exists. * the whole world if none exists.
* *
* @return RegionWrapper * @return CuboidRegion
*/ */
public RegionWrapper getRegion() { public CuboidRegion getRegion() {
this.region = getRegionAbs(); this.region = getRegionAbs();
if (this.region == null) { if (this.region == null) {
return new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, return new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
Integer.MAX_VALUE); BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE));
} }
return this.region; return this.region;
} }
@ -145,15 +149,16 @@ public abstract class PlotArea {
/** /**
* Returns the region for this PlotArea. * Returns the region for this PlotArea.
* *
* @return RegionWrapper or null if no applicable region * @return CuboidRegion or null if no applicable region
*/ */
private RegionWrapper getRegionAbs() { private CuboidRegion getRegionAbs() {
if (this.region == null) { if (this.region == null) {
if (this.min != null) { if (this.min != null) {
Location bot = getPlotManager().getPlotBottomLocAbs(this.min); Location bot = getPlotManager().getPlotBottomLocAbs(this.min);
Location top = getPlotManager().getPlotTopLocAbs(this.max); Location top = getPlotManager().getPlotTopLocAbs(this.max);
this.region = new RegionWrapper(bot.getX() - 1, top.getX() + 1, bot.getZ() - 1, BlockVector3 pos1 = bot.getBlockVector3().subtract(BlockVector3.ONE);
top.getZ() + 1); BlockVector3 pos2 = top.getBlockVector3().add(BlockVector3.ONE);
this.region = new CuboidRegion(pos1, pos2);
} }
} }
return this.region; return this.region;
@ -497,7 +502,7 @@ public abstract class PlotArea {
} }
public boolean contains(final int x, final int z) { public boolean contains(final int x, final int z) {
return this.TYPE != 2 || getRegionAbs().isIn(x, z); return this.TYPE != 2 || RegionUtil.contains(getRegionAbs(), x, z);
} }
public boolean contains(@NotNull final PlotId id) { public boolean contains(@NotNull final PlotId id) {
@ -507,7 +512,7 @@ public abstract class PlotArea {
public boolean contains(@NotNull final Location location) { public boolean contains(@NotNull final Location location) {
return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null return StringMan.isEqual(location.getWorld(), this.worldname) && (getRegionAbs() == null
|| this.region.isIn(location.getX(), location.getZ())); || this.region.contains(location.getBlockVector3()));
} }
@NotNull Set<Plot> getPlotsAbs(final UUID uuid) { @NotNull Set<Plot> getPlotsAbs(final UUID uuid) {
@ -940,9 +945,10 @@ public abstract class PlotArea {
public void addCluster(@Nullable final PlotCluster plotCluster) { public void addCluster(@Nullable final PlotCluster plotCluster) {
if (this.clusters == null) { if (this.clusters == null) {
this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) { this.clusters = new QuadMap<PlotCluster>(Integer.MAX_VALUE, 0, 0, 62) {
@Override public RegionWrapper getRegion(PlotCluster value) { @Override public CuboidRegion getRegion(PlotCluster value) {
return new RegionWrapper(value.getP1().x, value.getP2().x, value.getP1().y, BlockVector2 pos1 = BlockVector2.at(value.getP1().x, value.getP1().y);
value.getP2().y); BlockVector2 pos2 = BlockVector2.at(value.getP2().x, value.getP2().y);
return new CuboidRegion(pos1.toBlockVector3(), pos2.toBlockVector3(Plot.MAX_HEIGHT - 1));
} }
}; };
} }

View File

@ -2,6 +2,8 @@ package com.github.intellectualsites.plotsquared.plot.object;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@ -15,7 +17,7 @@ public class PlotCluster {
public int temp; public int temp;
private PlotId pos1; private PlotId pos1;
private PlotId pos2; private PlotId pos2;
private RegionWrapper region; private CuboidRegion region;
public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) { public PlotCluster(PlotArea area, PlotId pos1, PlotId pos2, UUID owner) {
this.area = area; this.area = area;
@ -56,10 +58,10 @@ public class PlotCluster {
} }
private void setRegion() { private void setRegion() {
this.region = new RegionWrapper(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y); this.region = RegionUtil.createRegion(this.pos1.x, this.pos2.x, this.pos1.y, this.pos2.y);
} }
public RegionWrapper getRegion() { public CuboidRegion getRegion() {
return this.region; return this.region;
} }

View File

@ -1,71 +0,0 @@
package com.github.intellectualsites.plotsquared.plot.object;
public class RegionWrapper {
public final int minX;
public final int maxX;
public final int minY;
public final int maxY;
public final int minZ;
public final int maxZ;
public RegionWrapper(int minX, int maxX, int minZ, int maxZ) {
this.maxX = maxX;
this.minX = minX;
this.maxZ = maxZ;
this.minZ = minZ;
this.minY = 0;
this.maxY = 256;
}
public RegionWrapper(int minX, int maxX, int minY, int maxY, int minZ, int maxZ) {
this.maxX = maxX;
this.minX = minX;
this.maxZ = maxZ;
this.minZ = minZ;
this.minY = minY;
this.maxY = maxY;
}
public boolean isIn(int x, int y, int z) {
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ
&& y >= this.minY && y <= this.maxY;
}
public boolean isIn(int x, int z) {
return x >= this.minX && x <= this.maxX && z >= this.minZ && z <= this.maxZ;
}
public boolean intersects(RegionWrapper other) {
return other.minX <= this.maxX && other.maxX >= this.minX && other.minY <= this.maxY
&& other.maxY >= this.minY;
}
@Override public int hashCode() {
return this.minX + 13 * this.maxX + 23 * this.minZ + 39 * this.maxZ;
}
@Override public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (obj == this) {
return true;
}
if (obj instanceof RegionWrapper) {
RegionWrapper other = (RegionWrapper) obj;
return this.minX == other.minX && this.minZ == other.minZ && this.minY == other.minY
&& this.maxX == other.maxX && this.maxZ == other.maxZ && this.maxY == other.maxY;
}
return false;
}
@Override public String toString() {
return this.minX + "->" + this.maxX + "," + this.minZ + "->" + this.maxZ;
}
public Location[] getCorners(String world) {
Location pos1 = new Location(world, this.minX, this.minY, this.minZ);
Location pos2 = new Location(world, this.maxX, this.maxY, this.maxZ);
return new Location[] {pos1, pos2};
}
}

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap; import com.github.intellectualsites.plotsquared.plot.util.area.QuadMap;
@ -99,7 +99,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname); QuadMap<PlotArea> map = this.plotAreaGrid.get(plotArea.worldname);
if (map == null) { if (map == null) {
map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) { map = new QuadMap<PlotArea>(Integer.MAX_VALUE, 0, 0) {
@Override public RegionWrapper getRegion(PlotArea value) { @Override public CuboidRegion getRegion(PlotArea value) {
return value.getRegion(); return value.getRegion();
} }
}; };
@ -201,7 +201,7 @@ public class DefaultPlotAreaManager implements PlotAreaManager {
} }
} }
@Override public PlotArea[] getPlotAreas(String world, RegionWrapper region) { @Override public PlotArea[] getPlotAreas(String world, CuboidRegion region) {
if (region == null) { if (region == null) {
PlotArea[] areas = this.plotAreaMap.get(world); PlotArea[] areas = this.plotAreaMap.get(world);
if (areas == null) { if (areas == null) {

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
public interface PlotAreaManager { public interface PlotAreaManager {
PlotArea getApplicablePlotArea(Location location); PlotArea getApplicablePlotArea(Location location);
@ -11,7 +11,7 @@ public interface PlotAreaManager {
PlotArea getPlotArea(String world, String id); PlotArea getPlotArea(String world, String id);
PlotArea[] getPlotAreas(String world, RegionWrapper region); PlotArea[] getPlotAreas(String world, CuboidRegion region);
PlotArea[] getAllPlotAreas(); PlotArea[] getAllPlotAreas();

View File

@ -8,18 +8,21 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.google.common.collect.Sets; import com.google.common.collect.Sets;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
public class SinglePlot extends Plot { public class SinglePlot extends Plot {
private HashSet<RegionWrapper> regions = Sets.newHashSet( private Set<CuboidRegion> regions = Collections.singleton(
new RegionWrapper(Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MIN_VALUE, new CuboidRegion(BlockVector3.at(Integer.MIN_VALUE, Integer.MIN_VALUE, Integer.MIN_VALUE),
Integer.MAX_VALUE)); BlockVector3.at(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE)));
public SinglePlot(PlotArea area, PlotId id, UUID owner) { public SinglePlot(PlotArea area, PlotId id, UUID owner) {
super(area, id, owner); super(area, id, owner);
@ -66,7 +69,7 @@ public class SinglePlot extends Plot {
return super.isLoaded(); return super.isLoaded();
} }
@NotNull @Override public HashSet<RegionWrapper> getRegions() { @NotNull @Override public Set<CuboidRegion> getRegions() {
return regions; return regions;
} }

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.plot.object.worlds;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.util.ArrayUtil; import com.github.intellectualsites.plotsquared.plot.util.ArrayUtil;
import com.github.intellectualsites.plotsquared.plot.util.SetupUtils; import com.github.intellectualsites.plotsquared.plot.util.SetupUtils;
@ -90,7 +90,7 @@ public class SinglePlotAreaManager extends DefaultPlotAreaManager {
return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null; return isWorld(location.getWorld()) || location.getWorld().equals("*") ? area : null;
} }
@Override public PlotArea[] getPlotAreas(String world, RegionWrapper region) { @Override public PlotArea[] getPlotAreas(String world, CuboidRegion region) {
PlotArea[] found = super.getPlotAreas(world, region); PlotArea[] found = super.getPlotAreas(world, region);
if (found != null && found.length != 0) { if (found != null && found.length != 0) {
return found; return found;

View File

@ -6,7 +6,7 @@ import com.github.intellectualsites.plotsquared.plot.object.BlockBucket;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue;
public class SingleWorldGenerator extends IndependentPlotGenerator { public class SingleWorldGenerator extends IndependentPlotGenerator {

View File

@ -3,7 +3,7 @@ package com.github.intellectualsites.plotsquared.plot.util;
import com.github.intellectualsites.plotsquared.plot.PlotSquared; import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
@ -80,7 +80,7 @@ public abstract class ChunkManager {
return false; return false;
} }
public static void largeRegionTask(final String world, final RegionWrapper region, public static void largeRegionTask(final String world, final CuboidRegion region,
final RunnableVal<BlockVector2> task, final Runnable whenDone) { final RunnableVal<BlockVector2> task, final Runnable whenDone) {
TaskManager.runTaskAsync(() -> { TaskManager.runTaskAsync(() -> {
HashSet<BlockVector2> chunks = new HashSet<>(); HashSet<BlockVector2> chunks = new HashSet<>();
@ -90,16 +90,16 @@ public abstract class ChunkManager {
int bz = mcr.getZ() << 9; int bz = mcr.getZ() << 9;
int tx = bx + 511; int tx = bx + 511;
int tz = bz + 511; int tz = bz + 511;
if (bx <= region.maxX && tx >= region.minX && bz <= region.maxZ if (bx <= region.getMaximumPoint().getX() && tx >= region.getMinimumPoint().getX() && bz <= region.getMaximumPoint().getZ()
&& tz >= region.minZ) { && tz >= region.getMinimumPoint().getZ()) {
for (int x = bx >> 4; x <= (tx >> 4); x++) { for (int x = bx >> 4; x <= (tx >> 4); x++) {
int cbx = x << 4; int cbx = x << 4;
int ctx = cbx + 15; int ctx = cbx + 15;
if (cbx <= region.maxX && ctx >= region.minX) { if (cbx <= region.getMaximumPoint().getX() && ctx >= region.getMinimumPoint().getX()) {
for (int z = bz >> 4; z <= (tz >> 4); z++) { for (int z = bz >> 4; z <= (tz >> 4); z++) {
int cbz = z << 4; int cbz = z << 4;
int ctz = cbz + 15; int ctz = cbz + 15;
if (cbz <= region.maxZ && ctz >= region.minZ) { if (cbz <= region.getMaximumPoint().getZ() && ctz >= region.getMinimumPoint().getZ()) {
chunks.add(BlockVector2.at(x, z)); chunks.add(BlockVector2.at(x, z));
} }
} }
@ -118,16 +118,16 @@ public abstract class ChunkManager {
public static void chunkTask(final Plot plot, final RunnableVal<int[]> task, public static void chunkTask(final Plot plot, final RunnableVal<int[]> task,
final Runnable whenDone, final int allocate) { final Runnable whenDone, final int allocate) {
final ArrayList<RegionWrapper> regions = new ArrayList<>(plot.getRegions()); final ArrayList<CuboidRegion> regions = new ArrayList<>(plot.getRegions());
Runnable smallTask = new Runnable() { Runnable smallTask = new Runnable() {
@Override public void run() { @Override public void run() {
if (regions.isEmpty()) { if (regions.isEmpty()) {
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
} }
RegionWrapper value = regions.remove(0); CuboidRegion value = regions.remove(0);
Location pos1 = new Location(plot.getWorldName(), value.minX, 0, value.minZ); Location pos1 = new Location(plot.getWorldName(), value.getMinimumPoint().getX(), 0, value.getMinimumPoint().getZ());
Location pos2 = new Location(plot.getWorldName(), value.maxX, 0, value.maxZ); Location pos2 = new Location(plot.getWorldName(), value.getMaximumPoint().getX(), 0, value.getMaximumPoint().getZ());
chunkTask(pos1, pos2, task, this, allocate); chunkTask(pos1, pos2, task, this, allocate);
} }
}; };

View File

@ -16,7 +16,9 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream; import com.github.intellectualsites.plotsquared.plot.object.stream.AbstractDelegateOutputStream;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
@ -372,6 +374,14 @@ public class MainUtil {
return plot.getFlag(Flags.SERVER_PLOT).orElse(false); return plot.getFlag(Flags.SERVER_PLOT).orElse(false);
} }
@NotNull public static Location[] getCorners(String world, CuboidRegion region) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
Location pos1 = new Location(world, min.getX(), min.getY(), min.getZ());
Location pos2 = new Location(world, max.getX(), max.getY(), max.getZ());
return new Location[] {pos1, pos2};
}
/** /**
* Get the corner locations for a list of regions. * Get the corner locations for a list of regions.
* *
@ -380,11 +390,11 @@ public class MainUtil {
* @return * @return
* @see Plot#getCorners() * @see Plot#getCorners()
*/ */
@NotNull public static Location[] getCorners(String world, Collection<RegionWrapper> regions) { @NotNull public static Location[] getCorners(String world, Collection<CuboidRegion> regions) {
Location min = null; Location min = null;
Location max = null; Location max = null;
for (RegionWrapper region : regions) { for (CuboidRegion region : regions) {
Location[] corners = region.getCorners(world); Location[] corners = getCorners(world, region);
if (min == null) { if (min == null) {
min = corners[0]; min = corners[0];
max = corners[1]; max = corners[1];
@ -558,7 +568,9 @@ public class MainUtil {
* @param biome * @param biome
*/ */
public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, String biome) { public static void setBiome(String world, int p1x, int p1z, int p2x, int p2z, String biome) {
RegionWrapper region = new RegionWrapper(p1x, p2x, p1z, p2z); BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
CuboidRegion region = new CuboidRegion(pos1, pos2);
WorldUtil.IMP.setBiomes(world, region, biome); WorldUtil.IMP.setBiomes(world, region, biome);
} }

View File

@ -10,7 +10,7 @@ import com.github.intellectualsites.plotsquared.plot.generator.ClassicPlotWorld;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea; import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic; import com.github.intellectualsites.plotsquared.plot.object.schematic.Schematic;
import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue; import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
@ -168,13 +168,13 @@ public abstract class SchematicHandler {
final int LENGTH = dimension.getZ(); final int LENGTH = dimension.getZ();
final int HEIGHT = dimension.getY(); final int HEIGHT = dimension.getY();
// Validate dimensions // Validate dimensions
RegionWrapper region = plot.getLargestRegion(); CuboidRegion region = plot.getLargestRegion();
if (((region.maxX - region.minX + xOffset + 1) < WIDTH) || ( if (((region.getMaximumPoint().getX() - region.getMinimumPoint().getX() + xOffset + 1) < WIDTH) || (
(region.maxZ - region.minZ + zOffset + 1) < LENGTH) || (HEIGHT > 256)) { (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ() + zOffset + 1) < LENGTH) || (HEIGHT > 256)) {
PlotSquared.debug("Schematic is too large"); PlotSquared.debug("Schematic is too large");
PlotSquared.debug( PlotSquared.debug(
"(" + WIDTH + ',' + LENGTH + ',' + HEIGHT + ") is bigger than (" + ( "(" + WIDTH + ',' + LENGTH + ',' + HEIGHT + ") is bigger than (" + (
region.maxX - region.minX) + ',' + (region.maxZ - region.minZ) region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) + ',' + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ())
+ ",256)"); + ",256)");
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
return; return;
@ -192,16 +192,16 @@ public abstract class SchematicHandler {
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT; y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
} else { } else {
y_offset_actual = yOffset + 1 + MainUtil y_offset_actual = yOffset + 1 + MainUtil
.getHeighestBlock(plot.getWorldName(), region.minX + 1, .getHeighestBlock(plot.getWorldName(), region.getMinimumPoint().getX() + 1,
region.minZ + 1); region.getMinimumPoint().getZ() + 1);
} }
} }
} else { } else {
y_offset_actual = yOffset; y_offset_actual = yOffset;
} }
Location pos1 = Location pos1 =
new Location(plot.getWorldName(), region.minX + xOffset, y_offset_actual, new Location(plot.getWorldName(), region.getMinimumPoint().getX() + xOffset, y_offset_actual,
region.minZ + zOffset); region.getMinimumPoint().getZ() + zOffset);
Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1); Location pos2 = pos1.clone().add(WIDTH - 1, HEIGHT - 1, LENGTH - 1);
final int p1x = pos1.getX(); final int p1x = pos1.getX();
final int p1z = pos1.getZ(); final int p1z = pos1.getZ();
@ -445,7 +445,7 @@ public abstract class SchematicHandler {
return true; return true;
} }
public abstract void getCompoundTag(String world, Set<RegionWrapper> regions, public abstract void getCompoundTag(String world, Set<CuboidRegion> regions,
RunnableVal<CompoundTag> whenDone); RunnableVal<CompoundTag> whenDone);
public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) { public void getCompoundTag(final Plot plot, final RunnableVal<CompoundTag> whenDone) {

View File

@ -4,7 +4,7 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.Plot; import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.sk89q.worldedit.regions.CuboidRegion;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal;
import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem; import com.github.intellectualsites.plotsquared.plot.object.schematic.PlotItem;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -66,7 +66,7 @@ public abstract class WorldUtil {
public abstract void setSign(String world, int x, int y, int z, String[] lines); public abstract void setSign(String world, int x, int y, int z, String[] lines);
public abstract void setBiomes(String world, RegionWrapper region, String biome); public abstract void setBiomes(String world, CuboidRegion region, String biome);
public abstract com.sk89q.worldedit.world.World getWeWorld(String world); public abstract com.sk89q.worldedit.world.World getWeWorld(String world);

View File

@ -1,6 +1,7 @@
package com.github.intellectualsites.plotsquared.plot.util.area; package com.github.intellectualsites.plotsquared.plot.util.area;
import com.github.intellectualsites.plotsquared.plot.object.RegionWrapper; import com.github.intellectualsites.plotsquared.plot.util.world.RegionUtil;
import com.sk89q.worldedit.regions.CuboidRegion;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -96,9 +97,9 @@ public class QuadMap<T> {
this.objects.add(area); this.objects.add(area);
return; return;
} }
RegionWrapper region = getRegion(area); CuboidRegion region = getRegion(area);
if (region.minX >= this.x) { if (region.getMinimumPoint().getX() >= this.x) {
if (region.minZ >= this.z) { if (region.getMinimumPoint().getZ() >= this.z) {
if (this.one == null) { if (this.one == null) {
this.one = this.one =
newInstance(this.newsize, this.x + this.newsize, this.z + this.newsize, newInstance(this.newsize, this.x + this.newsize, this.z + this.newsize,
@ -107,7 +108,7 @@ public class QuadMap<T> {
this.one.add(area); this.one.add(area);
recalculateSkip(); recalculateSkip();
return; return;
} else if (region.maxZ < this.z) { } else if (region.getMaximumPoint().getZ() < this.z) {
if (this.two == null) { if (this.two == null) {
this.two = this.two =
newInstance(this.newsize, this.x + this.newsize, this.z - this.newsize, newInstance(this.newsize, this.x + this.newsize, this.z - this.newsize,
@ -117,8 +118,8 @@ public class QuadMap<T> {
recalculateSkip(); recalculateSkip();
return; return;
} }
} else if (region.maxX < this.x) { } else if (region.getMaximumPoint().getX() < this.x) {
if (region.minZ >= this.z) { if (region.getMinimumPoint().getZ() >= this.z) {
if (this.four == null) { if (this.four == null) {
this.four = this.four =
newInstance(this.newsize, this.x - this.newsize, this.z + this.newsize, newInstance(this.newsize, this.x - this.newsize, this.z + this.newsize,
@ -127,7 +128,7 @@ public class QuadMap<T> {
this.four.add(area); this.four.add(area);
recalculateSkip(); recalculateSkip();
return; return;
} else if (region.maxZ < this.z) { } else if (region.getMaximumPoint().getZ() < this.z) {
if (this.three == null) { if (this.three == null) {
this.three = this.three =
newInstance(this.newsize, this.x - this.newsize, this.z - this.newsize, newInstance(this.newsize, this.x - this.newsize, this.z - this.newsize,
@ -144,14 +145,14 @@ public class QuadMap<T> {
this.objects.add(area); this.objects.add(area);
} }
public RegionWrapper getRegion(T value) { public CuboidRegion getRegion(T value) {
return null; return null;
} }
public QuadMap<T> newInstance(int newsize, int x, int z, int min) { public QuadMap<T> newInstance(int newsize, int x, int z, int min) {
try { try {
return new QuadMap<T>(newsize, x, z, min) { return new QuadMap<T>(newsize, x, z, min) {
@Override public RegionWrapper getRegion(T value) { @Override public CuboidRegion getRegion(T value) {
return QuadMap.this.getRegion(value); return QuadMap.this.getRegion(value);
} }
}; };
@ -172,9 +173,9 @@ public class QuadMap<T> {
this.skip = null; this.skip = null;
} }
} else { } else {
RegionWrapper region = getRegion(area); CuboidRegion region = getRegion(area);
if (region.minX >= this.x) { if (region.getMinimumPoint().getX() >= this.x) {
if (region.minZ >= this.z) { if (region.getMinimumPoint().getZ() >= this.z) {
if (this.one != null) { if (this.one != null) {
if (this.one.remove(area)) { if (this.one.remove(area)) {
this.one = null; this.one = null;
@ -190,7 +191,7 @@ public class QuadMap<T> {
} }
} }
} else { } else {
if (region.minZ >= this.z) { if (region.getMinimumPoint().getZ() >= this.z) {
if (this.four != null) { if (this.four != null) {
if (this.four.remove(area)) { if (this.four.remove(area)) {
this.four = null; this.four = null;
@ -224,11 +225,11 @@ public class QuadMap<T> {
this.skip = map.skip == null ? map : map.skip; this.skip = map.skip == null ? map : map.skip;
} }
public Set<T> get(RegionWrapper region) { public Set<T> get(CuboidRegion region) {
HashSet<T> set = new HashSet<>(); HashSet<T> set = new HashSet<>();
if (this.objects != null) { if (this.objects != null) {
for (T obj : this.objects) { for (T obj : this.objects) {
if (getRegion(obj).intersects(region)) { if (RegionUtil.intersects(getRegion(obj), region)) {
set.add(obj); set.add(obj);
} }
} }
@ -254,15 +255,15 @@ public class QuadMap<T> {
return set; return set;
} }
public boolean intersects(RegionWrapper other) { public boolean intersects(CuboidRegion other) {
return (other.minX <= this.x + this.size) && (other.maxX >= this.x - this.size) && ( return (other.getMinimumPoint().getX() <= this.x + this.size) && (other.getMaximumPoint().getX() >= this.x - this.size) && (
other.minZ <= this.z + this.size) && (other.maxZ >= this.z - this.size); other.getMinimumPoint().getZ() <= this.z + this.size) && (other.getMaximumPoint().getZ() >= this.z - this.size);
} }
public T get(int x, int z) { public T get(int x, int z) {
if (this.objects != null) { if (this.objects != null) {
for (T obj : this.objects) { for (T obj : this.objects) {
if (getRegion(obj).isIn(x, z)) { if (RegionUtil.contains(getRegion(obj), x, z)) {
return obj; return obj;
} }
} }

View File

@ -1,4 +1,4 @@
package com.github.intellectualsites.plotsquared.plot.util.block; package com.github.intellectualsites.plotsquared.plot.util.world;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;

View File

@ -1,4 +1,4 @@
package com.github.intellectualsites.plotsquared.plot.util.block; package com.github.intellectualsites.plotsquared.plot.util.world;
import com.github.intellectualsites.plotsquared.plot.util.MathMan; import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;

View File

@ -0,0 +1,40 @@
package com.github.intellectualsites.plotsquared.plot.util.world;
import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
public class RegionUtil {
public static CuboidRegion createRegion(int pos1x, int pos2x, int pos1z, int pos2z) {
return createRegion(pos1x, pos2x, 0, Plot.MAX_HEIGHT - 1, pos1z, pos2z);
}
public static CuboidRegion createRegion(int pos1x, int pos2x, int pos1y, int pos2y, int pos1z, int pos2z) {
BlockVector3 pos1 = BlockVector3.at(pos1x, pos1y, pos1z);
BlockVector3 pos2 = BlockVector3.at(pos2x, pos2y, pos2z);
return new CuboidRegion(pos1, pos2);
}
public static boolean contains(CuboidRegion region, int x, int z) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
return x >= min.getX() && x <= max.getX() && z >= min.getZ() && z <= max.getZ();
}
public static boolean contains(CuboidRegion region, int x, int y, int z) {
BlockVector3 min = region.getMinimumPoint();
BlockVector3 max = region.getMaximumPoint();
return x >= min.getX() && x <= max.getX() && z >= min.getZ() && z <= max.getZ() && y >= min.getY() && y <= max.getY();
}
// Because WE (not fawe) lack this for CuboidRegion
public static boolean intersects(CuboidRegion region, CuboidRegion other) {
BlockVector3 regionMin = region.getMinimumPoint();
BlockVector3 regionMax = region.getMaximumPoint();
BlockVector3 otherMin = other.getMinimumPoint();
BlockVector3 otherMax = other.getMaximumPoint();
return otherMin.getX() <= regionMax.getX() && otherMax.getX() >= regionMin.getX() && otherMin.getZ() <= regionMax.getZ() && otherMax.getZ() >= regionMin.getZ();
}
}

View File

@ -8,7 +8,7 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotId; import com.github.intellectualsites.plotsquared.plot.object.PlotId;
import com.github.intellectualsites.plotsquared.plot.util.EventUtil; import com.github.intellectualsites.plotsquared.plot.util.EventUtil;
import com.github.intellectualsites.plotsquared.plot.util.EventUtilTest; import com.github.intellectualsites.plotsquared.plot.util.EventUtilTest;
import com.github.intellectualsites.plotsquared.plot.util.block.BlockUtil; import com.github.intellectualsites.plotsquared.plot.util.world.BlockUtil;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;