From 2e4c43c251c3011ae13bf0670850cae1670ca41d Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Tue, 14 Jul 2020 19:10:53 +0100 Subject: [PATCH] Add config option to disable placing top wall blocks --- .../core/generator/ClassicPlotManager.java | 67 +++++++++++-------- .../core/generator/ClassicPlotWorld.java | 4 ++ .../plotsquared/core/generator/HybridGen.java | 12 ++-- 3 files changed, 50 insertions(+), 33 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java index 46333a84c..be60498bd 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotManager.java @@ -84,8 +84,8 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean unClaimPlot(Plot plot, Runnable whenDone) { setWallFilling(plot.getId(), classicPlotWorld.WALL_FILLING.toPattern()); - if (!classicPlotWorld.WALL_BLOCK.isAir() || !classicPlotWorld.WALL_BLOCK - .equals(classicPlotWorld.CLAIMED_WALL_BLOCK)) { + if (classicPlotWorld.PLACE_TOP_BLOCK && (!classicPlotWorld.WALL_BLOCK.isAir() + || !classicPlotWorld.WALL_BLOCK.equals(classicPlotWorld.CLAIMED_WALL_BLOCK))) { setWall(plot.getId(), classicPlotWorld.WALL_BLOCK.toPattern()); } return GlobalBlockQueue.IMP.addEmptyTask(whenDone); @@ -324,19 +324,23 @@ public class ClassicPlotManager extends SquarePlotManager { queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz + 1), new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING.toPattern()); - queue.setCuboid( - new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, - sz + 1), - new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, - ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); + if (classicPlotWorld.PLACE_TOP_BLOCK) { + queue.setCuboid( + new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, + sz + 1), + new Location(classicPlotWorld.getWorldName(), sx, classicPlotWorld.WALL_HEIGHT + 1, + ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); + } queue.setCuboid(new Location(classicPlotWorld.getWorldName(), ex, 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT, ez - 1), classicPlotWorld.WALL_FILLING.toPattern()); - queue.setCuboid( - new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, - sz + 1), - new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, - ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); + if (classicPlotWorld.PLACE_TOP_BLOCK) { + queue.setCuboid( + new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, + sz + 1), + new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.WALL_HEIGHT + 1, + ez - 1), classicPlotWorld.WALL_BLOCK.toPattern()); + } queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern()); @@ -362,19 +366,21 @@ public class ClassicPlotManager extends SquarePlotManager { queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, sz), classicPlotWorld.WALL_FILLING.toPattern()); - queue.setCuboid( - new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, - sz), - new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, - sz), classicPlotWorld.WALL_BLOCK.toPattern()); + if (classicPlotWorld.PLACE_TOP_BLOCK) { + queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, + classicPlotWorld.WALL_HEIGHT + 1, sz), + new Location(classicPlotWorld.getWorldName(), ex - 1, + classicPlotWorld.WALL_HEIGHT + 1, sz), classicPlotWorld.WALL_BLOCK.toPattern()); + } queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, ez), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT, ez), classicPlotWorld.WALL_FILLING.toPattern()); - queue.setCuboid( - new Location(classicPlotWorld.getWorldName(), sx + 1, classicPlotWorld.WALL_HEIGHT + 1, - ez), - new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.WALL_HEIGHT + 1, - ez), classicPlotWorld.WALL_BLOCK.toPattern()); + if (classicPlotWorld.PLACE_TOP_BLOCK) { + queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, + classicPlotWorld.WALL_HEIGHT + 1, ez), + new Location(classicPlotWorld.getWorldName(), ex - 1, + classicPlotWorld.WALL_HEIGHT + 1, ez), classicPlotWorld.WALL_BLOCK.toPattern()); + } queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx + 1, 1, sz + 1), new Location(classicPlotWorld.getWorldName(), ex - 1, classicPlotWorld.ROAD_HEIGHT, ez - 1), classicPlotWorld.ROAD_BLOCK.toPattern()); @@ -456,10 +462,10 @@ public class ClassicPlotManager extends SquarePlotManager { int ez = sz + classicPlotWorld.ROAD_WIDTH - 1; LocalBlockQueue queue = classicPlotWorld.getQueue(false); queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, - Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), - new Location(classicPlotWorld.getWorldName(), ex, - classicPlotWorld.getPlotManager().getWorldHeight(), ez), - BlockTypes.AIR.getDefaultState()); + Math.min(classicPlotWorld.PLOT_HEIGHT, classicPlotWorld.ROAD_HEIGHT) + 1, sz), + new Location(classicPlotWorld.getWorldName(), ex, + classicPlotWorld.getPlotManager().getWorldHeight(), ez), + BlockTypes.AIR.getDefaultState()); queue.setCuboid(new Location(classicPlotWorld.getWorldName(), sx, 1, sz), new Location(classicPlotWorld.getWorldName(), ex, classicPlotWorld.PLOT_HEIGHT - 1, ez), classicPlotWorld.MAIN_BLOCK.toPattern()); @@ -477,7 +483,8 @@ public class ClassicPlotManager extends SquarePlotManager { */ @Override public boolean finishPlotMerge(List plotIds) { final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; - if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + if (classicPlotWorld.PLACE_TOP_BLOCK && (!claim.isAir() || !claim + .equals(classicPlotWorld.WALL_BLOCK))) { for (PlotId plotId : plotIds) { setWall(plotId, claim.toPattern()); } @@ -493,7 +500,8 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean finishPlotUnlink(List plotIds) { final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; - if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + if (classicPlotWorld.PLACE_TOP_BLOCK && (!claim.isAir() || !claim + .equals(classicPlotWorld.WALL_BLOCK))) { for (PlotId id : plotIds) { setWall(id, claim.toPattern()); } @@ -511,7 +519,8 @@ public class ClassicPlotManager extends SquarePlotManager { @Override public boolean claimPlot(Plot plot) { final BlockBucket claim = classicPlotWorld.CLAIMED_WALL_BLOCK; - if (!claim.isAir() || !claim.equals(classicPlotWorld.WALL_BLOCK)) { + if (classicPlotWorld.PLACE_TOP_BLOCK && (!claim.isAir() || !claim + .equals(classicPlotWorld.WALL_BLOCK))) { return setWall(plot.getId(), claim.toPattern()); } return true; diff --git a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java index 13b2fb352..8a0e41c02 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/plotsquared/core/generator/ClassicPlotWorld.java @@ -52,6 +52,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { public BlockBucket ROAD_BLOCK = new BlockBucket(BlockTypes.QUARTZ_BLOCK); // BlockUtil.get((short) 155, (byte) 0); public boolean PLOT_BEDROCK = true; + public boolean PLACE_TOP_BLOCK = true; public ClassicPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator, PlotId min, PlotId max) { @@ -79,6 +80,8 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { ConfigurationUtil.BLOCK_BUCKET), new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", ConfigurationUtil.BLOCK_BUCKET), + new ConfigurationNode("wall.place_top_block", this.PLACE_TOP_BLOCK, + "Place or not the top block", ConfigurationUtil.BOOLEAN), new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", ConfigurationUtil.INTEGER), new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", @@ -109,5 +112,6 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { this.WALL_FILLING = new BlockBucket(config.getString("wall.filling")); this.WALL_HEIGHT = Math.min(254, config.getInt("wall.height")); this.CLAIMED_WALL_BLOCK = new BlockBucket(config.getString("wall.block_claimed")); + this.PLACE_TOP_BLOCK = config.getBoolean("wall.place_top_block"); } } diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java index a4f955682..c45931d81 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java @@ -172,8 +172,10 @@ public class HybridGen extends IndependentPlotGenerator { result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern()); } if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { - result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, - hybridPlotWorld.WALL_BLOCK.toPattern()); + if (hybridPlotWorld.PLACE_TOP_BLOCK) { + result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, + hybridPlotWorld.WALL_BLOCK.toPattern()); + } } else { placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true); @@ -197,8 +199,10 @@ public class HybridGen extends IndependentPlotGenerator { result.setBlock(x, y, z, hybridPlotWorld.WALL_FILLING.toPattern()); } if (!hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { - result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, - hybridPlotWorld.WALL_BLOCK.toPattern()); + if (hybridPlotWorld.PLACE_TOP_BLOCK) { + result.setBlock(x, hybridPlotWorld.WALL_HEIGHT + 1, z, + hybridPlotWorld.WALL_BLOCK.toPattern()); + } } else { placeSchem(hybridPlotWorld, result, relativeX[x], relativeZ[z], x, z, true);