From b35221bf4fea25bd2f176a7475aec0076f42e087 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 20 Dec 2018 12:23:49 +0000 Subject: [PATCH] Fix crashing on chunk load (chunks are still empty though) --- .../bukkit/generator/BukkitPlotGenerator.java | 17 +++++++++-------- .../plotsquared/bukkit/util/block/GenChunk.java | 9 +++++---- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java index cb3a44468..5277031bb 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -50,8 +50,7 @@ public class BukkitPlotGenerator extends ChunkGenerator PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null); ChunkWrapper wrap = new ChunkWrapper(area.worldname, c.getX(), c.getZ()); ScopedLocalBlockQueue chunk = queue.getForChunk(wrap.x, wrap.z); - if (BukkitPlotGenerator.this.plotGenerator - .populateChunk(chunk, area)) { + if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area)) { queue.flush(); } } @@ -218,15 +217,16 @@ public class BukkitPlotGenerator extends ChunkGenerator grid.setBiome(x, z, Biome.PLAINS); } } - return result.cd; + return result.getCd(); } } // Set the chunk location result.setChunk(new ChunkWrapper(world.getName(), cx, cz)); // Set the result data - result.cd = createChunkData(world); + result.setCd(createChunkData(world)); result.grid = grid; result.result = generateExtBlockSections(world, random, cx, cz, grid); + // Catch any exceptions (as exceptions usually thrown) try { // Fill the result data if necessary @@ -239,7 +239,7 @@ public class BukkitPlotGenerator extends ChunkGenerator e.printStackTrace(); } // Return the result data - return result.cd; + return result.getCd(); } public void generate(World world, ScopedLocalBlockQueue result) { @@ -272,11 +272,11 @@ public class BukkitPlotGenerator extends ChunkGenerator // Set the result data result.result = new PlotBlock[16][]; result.grid = grid; - result.cd = null; // Catch any exceptions (as exceptions usually thrown) try { if (this.platformGenerator != this) { - final ChunkData chunkData = this.platformGenerator.generateChunkData(world, r, cx, cz, grid); + final ChunkData chunkData = + this.platformGenerator.generateChunkData(world, r, cx, cz, grid); final PlotBlock[][] blocks = new PlotBlock[world.getMaxHeight() / 16][]; // section ID = Y >> 4 for (int x = 0; x < 16; x++) { @@ -285,7 +285,8 @@ public class BukkitPlotGenerator extends ChunkGenerator if (blocks[y >> 4] == null) { blocks[y >> 4] = new PlotBlock[4096]; } - blocks[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = PlotBlock.get(chunkData.getType(x, y, z)); + blocks[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = + PlotBlock.get(chunkData.getType(x, y, z)); } } } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java index 77f5b1fd6..1f9959f57 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/util/block/GenChunk.java @@ -6,6 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Location; import com.github.intellectualsites.plotsquared.plot.object.PlotBlock; import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.block.ScopedLocalBlockQueue; +import lombok.Getter; +import lombok.Setter; import org.bukkit.Chunk; import org.bukkit.Material; import org.bukkit.World; @@ -19,13 +21,12 @@ public class GenChunk extends ScopedLocalBlockQueue { public final Biome[] biomes; public PlotBlock[][] result; - public ChunkData cd; public BiomeGrid grid; - public Chunk chunk; public String world; public int cx; public int cz; + @Getter @Setter private ChunkData cd = null; public GenChunk(Chunk chunk, ChunkWrapper wrap) { super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15)); @@ -66,8 +67,8 @@ public class GenChunk extends ScopedLocalBlockQueue { } @Override public void setCuboid(Location pos1, Location pos2, PlotBlock block) { - if (result != null && pos1.getX() == 0 && pos1.getZ() == 0 - && pos2.getX() == 15 && pos2.getZ() == 15) { + if (result != null && pos1.getX() == 0 && pos1.getZ() == 0 && pos2.getX() == 15 + && pos2.getZ() == 15) { for (int y = pos1.getY(); y <= pos2.getY(); y++) { int layer = y >> 4; PlotBlock[] data = result[layer];