From 2fb76e66364737ba5609fecd2c5e53b29bb36526 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 9 Jul 2020 22:39:06 +0100 Subject: [PATCH] Split road and plot paste-on-top settings --- .../plotsquared/core/configuration/Settings.java | 3 +++ .../plotsquared/core/generator/HybridGen.java | 3 ++- .../core/generator/HybridPlotManager.java | 16 +++++++++------- .../plotsquared/core/generator/HybridUtils.java | 14 +++++++------- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index db22c46be..f575fba43 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -388,6 +388,9 @@ public class Settings extends Config { @Comment( "Whether schematic based generation should paste schematic on top of plots, or from Y=1") public static boolean PASTE_ON_TOP = true; + @Comment( + "Whether schematic based road generation should paste schematic on top of roads, or from Y=1") + public static boolean PASTE_ROAD_ON_TOP = true; } 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 e661e4c5f..a4f955682 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridGen.java @@ -47,7 +47,8 @@ public class HybridGen extends IndependentPlotGenerator { private void placeSchem(HybridPlotWorld world, ScopedLocalBlockQueue result, short relativeX, short relativeZ, int x, int z, boolean isRoad) { int minY; // Math.min(world.PLOT_HEIGHT, world.ROAD_HEIGHT); - if (isRoad || Settings.Schematics.PASTE_ON_TOP) { + if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad + && Settings.Schematics.PASTE_ON_TOP)) { minY = world.SCHEM_Y; } else { minY = 1; diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java index 67ad6eb8b..da4fa74b9 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridPlotManager.java @@ -112,15 +112,17 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); queue.enqueue(); return true; } - private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2) { + private void createSchemAbs(LocalBlockQueue queue, Location pos1, Location pos2, + boolean isRoad) { int size = hybridPlotWorld.SIZE; int minY; - if (Settings.Schematics.PASTE_ON_TOP) { + if ((isRoad && Settings.Schematics.PASTE_ROAD_ON_TOP) || (!isRoad + && Settings.Schematics.PASTE_ON_TOP)) { minY = hybridPlotWorld.SCHEM_Y; } else { minY = 1; @@ -172,7 +174,7 @@ public class HybridPlotManager extends ClassicPlotManager { return true; } LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); queue.enqueue(); return true; } @@ -186,9 +188,9 @@ public class HybridPlotManager extends ClassicPlotManager { pos1.setY(0); pos2.setY(Math.min(getWorldHeight(), 255)); LocalBlockQueue queue = hybridPlotWorld.getQueue(false); - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); if (hybridPlotWorld.ROAD_SCHEMATIC_ENABLED) { - createSchemAbs(queue, pos1, pos2); + createSchemAbs(queue, pos1, pos2, true); } return queue.enqueue(); } @@ -267,7 +269,7 @@ public class HybridPlotManager extends ClassicPlotManager { if (!hybridPlotWorld.PLOT_SCHEMATIC) { return; } - createSchemAbs(queue, bottom, top); + createSchemAbs(queue, bottom, top, false); } /** diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java index ec70811db..539e9e1cd 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java @@ -83,6 +83,11 @@ public abstract class HybridUtils { public static PlotArea area; public static boolean UPDATE = false; + public static boolean regeneratePlotWalls(final PlotArea area) { + PlotManager plotManager = area.getPlotManager(); + return plotManager.regenerateAllPlotWalls(); + } + public void analyzeRegion(final String world, final CuboidRegion region, final RunnableVal whenDone) { // int diff, int variety, int vertices, int rotation, int height_sd @@ -501,7 +506,7 @@ public abstract class HybridUtils { PlotManager plotManager = plotworld.getPlotManager(); int sx = bot.getX() - plotworld.ROAD_WIDTH + 1; int sz = bot.getZ() + 1; - int sy = plotworld.ROAD_HEIGHT; + int sy = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotworld.ROAD_HEIGHT : 1; int ex = bot.getX(); int ez = top.getZ(); int ey = get_ey(plotManager, queue, sx, ex, sz, ez, sy); @@ -621,7 +626,7 @@ public abstract class HybridUtils { } if (condition) { BaseBlock[] blocks = plotWorld.G_SCH.get(MathMan.pair(absX, absZ)); - int minY = plotWorld.SCHEM_Y; + int minY = Settings.Schematics.PASTE_ROAD_ON_TOP ? plotWorld.SCHEM_Y : 1; int maxY = Math.max(extend, blocks.length); for (int y = 0; y < maxY; y++) { if (y > blocks.length - 1) { @@ -656,9 +661,4 @@ public abstract class HybridUtils { } return false; } - - public static boolean regeneratePlotWalls(final PlotArea area) { - PlotManager plotManager = area.getPlotManager(); - return plotManager.regenerateAllPlotWalls(); - } }