diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java index b0ef7e138..640ee389c 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/generator/ClassicPlotManager.java @@ -51,7 +51,9 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean unClaimPlot(Plot plot, Runnable whenDone) { setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING); - setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); + if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) { + setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); + } return GlobalBlockQueue.IMP.addEmptyTask(whenDone); } @@ -409,44 +411,29 @@ public class ClassicPlotManager extends SquarePlotManager { * @return false if part of the merge failed, otherwise true if successful. */ @Override public boolean finishPlotMerge(List plotIds) { - final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; - boolean success = true; - for (PlotId plotId : plotIds) { - success &= setWall(plotId, block); + final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; + if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + for (PlotId plotId : plotIds) { + setWall(plotId, claim); + } } if (Settings.General.MERGE_REPLACE_WALL) { final BlockBucket wallBlock = classicPlotWorld.WALL_FILLING; for (PlotId id : plotIds) { - success &= setWallFilling(id, wallBlock); + setWallFilling(id, wallBlock); } } - return success; + return true; } @Override public boolean finishPlotUnlink(List plotIds) { - final BlockBucket block = classicPlotWorld.CLAIMED_WALL_BLOCK; - boolean success = true; - for (PlotId id : plotIds) { - success &= setWall(id, block); - } - return success; - } - - /** - * Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed). - * - * @return true if the wall blocks were successfully set - */ - @Override public boolean regenerateAllPlotWalls() { - boolean success = true; - for (Plot plot : classicPlotWorld.getPlots()) { - if (plot.hasOwner()) { - success &= setWall(plot.getId(), classicPlotWorld.CLAIMED_WALL_BLOCK); - } else { - success &= setWall(plot.getId(), classicPlotWorld.WALL_BLOCK); + final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; + if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + for (PlotId id : plotIds) { + setWall(id, claim); } } - return success; + return true; // return false if unlink has been denied } @Override public boolean startPlotMerge(List plotIds) { @@ -459,7 +446,10 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean claimPlot(Plot plot) { final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; - return setWall(plot.getId(), claim); + if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + return setWall(plot.getId(), claim); + } + return true; } @Override public String[] getPlotComponents(PlotId plotId) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java index cc8e9cd72..43b519fc3 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/BlockBucket.java @@ -25,7 +25,7 @@ import java.util.Random; * A block bucket is a container of block types, where each block * has a specified chance of being randomly picked */ -@EqualsAndHashCode @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket +@EqualsAndHashCode(of={"blocks"}) @SuppressWarnings({"unused", "WeakerAccess"}) public final class BlockBucket implements Iterable, ConfigurationSerializable { private final Random random = new Random(); @@ -194,6 +194,11 @@ import java.util.Random; return builder.toString(); } + public boolean isAir() { + compile(); + return blocks.isEmpty() || (single != null && single.getBlockType().getMaterial().isAir()); + } + @Override public Map serialize() { if (!isCompiled()) { compile(); @@ -201,7 +206,6 @@ import java.util.Random; return ImmutableMap.of("blocks", this.toString()); } - @Getter @EqualsAndHashCode @RequiredArgsConstructor private final static class Range { private final int min; diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java index 0b39b2b7d..8f50f3504 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotManager.java @@ -90,6 +90,21 @@ public abstract class PlotManager { return 255; } - public abstract boolean regenerateAllPlotWalls(); + /** + * Sets all the blocks along all the plot walls to their correct state (claimed or unclaimed). + * + * @return true if the wall blocks were successfully set + */ + public boolean regenerateAllPlotWalls() { + boolean success = true; + for (Plot plot : plotArea.getPlots()) { + if (plot.hasOwner()) { + success &= claimPlot(plot); + } else { + success &= unClaimPlot(plot, null); + } + } + return success; + } }