From 1f32707ec2a60f7ffb89488dae70fc688316daf8 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 5 Apr 2016 10:08:10 +1000 Subject: [PATCH 1/2] Fix populate offset for older versions --- .../bukkit/generator/BukkitPlotGenerator.java | 32 ++++++++++++++++--- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index 18338b3dc..74f1c3332 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; @@ -16,6 +17,7 @@ import com.intellectualcrafters.plot.util.SetQueue; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.block.GenChunk; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.Set; @@ -35,16 +37,34 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap private final boolean full; private boolean loaded = false; + HashMap dataMap = new HashMap<>(); + public BukkitPlotGenerator(IndependentPlotGenerator generator) { this.plotGenerator = generator; this.platformGenerator = this; this.populators.add(new BlockPopulator() { @Override public void populate(World world, Random r, Chunk c) { - GenChunk result = (GenChunk) BukkitPlotGenerator.this.chunkSetter; - if (result.result_data != null) { - for (int i = 0; i < result.result_data.length; i++) { - byte[] section = result.result_data[i]; + ChunkLoc loc = new ChunkLoc(c.getX(), c.getZ()); + byte[][] resultData; + if (!dataMap.containsKey(loc)) { + GenChunk result = (GenChunk) chunkSetter; + // Set the chunk location + result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), loc.x, loc.z)); + // Set the result data + result.result = new short[16][]; + result.result_data = new byte[16][]; + result.grid = null; + result.cd = null; + // Catch any exceptions (as exceptions usually thrown) + generate(world, loc.x, loc.z, result); + resultData = result.result_data; + } else { + resultData = dataMap.remove(loc); + } + if (resultData != null) { + for (int i = 0; i < resultData.length; i++) { + byte[] section = resultData[i]; if (section == null) { continue; } @@ -250,7 +270,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap return result.cd; } - public void generate(World world, int cx, int cz, GenChunk result) { + public void generate(World world, int cx, int cz, PlotChunk result) { // Load if improperly loaded if (!this.loaded) { String name = world.getName(); @@ -285,6 +305,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap return this.platformGenerator.generateExtBlockSections(world, r, cx, cz, grid); } else { generate(world, cx, cz, result); + dataMap.put(new ChunkLoc(cx, cz), result.result_data); + } } catch (Throwable e) { e.printStackTrace(); From fab60a0d539d76e310ec60014d962dd2ab199997 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 5 Apr 2016 11:07:37 +1000 Subject: [PATCH 2/2] Fix schematic on claim/auto --- .../main/java/com/plotsquared/bukkit/util/block/GenChunk.java | 4 +++- .../main/java/com/intellectualcrafters/plot/object/Plot.java | 2 +- .../com/intellectualcrafters/plot/util/SchematicHandler.java | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java index 8b0f2af43..286f63aee 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java @@ -41,7 +41,9 @@ public class GenChunk extends PlotChunk { @Override public void setBiome(int x, int z, int biome) { - this.grid.setBiome(x, z, this.biomes[biome]); + if (this.grid != null) { + this.grid.setBiome(x, z, this.biomes[biome]); + } } public void setBiome(int x, int z, Biome biome) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 7a775fa45..cda7b404b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -1301,7 +1301,7 @@ public class Plot { PlotArea plotworld = getArea(); if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; - if (schematic.isEmpty()) { + if (schematic == null || schematic.isEmpty()) { sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); } else { sch = SchematicHandler.manager.getSchematic(schematic); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 31c70b0cd..d151634a2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -705,7 +705,7 @@ public abstract class SchematicHandler { * @return Map of block location to tag */ public HashMap getTiles() { - return this.tiles; + return this.tiles == null ? new HashMap() : tiles; } /**