From dcf1475d92288a653235bab8af3f5f831e96b939 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 9 May 2015 16:24:03 +1000 Subject: [PATCH] External generators Fixed an issue with external generators not working correctly (caused by another "fix"). The following will need to be updated: - AdvPlots - IslandPlots --- PlotSquared/pom.xml | 2 +- .../main/java/com/intellectualcrafters/plot/BukkitMain.java | 4 ++-- .../main/java/com/intellectualcrafters/plot/PlotSquared.java | 2 +- .../com/intellectualcrafters/plot/commands/Template.java | 4 +++- .../plot/database/plotme/PlotMeConverter.java | 2 +- .../com/intellectualcrafters/plot/generator/HybridGen.java | 5 +++++ .../com/intellectualcrafters/plot/listeners/WorldEvents.java | 2 +- .../com/intellectualcrafters/plot/object/PlotGenerator.java | 4 ++++ 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 73e00de9e..5c32816aa 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -8,7 +8,7 @@ UTF-8 PlotSquared - 2.10.6 + 2.10.7 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 5b7d78cf0..7b3c22874 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -328,7 +328,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (!PlotSquared.setupPlotWorld(world, id)) { return null; } - HybridGen result = new HybridGen(); + HybridGen result = new HybridGen(world); TaskManager.runTaskLater(new Runnable() { @Override public void run() { @@ -440,7 +440,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if ((gen_plugin != null) && gen_plugin.isEnabled()) { return gen_plugin.getDefaultWorldGenerator(world, ""); } else { - return new HybridGen(); + return new HybridGen(world); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 88c4ad300..d9ff3a956 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -350,7 +350,7 @@ public class PlotSquared { try { final String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); if (gen_string == null) { - generator = new HybridGen(); + generator = new HybridGen(world); } else { generator = (PlotGenerator) IMP.getGenerator(world, gen_string); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 4b40fe96d..f40d81007 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -30,6 +30,7 @@ import java.util.zip.ZipInputStream; import java.util.zip.ZipOutputStream; import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PlotSquared; @@ -87,7 +88,8 @@ public class Template extends SubCommand { PlotSquared.config.set("worlds." + world, worldConfig.get("")); try { PlotSquared.config.save(PlotSquared.configFile); - } catch (IOException e) { + PlotSquared.config.load(PlotSquared.configFile); + } catch (Exception e) { e.printStackTrace(); } String manager = worldConfig.getString("generator.plugin"); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java index b768e79e4..2e21e1937 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/database/plotme/PlotMeConverter.java @@ -266,7 +266,7 @@ public class PlotMeConverter { // Load using Bukkit API // - User must set generator manually Bukkit.getServer().unloadWorld(world, true); - final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld(); + final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen(actualWorldName)).createWorld(); myworld.save(); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java index 26154df34..3c57d5918 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridGen.java @@ -46,6 +46,11 @@ import com.intellectualcrafters.plot.object.RegionWrapper; * @author Empire92 */ public class HybridGen extends PlotGenerator { + + public HybridGen(String world) { + super(world); + } + /** * Set to static to re-use the same managet for all Default World Generators */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEvents.java index 16a9a7229..0a07ce98d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEvents.java @@ -17,7 +17,7 @@ public class WorldEvents implements Listener { public static String lastWorld = null; public static String getName(World world) { - if (lastWorld != null) { + if (lastWorld != null && !lastWorld.equals("CheckingPlotSquaredGenerator")) { return lastWorld; } else { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java index 411aeeabd..e0a8e9868 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -41,6 +41,10 @@ public abstract class PlotGenerator extends ChunkGenerator { public int X; public int Z; private PseudoRandom random = new PseudoRandom(); + + public PlotGenerator(String world) { + WorldEvents.lastWorld = world; + } @SuppressWarnings("unchecked") @Override