From dda2636250c3c577d0ef31e228e083ab7722211c Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 28 Apr 2015 00:53:07 +1000 Subject: [PATCH] Fixed setup command --- .../plot/PlotSquared.java | 5 +++++ .../plot/commands/Info.java | 4 +++- .../plot/commands/Setup.java | 2 ++ .../plot/object/PlotGenerator.java | 22 ++++++++++++++++++- .../plot/util/bukkit/BukkitSetupUtils.java | 1 - 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index 75b10fa7c..7602010cc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -27,6 +27,7 @@ import java.util.zip.ZipInputStream; import net.milkbowl.vault.economy.Economy; +import org.apache.commons.lang.StringUtils; import org.bukkit.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.commands.Cluster; @@ -361,18 +362,22 @@ public class PlotSquared { final PlotGenerator gen_class = generator; plotWorld = gen_class.getNewPlotWorld(world); plotManager = gen_class.getPlotManager(); + if (!config.contains(path)) { config.createSection(path); } + plotWorld.TYPE = 2; plotWorld.TERRAIN = 0; plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); + try { config.save(configFile); } catch (final IOException e) { e.printStackTrace(); } + if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) { log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!"); return; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 91a1fbd49..7b357d131 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -163,7 +163,9 @@ public class Info extends SubCommand { final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; - final String biome = BlockManager.manager.getBiome(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1)); + Location top = MainUtil.getPlotTopLoc(world, plot.id); + Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1); + final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2)); final String helpers = getPlayerList(plot.helpers); final String trusted = getPlayerList(plot.trusted); final String denied = getPlayerList(plot.denied); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 613166fbd..a6da94f11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -140,6 +140,7 @@ public class Setup extends SubCommand { if (object.step == null) { object.plotManager = object.setupGenerator; object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object); } final ConfigurationNode step = object.step[object.setup_index]; sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + ""); @@ -148,6 +149,7 @@ public class Setup extends SubCommand { object.plotManager = object.setupGenerator; object.setupGenerator = null; object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes(); + ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object); } else { object.plotManager = "PlotSquared"; 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 6d5948b9d..1e5603760 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotGenerator.java @@ -150,7 +150,7 @@ public abstract class PlotGenerator extends ChunkGenerator { } /** - * random is a optimized random number generator.
+ * random is an optimized random number generator.
* - Change the state to have the same chunk random each time it generates
* requiredRegion If a plot is being regenerated, you are only required to generate content in this area
* - use the contains(RegionWrapper, x, z) method to check if the region contains a location
@@ -172,11 +172,31 @@ public abstract class PlotGenerator extends ChunkGenerator { public abstract List getPopulators(String world); + /** + * This is called when the generator is initialized. + * You don't need to do anything with it necessarily. + * @param plotworld + */ public abstract void init(PlotWorld plotworld); + /** + * Return a new instance of the PlotWorld for a world + * @param world + * @return + */ public abstract PlotWorld getNewPlotWorld(final String world); + /** + * Get the PlotManager class for this generator + * @return + */ public abstract PlotManager getPlotManager(); + /** + * If you need to do anything fancy for /plot setup
+ * - Otherwise it will just use the PlotWorld configuration
+ * Feel free to extend BukkitSetupUtils and customize world creation + * @param object + */ public void processSetup(SetupObject object) {}; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java index fee1b5334..2dfeabb86 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitSetupUtils.java @@ -45,7 +45,6 @@ public class BukkitSetupUtils extends SetupUtils { @Override public String setupWorld(final SetupObject object) { SetupUtils.manager.updateGenerators(); - ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);; final ConfigurationNode[] steps = object.step; final String world = object.world; for (final ConfigurationNode step : steps) {