From 107963ff40dfebc9907d59f1a9d0ee3920ebc9ac Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Wed, 5 Jul 2023 01:36:47 +0300 Subject: [PATCH 1/8] Fix loading schematic from clipboard; --- .../de/minebench/plotgenerator/PlotSchematic.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java index ab2e52d..9e9d19f 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java +++ b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java @@ -35,10 +35,17 @@ public PlotSchematic(Clipboard clipboard) { blocks = new BlockData[getWidth()][getHeight()][getLength()]; - for (int x = 0; x < getWidth(); x++) { - for (int z = 0; z < getLength(); z++) { - for (int y = 0; y < getHeight(); y++) { - setBlock(x, y, z, BukkitAdapter.adapt(clipboard.getBlock(BlockVector3.at(x, y, z)))); + BlockVector3 minimumPoint = clipboard.getMinimumPoint(); + BlockVector3 maximumPoint = clipboard.getMaximumPoint(); + + for (int x = minimumPoint.getBlockX(); x < maximumPoint.getBlockX() + 1; x++) { + for (int z = minimumPoint.getBlockZ(); z < maximumPoint.getBlockZ() + 1; z++) { + for (int y = minimumPoint.getBlockY(); y < maximumPoint.getBlockY() + 1; y++) { + BlockVector3 pos = BlockVector3.at(x, y, z); + BlockData adapt = BukkitAdapter.adapt(clipboard.getBlock(pos)); + + BlockVector3 relPos = pos.subtract(minimumPoint); + setBlock(relPos.getBlockX(), relPos.getBlockY(), relPos.getBlockZ(), adapt); } } } From a7ea5e5aed18edba63c63952628df2f3f484536a Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Wed, 5 Jul 2023 13:27:16 +0300 Subject: [PATCH 2/8] Migrate to use Clipboard instead of an array; --- .../plotgenerator/PlotChunkGenerator.java | 4 +- .../plotgenerator/PlotSchematic.java | 62 ++++++++----------- 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java index eeab3a1..17b2106 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java @@ -66,8 +66,8 @@ public ChunkData generateChunkData(World world, Random random, int x, int z, Bio int schemX = (startX + chunkX) % width; for (int chunkZ = 0; chunkZ < 16; chunkZ++) { int schemZ = (startZ + chunkZ) % length; - for (int chunkY = 0; chunkY < schematic.getHeight(); chunkY++) { - BlockData block = schematic.getBlock(schemX, chunkY, schemZ); + for (int chunkY = schematic.getMinY(); chunkY < schematic.getMaxY() + 1; chunkY++) { + BlockData block = schematic.getBlock(schemX, chunkY - schematic.getMinY(), schemZ); data.setBlock(chunkX, chunkY, chunkZ, block); if (sign == null && (block instanceof Sign || block instanceof WallSign)) { sign = BlockVector3.at(x * 16 + chunkX, chunkY, z * 16 + chunkZ); diff --git a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java index 9e9d19f..27ea43e 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java +++ b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java @@ -21,67 +21,59 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; +import com.sk89q.worldedit.world.block.BlockState; +import org.bukkit.Material; import org.bukkit.block.data.BlockData; public class PlotSchematic { - private final BlockVector3 size; - private final BlockVector3 origin; - - private final BlockData[][][] blocks; + private final Clipboard clipboard; + private final BlockVector3 dimensions; public PlotSchematic(Clipboard clipboard) { - size = clipboard.getDimensions(); - origin = clipboard.getOrigin(); - - blocks = new BlockData[getWidth()][getHeight()][getLength()]; - - BlockVector3 minimumPoint = clipboard.getMinimumPoint(); - BlockVector3 maximumPoint = clipboard.getMaximumPoint(); - - for (int x = minimumPoint.getBlockX(); x < maximumPoint.getBlockX() + 1; x++) { - for (int z = minimumPoint.getBlockZ(); z < maximumPoint.getBlockZ() + 1; z++) { - for (int y = minimumPoint.getBlockY(); y < maximumPoint.getBlockY() + 1; y++) { - BlockVector3 pos = BlockVector3.at(x, y, z); - BlockData adapt = BukkitAdapter.adapt(clipboard.getBlock(pos)); - - BlockVector3 relPos = pos.subtract(minimumPoint); - setBlock(relPos.getBlockX(), relPos.getBlockY(), relPos.getBlockZ(), adapt); - } - } - } - + this.clipboard = clipboard; + this.dimensions = clipboard.getDimensions(); } - private void setBlock(int x, int y, int z, BlockData blockData) throws IndexOutOfBoundsException { - blocks[x][y][z] = blockData; - } + public BlockData getBlock(int x, int y, int z) { + BlockVector3 pos = BlockVector3.at(x, y, z).add(clipboard.getMinimumPoint()); + if (!pos.containedWithin(clipboard.getMinimumPoint(), clipboard.getMaximumPoint())) { + return Material.AIR.createBlockData(); + } - public BlockData getBlock(int x, int y, int z) throws IndexOutOfBoundsException { - return blocks[x][y][z]; + BlockState blockState = clipboard.getBlock(pos); + return BukkitAdapter.adapt(blockState); } public BlockVector3 getSize() { - return size; + return dimensions; } public BlockVector3 getOrigin() { - return origin; + return clipboard.getOrigin(); } public int getWidth() { - return size.getBlockX(); + return dimensions.getBlockX(); } public int getLength() { - return size.getBlockZ(); + return dimensions.getBlockZ(); } public int getHeight() { - return size.getBlockY(); + return dimensions.getBlockY(); + } + + public int getMinY() { + return clipboard.getMinimumPoint().getBlockY(); + } + + public int getMaxY() { + return clipboard.getMaximumPoint().getBlockY(); } @Override public String toString() { - return "PlotSchematic{size=" + size + ",origin=" + origin + "}"; + return "PlotSchematic{size=" + getSize() + ",origin=" + getOrigin() + "}"; } } From f35f59b243248ded7865fdfa96af30a414c28277 Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Wed, 19 Jul 2023 19:09:36 +0300 Subject: [PATCH 3/8] Revert "Migrate to use Clipboard instead of an array;" This reverts commit a7ea5e5aed18edba63c63952628df2f3f484536a. --- .../plotgenerator/PlotChunkGenerator.java | 4 +- .../plotgenerator/PlotSchematic.java | 62 +++++++++++-------- 2 files changed, 37 insertions(+), 29 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java index 17b2106..eeab3a1 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java @@ -66,8 +66,8 @@ public ChunkData generateChunkData(World world, Random random, int x, int z, Bio int schemX = (startX + chunkX) % width; for (int chunkZ = 0; chunkZ < 16; chunkZ++) { int schemZ = (startZ + chunkZ) % length; - for (int chunkY = schematic.getMinY(); chunkY < schematic.getMaxY() + 1; chunkY++) { - BlockData block = schematic.getBlock(schemX, chunkY - schematic.getMinY(), schemZ); + for (int chunkY = 0; chunkY < schematic.getHeight(); chunkY++) { + BlockData block = schematic.getBlock(schemX, chunkY, schemZ); data.setBlock(chunkX, chunkY, chunkZ, block); if (sign == null && (block instanceof Sign || block instanceof WallSign)) { sign = BlockVector3.at(x * 16 + chunkX, chunkY, z * 16 + chunkZ); diff --git a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java index 27ea43e..9e9d19f 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotSchematic.java +++ b/src/main/java/de/minebench/plotgenerator/PlotSchematic.java @@ -21,59 +21,67 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.world.block.BlockState; -import org.bukkit.Material; import org.bukkit.block.data.BlockData; public class PlotSchematic { - private final Clipboard clipboard; - private final BlockVector3 dimensions; + private final BlockVector3 size; + private final BlockVector3 origin; + + private final BlockData[][][] blocks; public PlotSchematic(Clipboard clipboard) { - this.clipboard = clipboard; - this.dimensions = clipboard.getDimensions(); - } + size = clipboard.getDimensions(); + origin = clipboard.getOrigin(); + + blocks = new BlockData[getWidth()][getHeight()][getLength()]; + + BlockVector3 minimumPoint = clipboard.getMinimumPoint(); + BlockVector3 maximumPoint = clipboard.getMaximumPoint(); - public BlockData getBlock(int x, int y, int z) { - BlockVector3 pos = BlockVector3.at(x, y, z).add(clipboard.getMinimumPoint()); - if (!pos.containedWithin(clipboard.getMinimumPoint(), clipboard.getMaximumPoint())) { - return Material.AIR.createBlockData(); + for (int x = minimumPoint.getBlockX(); x < maximumPoint.getBlockX() + 1; x++) { + for (int z = minimumPoint.getBlockZ(); z < maximumPoint.getBlockZ() + 1; z++) { + for (int y = minimumPoint.getBlockY(); y < maximumPoint.getBlockY() + 1; y++) { + BlockVector3 pos = BlockVector3.at(x, y, z); + BlockData adapt = BukkitAdapter.adapt(clipboard.getBlock(pos)); + + BlockVector3 relPos = pos.subtract(minimumPoint); + setBlock(relPos.getBlockX(), relPos.getBlockY(), relPos.getBlockZ(), adapt); + } + } } - BlockState blockState = clipboard.getBlock(pos); - return BukkitAdapter.adapt(blockState); + } + + private void setBlock(int x, int y, int z, BlockData blockData) throws IndexOutOfBoundsException { + blocks[x][y][z] = blockData; + } + + public BlockData getBlock(int x, int y, int z) throws IndexOutOfBoundsException { + return blocks[x][y][z]; } public BlockVector3 getSize() { - return dimensions; + return size; } public BlockVector3 getOrigin() { - return clipboard.getOrigin(); + return origin; } public int getWidth() { - return dimensions.getBlockX(); + return size.getBlockX(); } public int getLength() { - return dimensions.getBlockZ(); + return size.getBlockZ(); } public int getHeight() { - return dimensions.getBlockY(); - } - - public int getMinY() { - return clipboard.getMinimumPoint().getBlockY(); - } - - public int getMaxY() { - return clipboard.getMaximumPoint().getBlockY(); + return size.getBlockY(); } @Override public String toString() { - return "PlotSchematic{size=" + getSize() + ",origin=" + getOrigin() + "}"; + return "PlotSchematic{size=" + size + ",origin=" + origin + "}"; } } From 403c64fdb20f85b88e78cbe3ab3dce186dfcbdef Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Sun, 23 Jul 2023 23:32:18 +0300 Subject: [PATCH 4/8] Fix information in README.md about create a world with MV; --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 47520f7..94cc5a9 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ You can define all settings of the generator directly via the id string of the g To create the same worlds as displayed below in the config section you would use the following commands (in Multiverse): -`/mv create test NORMAL -g PlotGenerator:testschematic,overlap=1,centerX=100,centerZ=0,regionId=%world%_plot_%number%,regionInset=5,regionMinY=40,regionMaxY=100,regionPrice=50` +`/mv create test NORMAL -g PlotGenerator:testschematic,overlap=1,x=100,y=64,z=0,regionId=%world%_plot_%number%,regionInset=5,regionMinY=40,regionMaxY=100,regionPrice=50` `/mv create mb_plotworld NORMAL -g PlotGenerator:config=test,schem=plot` (You need to have the test section of the config defined, it wont use the generator of the test world!) From b809aefd5b98d24bf7c59f7a7d2fa8a5e0ff14de Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Sun, 23 Jul 2023 23:34:07 +0300 Subject: [PATCH 5/8] Include Y center in plot generation; --- .../plotgenerator/PlotChunkGenerator.java | 93 +++++++++++-------- 1 file changed, 53 insertions(+), 40 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java index eeab3a1..adf63d7 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java @@ -46,54 +46,67 @@ public PlotChunkGenerator(PlotGenerator plugin, String id) { @Override public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) { ChunkData data = createChunkData(world); + PlotGeneratorConfig config = getConfig(world); - if (config != null && config.getSchematic() != null && !BlockVector3.ZERO.equals(config.getSchematic().getSize())) { - PlotSchematic schematic = config.getSchematic(); - BlockVector3 center = config.getCenter(); - int width = schematic.getWidth() - config.getOverlap(); - int startX = (x * 16 - center.getBlockX()) % width; - while (startX < 0) { - startX = width + startX; - } - int length = schematic.getLength() - config.getOverlap(); - int startZ = (z * 16 - center.getBlockZ()) % length; - while (startZ < 0) { - startZ = length + startZ; - } + if (config == null) { + return data; + } + + PlotSchematic schematic = config.getSchematic(); + if (schematic == null || BlockVector3.ZERO.equals(schematic.getSize())) { + return data; + } + + BlockVector3 center = config.getCenter(); - BlockVector3 sign = null; - for (int chunkX = 0; chunkX < 16; chunkX++) { - int schemX = (startX + chunkX) % width; - for (int chunkZ = 0; chunkZ < 16; chunkZ++) { - int schemZ = (startZ + chunkZ) % length; - for (int chunkY = 0; chunkY < schematic.getHeight(); chunkY++) { - BlockData block = schematic.getBlock(schemX, chunkY, schemZ); - data.setBlock(chunkX, chunkY, chunkZ, block); - if (sign == null && (block instanceof Sign || block instanceof WallSign)) { - sign = BlockVector3.at(x * 16 + chunkX, chunkY, z * 16 + chunkZ); - } + int width = schematic.getWidth() - config.getOverlap(); + int startX = (x * 16 - center.getBlockX()) % width; + while (startX < 0) { + startX = width + startX; + } + + int length = schematic.getLength() - config.getOverlap(); + int startZ = (z * 16 - center.getBlockZ()) % length; + while (startZ < 0) { + startZ = length + startZ; + } + + int startY = Math.max(world.getMinHeight(), center.getBlockY()); + int height = Math.min(startY + schematic.getHeight(), world.getMaxHeight()); + + BlockVector3 sign = null; + for (int chunkX = 0; chunkX < 16; chunkX++) { + int schemX = (startX + chunkX) % width; + for (int chunkZ = 0; chunkZ < 16; chunkZ++) { + int schemZ = (startZ + chunkZ) % length; + for (int chunkY = startY; chunkY < height; chunkY++) { + BlockData block = schematic.getBlock(schemX, chunkY - startY, schemZ); + data.setBlock(chunkX, chunkY, chunkZ, block); + if (sign == null && (block instanceof Sign || block instanceof WallSign)) { + sign = BlockVector3.at(x * 16 + chunkX, chunkY, z * 16 + chunkZ); } } } + } - if (plugin.getWorldGuard() != null && config.getRegionId() != null) { - BlockVector3 minPoint = BlockVector3.at( - x * 16 - startX + config.getRegionInset(), - config.getRegionMinY(), - z * 16 - startZ + config.getRegionInset() - ); - BlockVector3 maxPoint = BlockVector3.at( - minPoint.getBlockX() + width - 2 * config.getRegionInset(), - config.getRegionMaxY(), - minPoint.getBlockZ() + length - 2 * config.getRegionInset() - ); - RegionIntent intent = new RegionIntent(world, config, minPoint, maxPoint); - if (sign != null ) { - intent.setSign(sign); - } - plugin.registerRegionIntent(intent); + if (plugin.getWorldGuard() != null && config.getRegionId() != null) { + BlockVector3 minPoint = BlockVector3.at( + x * 16 - startX + config.getRegionInset(), + config.getRegionMinY(), + z * 16 - startZ + config.getRegionInset() + ); + BlockVector3 maxPoint = BlockVector3.at( + minPoint.getBlockX() + width - 2 * config.getRegionInset(), + config.getRegionMaxY(), + minPoint.getBlockZ() + length - 2 * config.getRegionInset() + ); + RegionIntent intent = new RegionIntent(world, config, minPoint, maxPoint); + if (sign != null ) { + intent.setSign(sign); } + plugin.registerRegionIntent(intent); } + return data; } From 562659f2a32cd7ba5bef8a4ca92a52fbd578c781 Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Sun, 23 Jul 2023 23:54:50 +0300 Subject: [PATCH 6/8] Async load plot schematic & lazy get it; --- .../plotgenerator/PlotGenerator.java | 61 ++++++++++--------- .../plotgenerator/PlotGeneratorConfig.java | 35 ++++++----- 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotGenerator.java index 5ab8228..d2cc073 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotGenerator.java @@ -59,6 +59,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.regex.Pattern; @@ -151,38 +152,40 @@ public Economy getEconomy() { return economy; } - public PlotSchematic loadSchematic(String schematicName) { - if (schematicName == null || schematicName.isEmpty()) { - return null; - } + public CompletableFuture loadSchematic(String schematicName) { + return CompletableFuture.supplyAsync(() -> { + if (schematicName == null || schematicName.isEmpty()) { + return null; + } - File file = new File(getDataFolder(), schematicName + ".schem"); - if (!file.exists()){ - file = new File(weSchemDir, schematicName + ".schem"); - } - if (!file.exists()){ - file = new File(getDataFolder(), schematicName + ".schematic"); - } - if (!file.exists()){ - file = new File(weSchemDir, schematicName + ".schematic"); - } - if (!file.exists()) { - getLogger().log(Level.SEVERE, "No schematic found with the name " + schematicName + "!"); - return null; - } + File file = new File(getDataFolder(), schematicName + ".schem"); + if (!file.exists()){ + file = new File(weSchemDir, schematicName + ".schem"); + } + if (!file.exists()){ + file = new File(getDataFolder(), schematicName + ".schematic"); + } + if (!file.exists()){ + file = new File(weSchemDir, schematicName + ".schematic"); + } + if (!file.exists()) { + getLogger().log(Level.SEVERE, "No schematic found with the name " + schematicName + "!"); + return null; + } - ClipboardFormat format = ClipboardFormats.findByFile(file); - if (format == null) { - getLogger().log(Level.SEVERE, "Could not load schematic format from file " + file.getAbsolutePath() + "!"); - return null; - } + ClipboardFormat format = ClipboardFormats.findByFile(file); + if (format == null) { + getLogger().log(Level.SEVERE, "Could not load schematic format from file " + file.getAbsolutePath() + "!"); + return null; + } - try { - return new PlotSchematic(loadSchematicFromFile(file, format)); - } catch (Exception e) { - getLogger().log(Level.SEVERE, "Error loading file " + file.getAbsolutePath(), e); - return null; - } + try { + return new PlotSchematic(loadSchematicFromFile(file, format)); + } catch (Exception e) { + getLogger().log(Level.SEVERE, "Error loading file " + file.getAbsolutePath(), e); + return null; + } + }); } private Clipboard loadSchematicFromFile(File file, ClipboardFormat format) throws IOException { diff --git a/src/main/java/de/minebench/plotgenerator/PlotGeneratorConfig.java b/src/main/java/de/minebench/plotgenerator/PlotGeneratorConfig.java index 98a69a1..a65c838 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotGeneratorConfig.java +++ b/src/main/java/de/minebench/plotgenerator/PlotGeneratorConfig.java @@ -18,15 +18,17 @@ * along with this program. If not, see . */ +import com.google.common.base.Suppliers; import com.sk89q.worldedit.math.BlockVector3; import org.bukkit.configuration.ConfigurationSection; +import java.util.function.Supplier; import java.util.logging.Level; public class PlotGeneratorConfig { private final String id; - private final PlotSchematic schematic; + private final Supplier schematic; private final BlockVector3 center; private final int overlap; private final String regionId; @@ -36,9 +38,9 @@ public class PlotGeneratorConfig { private final double regionPrice; private final String plotType; - public PlotGeneratorConfig(String id, PlotSchematic schematic, BlockVector3 center, int overlap, String regionId, int regionInset, int regionMinY, int regionMaxY, double regionPrice, String plotType) { + public PlotGeneratorConfig(String id, Supplier schematic, BlockVector3 center, int overlap, String regionId, int regionInset, int regionMinY, int regionMaxY, double regionPrice, String plotType) { this.id = id; - this.schematic = schematic; + this.schematic = Suppliers.memoize(schematic::get); this.center = center; this.overlap = overlap; this.regionId = regionId; @@ -176,7 +178,7 @@ public static PlotGeneratorConfig fromConfig(PlotGenerator plugin, Configuration } public PlotSchematic getSchematic() { - return schematic; + return schematic.get(); } public BlockVector3 getCenter() { @@ -218,7 +220,7 @@ public String getId() { public static class Builder { private String id; - private PlotSchematic schematic = null; + private Supplier schematic = Suppliers.ofInstance(null); private BlockVector3 center = BlockVector3.at(0, 0, 0); private int overlap = 0; private String regionId = null; @@ -237,16 +239,21 @@ public Builder(PlotGenerator plugin, String id) { } public Builder schematic(String name) { - return this.schematic(name, plugin.loadSchematic(name)); + return this.schematic(name, plugin.loadSchematic(name)::join); } - public Builder schematic(String name, PlotSchematic schematic) { - if (schematic == null) { - plugin.getLogger().log(Level.WARNING, "Schematic " + name + "not found?"); - return this; - } - this.schematic = schematic; - plugin.getLogger().log(Level.INFO, "Schematic: " + name + " (size: " + (schematic == null ? "null" : schematic.getSize()) + ")"); + public Builder schematic(String name, Supplier schematicSupplier) { + this.schematic = () -> { + PlotSchematic schematic = schematicSupplier.get(); + if (schematic == null) { + plugin.getLogger().log(Level.WARNING, "Schematic " + name + "not found?"); + return null; + } + + plugin.getLogger().log(Level.INFO, "Schematic: " + name + " (size: " + schematic.getSize() + ")"); + return schematic; + }; + return this; } @@ -333,7 +340,7 @@ public PlotGeneratorConfig build() { } public Builder copy(PlotGeneratorConfig config) { - schematic = config.getSchematic(); + schematic = config::getSchematic; center = config.getCenter(); overlap = config.getOverlap(); regionId = config.getRegionId(); From b403f482077b93754047977ad8e924d5a940d063 Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Fri, 11 Aug 2023 18:48:41 +0300 Subject: [PATCH 7/8] Fix minimum height in chunk generator; --- .../java/de/minebench/plotgenerator/PlotChunkGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java index adf63d7..d757b71 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java @@ -71,7 +71,7 @@ public ChunkData generateChunkData(World world, Random random, int x, int z, Bio startZ = length + startZ; } - int startY = Math.max(world.getMinHeight(), center.getBlockY()); + int startY = Math.max(-64, center.getBlockY()); int height = Math.min(startY + schematic.getHeight(), world.getMaxHeight()); BlockVector3 sign = null; From 44ae8d02c110747f9ace85ff2e39e63d491115f9 Mon Sep 17 00:00:00 2001 From: HarvelsX <90945793+HarvelsX@users.noreply.github.com> Date: Sat, 9 Sep 2023 22:56:26 +0300 Subject: [PATCH 8/8] Remove height normalization; --- .../java/de/minebench/plotgenerator/PlotChunkGenerator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java index d757b71..5f50789 100644 --- a/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java +++ b/src/main/java/de/minebench/plotgenerator/PlotChunkGenerator.java @@ -71,8 +71,8 @@ public ChunkData generateChunkData(World world, Random random, int x, int z, Bio startZ = length + startZ; } - int startY = Math.max(-64, center.getBlockY()); - int height = Math.min(startY + schematic.getHeight(), world.getMaxHeight()); + int startY = center.getBlockY(); + int height = startY + schematic.getHeight(); BlockVector3 sign = null; for (int chunkX = 0; chunkX < 16; chunkX++) {