From 63d04d3656f4cbb1d57ee6d6f149ecce2577a87d Mon Sep 17 00:00:00 2001 From: Moulberry Date: Sat, 11 Nov 2023 15:40:40 +0800 Subject: [PATCH] PlotSquared: Support for merged plots --- .../PlotSquaredIntegrationImpl.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/moulberry/axiom/integration/plotsquared/PlotSquaredIntegrationImpl.java b/src/main/java/com/moulberry/axiom/integration/plotsquared/PlotSquaredIntegrationImpl.java index c74f3b3..44ab1bd 100644 --- a/src/main/java/com/moulberry/axiom/integration/plotsquared/PlotSquaredIntegrationImpl.java +++ b/src/main/java/com/moulberry/axiom/integration/plotsquared/PlotSquaredIntegrationImpl.java @@ -168,7 +168,7 @@ public class PlotSquaredIntegrationImpl { for (int pz = minZ; pz <= maxZ; pz += 15) { PlotId pid = plotArea.getPlotManager().getPlotId(px, py, pz); if (pid == null) continue; - Plot plot = plotArea.getOwnedPlotAbs(pid); + Plot plot = plotArea.getOwnedPlot(pid); if (plot == null) continue; if (!checkedPlots.add(plot)) continue; @@ -177,23 +177,29 @@ public class PlotSquaredIntegrationImpl { if (!plot.isAdded(player.getUniqueId())) continue; if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) continue; - Location bottom = plot.getBottomAbs(); - Location top = plot.getTopAbs(); + for (CuboidRegion region : plot.getRegions()) { + BlockVector3 minPoint = region.getMinimumPoint(); + BlockVector3 maxPoint = region.getMaximumPoint(); - int minPlotX = Math.max(Math.min(bottom.getX(), top.getX()), minX); - int minPlotY = Math.max(Math.min(bottom.getY(), top.getY()), minY); - int minPlotZ = Math.max(Math.min(bottom.getZ(), top.getZ()), minZ); - int maxPlotX = Math.min(Math.max(bottom.getX(), top.getX()), maxX); - int maxPlotY = Math.min(Math.max(bottom.getY(), top.getY()), maxY); - int maxPlotZ = Math.min(Math.max(bottom.getZ(), top.getZ()), maxZ); + int minPlotX = Math.max(minPoint.getX(), minX); + int minPlotY = Math.max(minPoint.getY(), minY); + int minPlotZ = Math.max(minPoint.getZ(), minZ); + int maxPlotX = Math.min(maxPoint.getX(), maxX); + int maxPlotY = Math.min(maxPoint.getY(), maxY); + int maxPlotZ = Math.min(maxPoint.getZ(), maxZ); - if (minPlotX <= minX && minPlotY <= minY && minPlotZ <= minZ && - maxPlotX >= maxX && maxPlotY >= maxY && maxPlotZ >= maxZ) { - return SectionPermissionChecker.ALL_ALLOWED; + if (minPlotX > maxPlotX) continue; + if (minPlotY > maxPlotY) continue; + if (minPlotZ > maxPlotZ) continue; + + if (minPlotX <= minX && minPlotY <= minY && minPlotZ <= minZ && + maxPlotX >= maxX && maxPlotY >= maxY && maxPlotZ >= maxZ) { + return SectionPermissionChecker.ALL_ALLOWED; + } + + allowed.add(new Box(minPlotX - minX, minPlotY - minY, minPlotZ - minZ, + maxPlotX - minX, maxPlotY - minY, maxPlotZ - minZ)); } - - allowed.add(new Box(minPlotX - minX, minPlotY - minY, minPlotZ - minZ, - maxPlotX - minX, maxPlotY - minY, maxPlotZ - minZ)); } } }