From d8849f718cef808a6492f9b23c6d9be9b0f151c1 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 26 Apr 2016 09:32:16 +1000 Subject: [PATCH] Fix plotworld get --- .../bukkit/generator/BukkitPlotGenerator.java | 10 +++++++++- .../main/java/com/intellectualcrafters/plot/PS.java | 13 ++++++++----- 2 files changed, 17 insertions(+), 6 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 42b6e68f7..f56473119 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -40,6 +40,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap private boolean loaded = false; public BukkitPlotGenerator(IndependentPlotGenerator generator) { + if (generator == null) { + throw new IllegalArgumentException("Generator may not be null!"); + } this.plotGenerator = generator; this.platformGenerator = this; this.populators.add(new BlockPopulator() { @@ -279,7 +282,12 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap return; } PlotArea area = PS.get().getPlotArea(world.getName(), null); - this.plotGenerator.generateChunk(this.chunkSetter, area, this.random); + try { + this.plotGenerator.generateChunk(this.chunkSetter, area, this.random); + } catch (Throwable e) { + // Recover from generator error + e.printStackTrace(); + } ChunkManager.postProcessChunk(result); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index 4f47aa6f3..2273590c0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -482,15 +482,18 @@ public class PS { public PlotArea getPlotArea(String world, String id) { PlotArea[] areas = this.plotAreaMap.get(world); - if (areas == null || id == null) { + if (areas == null) { return null; } if (areas.length == 1) { return areas[0]; - } - for (PlotArea area : areas) { - if (StringMan.isEqual(id, area.id)) { - return area; + } else if (id == null) { + return null; + } else { + for (PlotArea area : areas) { + if (StringMan.isEqual(id, area.id)) { + return area; + } } } return null;