From 4d8b9f967433295582338a0939bea49ac7c0f05a Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 3 Aug 2015 05:25:41 +1000 Subject: [PATCH] World generation options for sponge --- .../com/intellectualcrafters/plot/PS.java | 2 - .../plot/commands/Cluster.java | 49 +-- .../plot/commands/MainCommand.java | 3 + .../plot/commands/WE_Anywhere.java | 3 +- .../plot/object/RegionWrapper.java | 4 + .../plot/util/ClusterManager.java | 1 + .../plot/util/SchematicHandler.java | 65 ++-- .../plot/util/SetupUtils.java | 3 + .../com/plotsquared/bukkit/BukkitMain.java | 6 +- .../bukkit/generator/AugmentedPopulator.java | 6 +- .../bukkit/listeners/PlayerEvents.java | 7 +- .../listeners/worldedit/WEListener.java | 3 +- .../bukkit/util/BukkitCommand.java | 3 - .../bukkit/util/BukkitSetupUtils.java | 11 +- .../bukkit/util/WorldEditSchematic.java | 3 +- .../com/plotsquared/sponge/SpongeMain.java | 54 +++- .../sponge/SpongeSchematicHandler.java | 7 +- .../plotsquared/sponge/SpongeSetupUtils.java | 88 ++++++ .../sponge/generator/AugmentedPopulator.java | 291 ++++++++++++++++++ .../sponge/generator/SpongeBasicGen.java | 12 +- .../generator/SpongeGeneratorWrapper.java | 17 +- .../sponge/generator/SpongePlotPopulator.java | 1 - .../sponge/generator/WorldModify.java | 31 +- 23 files changed, 559 insertions(+), 111 deletions(-) create mode 100644 src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java create mode 100644 src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java index a7bab50b8..1ddbbce40 100644 --- a/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/src/main/java/com/intellectualcrafters/plot/PS.java @@ -80,7 +80,6 @@ import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; /** * An implementation of the core, @@ -99,7 +98,6 @@ public class PS { private final HashMap plotmanagers = new HashMap<>(); // public: - public WorldEditPlugin worldEdit = null; public File configFile; public File translationFile; public YamlConfiguration style; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 2c2712c01..49310113a 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -24,11 +24,10 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.UUID; -import org.bukkit.generator.ChunkGenerator; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; +import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -43,9 +42,10 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.generator.AugmentedPopulator; -import com.plotsquared.bukkit.generator.BukkitPlotGenerator; -import com.plotsquared.bukkit.generator.HybridGen; +//import com.plotsquared.bukkit.generator.AugmentedPopulator; +//import com.plotsquared.bukkit.generator.AugmentedPopulator; +//import com.plotsquared.bukkit.generator.BukkitPlotGenerator; +//import com.plotsquared.bukkit.generator.HybridGen; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( @@ -157,21 +157,32 @@ public class Cluster extends SubCommand { PS.get().loadWorld(world, PS.get().IMP.getGenerator(world, null)); } else { - final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin"); - BukkitPlotGenerator generator; + String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin"); if (gen_string == null) { - generator = new HybridGen(world); - } else { - ChunkGenerator chunkgen = (ChunkGenerator) PS.get().IMP.getGenerator(world, gen_string).generator; - if (chunkgen instanceof BukkitPlotGenerator) { - generator = (BukkitPlotGenerator) chunkgen; - } - else { - MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ",")); - return false; - } + gen_string = "PlotSquared"; } - new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); + PlotGenerator wrapper = PS.get().IMP.getGenerator(world, gen_string); + if (wrapper.isFull()) { + wrapper.augment(cluster, plotworld); + } + else { + MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ",")); + return false; + } +// BukkitPlotGenerator generator; +// if (gen_string == null) { +// generator = new HybridGen(world); +// } else { +// ChunkGenerator chunkgen = (ChunkGenerator) PS.get().IMP.getGenerator(world, gen_string).generator; +// if (chunkgen instanceof BukkitPlotGenerator) { +// generator = (BukkitPlotGenerator) chunkgen; +// } +// else { +// MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ",")); +// return false; +// } +// } +// new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); } MainUtil.sendMessage(plr, C.CLUSTER_ADDED); return true; @@ -222,7 +233,7 @@ public class Cluster extends SubCommand { } DBFunc.delete(cluster); if (plotworld.TYPE == 2) { - AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster); + SetupUtils.manager.removePopulator(plr.getLocation().getWorld(), cluster); } ClusterManager.last = null; ClusterManager.clusters.get(cluster.world).remove(cluster); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index e2a855dd2..6907358ab 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -125,6 +125,9 @@ public class MainCommand extends CommandManager { createCommand(new Copy()); createCommand(new Chat()); createCommand(new Trim()); + if (Settings.ENABLE_CLUSTERS) { + MainCommand.getInstance().addCommand(new Cluster()); + } } public static boolean no_permission(final PlotPlayer player, final String permission) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 583eaebc8..acbe7f239 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.listeners.worldedit.WEManager; import com.plotsquared.general.commands.CommandDeclaration; @@ -41,7 +42,7 @@ public class WE_Anywhere extends SubCommand { @Override public boolean onCommand(PlotPlayer player, String[] arguments) { - if (PS.get().worldEdit == null) { + if (BukkitMain.worldEdit == null) { MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server"); return true; } diff --git a/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java b/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java index 54ff17720..e536145e0 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java +++ b/src/main/java/com/intellectualcrafters/plot/object/RegionWrapper.java @@ -12,4 +12,8 @@ public class RegionWrapper { this.maxZ = maxZ; this.minZ = minZ; } + + public boolean isIn(final int x, final int z) { + return ((x >= this.minX) && (x <= this.maxX) && (z >= this.minZ) && (z <= this.maxZ)); + } } diff --git a/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 23ca04120..6dfc4906d 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.Map.Entry; import java.util.Random; import org.bukkit.Bukkit; diff --git a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 0da7b398a..ae875af33 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.plotsquared.bukkit.object.schematic.StateWrapper; -import com.plotsquared.bukkit.util.WorldEditSchematic; public abstract class SchematicHandler { public static SchematicHandler manager; @@ -98,40 +97,38 @@ public abstract class SchematicHandler { if (area > 4096) { PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used"); } - if (area <= 4096 && PS.get().worldEdit != null) { - new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id); - } - else { - final Runnable THIS = this; - SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal() { - @Override - public void run() { - if (value == null) { - MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); - } - else { - TaskManager.runTaskAsync(new Runnable() { - @Override - public void run() { - MainUtil.sendMessage(null, "&6ID: " + plot.id); - final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic"); - if (!result) { - MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); - } else { - MainUtil.sendMessage(null, "&7 - &a success: " + plot.id); - } - TaskManager.runTask(new Runnable() { - @Override - public void run() { - THIS.run(); - } - }); - } - }); - } +// if (area <= 4096 && PS.get().worldEdit != null) { +// new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id); +// } + final Runnable THIS = this; + SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal() { + @Override + public void run() { + if (value == null) { + MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id); } - }); - } + else { + TaskManager.runTaskAsync(new Runnable() { + @Override + public void run() { + MainUtil.sendMessage(null, "&6ID: " + plot.id); + final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic"); + if (!result) { + MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id); + } else { + MainUtil.sendMessage(null, "&7 - &a success: " + plot.id); + } + TaskManager.runTask(new Runnable() { + @Override + public void run() { + THIS.run(); + } + }); + } + }); + } + } + }); } }); return true; diff --git a/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java b/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java index 5d61cfd66..9ba08a12a 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java +++ b/src/main/java/com/intellectualcrafters/plot/util/SetupUtils.java @@ -4,6 +4,7 @@ import java.util.HashMap; import java.util.Map; import com.intellectualcrafters.plot.generator.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; @@ -19,4 +20,6 @@ public abstract class SetupUtils { public abstract String getGenerator(PlotWorld plotworld); public abstract String setupWorld(final SetupObject object); + + public abstract void removePopulator(String world, PlotCluster cluster); } diff --git a/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/src/main/java/com/plotsquared/bukkit/BukkitMain.java index b41fa3aa7..ece0c5e6a 100644 --- a/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -88,9 +88,11 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS; + public static WorldEditPlugin worldEdit; private int[] version; + @Override public int[] getServerVersion() { if (version == null) { @@ -345,8 +347,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void registerWorldEditEvents() { if (getServer().getPluginManager().getPlugin("WorldEdit") != null) { - PS.get().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); - final String version = PS.get().worldEdit.getDescription().getVersion(); + BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit"); + final String version = BukkitMain.worldEdit.getDescription().getVersion(); if ((version != null) && version.startsWith("5.")) { log("&cThis version of WorldEdit does not support PlotSquared."); log("&cPlease use WorldEdit 6+ for masking support"); diff --git a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java index 9cec44063..0835d9997 100644 --- a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java +++ b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java @@ -42,6 +42,7 @@ public class AugmentedPopulator extends BlockPopulator { public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { MainUtil.initCache(); + PS.log("== NEW AUGMENTED POPULATOR FOR: " + world); this.cluster = cluster; this.generator = generator; this.plotworld = PS.get().getPlotWorld(world); @@ -99,6 +100,7 @@ public class AugmentedPopulator extends BlockPopulator { public void populate(final World world, final Random rand, final Chunk chunk) { final int cx = chunk.getX(); final int cz = chunk.getZ(); + PS.log("== POPULATING FOR: " + world + " | " + cx + "," + cz); final int bx = cx << 4; final int bz = cz << 4; final int tx = bx + 15; @@ -257,8 +259,4 @@ public class AugmentedPopulator extends BlockPopulator { populator.populate(world, this.r, chunk); } } - - public boolean isIn(final RegionWrapper plot, final int x, final int z) { - return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ)); - } } diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 87ec06512..76f1559ea 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -139,6 +139,7 @@ import com.intellectualcrafters.plot.util.RegExUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.listeners.worldedit.WEManager; import com.plotsquared.bukkit.object.BukkitLazyBlock; import com.plotsquared.bukkit.object.BukkitPlayer; @@ -454,7 +455,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen final UUID uuid = pp.getUUID(); UUIDHandler.add(name, uuid); ExpireManager.dates.put(uuid, System.currentTimeMillis()); - if (PS.get().worldEdit != null) { + if (BukkitMain.worldEdit != null) { if (Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) { WEManager.bypass.add(pp.getName()); } @@ -741,7 +742,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location"); BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); - if (PS.get().worldEdit != null) { + if (BukkitMain.worldEdit != null) { if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) { WEManager.bypass.remove(pp.getName()); } @@ -1613,7 +1614,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer()); ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis()); EventUtil.unregisterPlayer(pp); - if (PS.get().worldEdit != null) { + if (BukkitMain.worldEdit != null) { WEManager.bypass.remove(pp.getName()); } if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { diff --git a/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java b/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java index 536f610b8..95685db54 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java @@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.util.BukkitUtil; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.bukkit.selections.Selection; @@ -93,7 +94,7 @@ public class WEListener implements Listener { } public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) { - final Selection selection = PS.get().worldEdit.getSelection(p); + final Selection selection = BukkitMain.worldEdit.getSelection(p); if (selection == null) { return true; } diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java index 29d53f6f2..1ab214022 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java @@ -29,9 +29,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter { public BukkitCommand() { MainCommand.getInstance().addCommand(new DebugUUID()); - if (Settings.ENABLE_CLUSTERS) { - MainCommand.getInstance().addCommand(new Cluster()); - } } @Override diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java b/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java index cf0a800ad..fd8b251ba 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java @@ -13,9 +13,11 @@ import org.bukkit.plugin.Plugin; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.generator.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; +import com.plotsquared.bukkit.generator.AugmentedPopulator; import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper; import com.plotsquared.bukkit.generator.BukkitPlotGenerator; @@ -33,11 +35,7 @@ public class BukkitSetupUtils extends SetupUtils { if (generator != null) { PS.get().removePlotWorld(testWorld); final String name = plugin.getDescription().getName(); -// final PlotGenerator pgen = (PlotGenerator) generator; -// if (pgen.getPlotManager() instanceof SquarePlotManager) { SetupUtils.generators.put(name, new BukkitGeneratorWrapper("CheckingPlotSquaredGenerator", generator)); -// } -// } } } } @@ -115,4 +113,9 @@ public class BukkitSetupUtils extends SetupUtils { } return null; } + + @Override + public void removePopulator(String world, PlotCluster cluster) { + AugmentedPopulator.removePopulator(world, cluster); + } } diff --git a/src/main/java/com/plotsquared/bukkit/util/WorldEditSchematic.java b/src/main/java/com/plotsquared/bukkit/util/WorldEditSchematic.java index 1b2e31b1c..7f635d3ae 100644 --- a/src/main/java/com/plotsquared/bukkit/util/WorldEditSchematic.java +++ b/src/main/java/com/plotsquared/bukkit/util/WorldEditSchematic.java @@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; +import com.plotsquared.bukkit.BukkitMain; import com.sk89q.worldedit.CuboidClipboard; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; @@ -22,7 +23,7 @@ public class WorldEditSchematic { CuboidClipboard clipboard = new CuboidClipboard(size, origin); Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ()); Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ()); - EditSession session = PS.get().worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999); + EditSession session = BukkitMain.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999); clipboard.copy(session); try { clipboard.saveSchematic(new File(file)); diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java index 88850a406..b032cc30c 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -50,6 +50,7 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; @@ -240,14 +241,27 @@ public class SpongeMain implements IPlotMain, PluginContainer { ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds"); if (worldSection != null) { for (String world : worldSection.getKeys(false)) { - - SpongeBasicGen generator = new SpongeBasicGen(world); - PS.get().loadWorld(world, new SpongeGeneratorWrapper(world, generator)); - - this.modify = new WorldModify(generator); - Game game = event.getGame(); + createWorldFromConfig(world); + } + } + } + + public World createWorldFromConfig(String world) { + SpongeBasicGen generator = new SpongeBasicGen(world); + PlotWorld plotworld = generator.getNewPlotWorld(world); + SpongeGeneratorWrapper wrapper; + if (plotworld.TYPE == 0) { + wrapper = new SpongeGeneratorWrapper(world, generator); + } + else { + wrapper = new SpongeGeneratorWrapper(world, null); + } + PS.get().loadWorld(world, wrapper); + switch (plotworld.TYPE) { + // Normal + case 0: { + this.modify = new WorldModify(generator, false); game.getRegistry().registerWorldGeneratorModifier(modify); - Optional builder = game.getRegistry().getWorldBuilder() .name(world) .enabled(true) @@ -255,11 +269,26 @@ public class SpongeMain implements IPlotMain, PluginContainer { .keepsSpawnLoaded(true) .dimensionType(DimensionTypes.OVERWORLD) .generator(GeneratorTypes.FLAT) - .gameMode(GameModes.CREATIVE) .usesMapFeatures(false) .generatorModifiers(modify) .build(); - World worldObj = builder.get(); + return builder.get(); + } + // Augmented + default: { + this.modify = new WorldModify(generator, true); + game.getRegistry().registerWorldGeneratorModifier(modify); + Optional builder = game.getRegistry().getWorldBuilder() + .name(world) + .enabled(true) + .loadsOnStartup(true) + .keepsSpawnLoaded(true) + .dimensionType(DimensionTypes.OVERWORLD) + .generator(GeneratorTypes.OVERWORLD) + .usesMapFeatures(false) + .generatorModifiers(modify) + .build(); + return builder.get(); } } } @@ -433,7 +462,7 @@ public class SpongeMain implements IPlotMain, PluginContainer { return new SpongeGeneratorWrapper(world, null); } if (name.equals("PlotSquared")) { - return new SpongeGeneratorWrapper(world, null); + return new SpongeGeneratorWrapper(world, new SpongeBasicGen(world)); } else { throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); @@ -465,8 +494,7 @@ public class SpongeMain implements IPlotMain, PluginContainer { @Override public SetupUtils initSetupUtils() { - // TODO Auto-generated method stub - return null; + return new SpongeSetupUtils(); } @Override @@ -585,7 +613,7 @@ public class SpongeMain implements IPlotMain, PluginContainer { @Override public void setGenerator(String world) { - // THIS IS DONE DURING STARTUP ALREADY + // TODO THIS IS DONE DURING STARTUP ALREADY } @Override diff --git a/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java b/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java index bb9204054..af4b93b99 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java +++ b/src/main/java/com/plotsquared/sponge/SpongeSchematicHandler.java @@ -14,6 +14,7 @@ import com.intellectualcrafters.jnbt.ListTag; import com.intellectualcrafters.jnbt.ShortTag; import com.intellectualcrafters.jnbt.StringTag; import com.intellectualcrafters.jnbt.Tag; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; @@ -85,8 +86,10 @@ public class SpongeSchematicHandler extends SchematicHandler { // save schematics ChunkLoc chunk = chunks.remove(0); - if (!worldObj.loadChunk(chunk.x << 4, 0, chunk.z << 4, false).isPresent()) { - continue; + if (!worldObj.loadChunk(chunk.x << 4, 1, chunk.z << 4, false).isPresent()) { + System.out.println("COULD NOT LOAD CHUNK AT: " + chunk.x + "," + chunk.z); + // TODO continue - right now sponge chunk api seems to be broken :( + // continue; } int X = chunk.x; diff --git a/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java b/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java new file mode 100644 index 000000000..6edaa7b1b --- /dev/null +++ b/src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java @@ -0,0 +1,88 @@ +package com.plotsquared.sponge; + +import java.io.IOException; +import java.util.Map.Entry; + +import org.spongepowered.api.world.World; +import org.spongepowered.api.world.gen.WorldGenerator; + +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.config.ConfigurationNode; +import com.intellectualcrafters.plot.generator.PlotGenerator; +import com.intellectualcrafters.plot.object.PlotCluster; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.object.SetupObject; +import com.intellectualcrafters.plot.util.SetupUtils; +import com.plotsquared.sponge.generator.AugmentedPopulator; +import com.plotsquared.sponge.generator.SpongeBasicGen; +import com.plotsquared.sponge.generator.SpongeGeneratorWrapper; +import com.plotsquared.sponge.generator.SpongePlotGenerator; +import com.plotsquared.sponge.util.SpongeUtil; + +public class SpongeSetupUtils extends SetupUtils { + + @Override + public void updateGenerators() { + if (SetupUtils.generators.size() > 0) { + return; + } + // TODO get external world generators + final String testWorld = "CheckingPlotSquaredGenerator"; + SetupUtils.generators.put("PlotSquared", new SpongeGeneratorWrapper(testWorld, new SpongeBasicGen(testWorld))); + } + + @Override + public String getGenerator(PlotWorld plotworld) { + if (SetupUtils.generators.size() == 0) { + updateGenerators(); + } + World world = SpongeUtil.getWorld(plotworld.worldname); + if (world == null) { + return null; + } + WorldGenerator generator = world.getWorldGenerator(); + if (!(generator instanceof SpongePlotGenerator)) { + return null; + } + for (Entry> entry : generators.entrySet()) { + if (entry.getValue().generator.getClass().getName().equals(generator.getClass().getName())) { + return entry.getKey(); + } + } + return null; + } + + @Override + public String setupWorld(SetupObject object) { + SetupUtils.manager.updateGenerators(); + final ConfigurationNode[] steps = object.step; + final String world = object.world; + for (final ConfigurationNode step : steps) { + PS.get().config.set("worlds." + world + "." + step.getConstant(), step.getValue()); + } + if (object.type != 0) { + PS.get().config.set("worlds." + world + "." + "generator.type", object.type); + PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain); + PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager); + if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) { + PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator); + } + PlotGenerator gen = (PlotGenerator) generators.get(object.setupGenerator); + if (gen != null && gen.generator instanceof SpongePlotGenerator) { + object.setupGenerator = null; + } + } + try { + PS.get().config.save(PS.get().configFile); + } catch (final IOException e) { + e.printStackTrace(); + } + SpongeMain.THIS.createWorldFromConfig(world); + return object.world; + } + + @Override + public void removePopulator(String world, PlotCluster cluster) { + AugmentedPopulator.removePopulator(world, cluster); + } +} diff --git a/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java new file mode 100644 index 000000000..54262460e --- /dev/null +++ b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java @@ -0,0 +1,291 @@ +package com.plotsquared.sponge.generator; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Random; + +import org.spongepowered.api.block.BlockState; +import org.spongepowered.api.block.BlockType; +import org.spongepowered.api.world.Chunk; +import org.spongepowered.api.world.World; +import org.spongepowered.api.world.extent.MutableBlockVolume; +import org.spongepowered.api.world.gen.GeneratorPopulator; +import org.spongepowered.api.world.gen.Populator; +import org.spongepowered.api.world.gen.WorldGenerator; + +import com.flowpowered.math.vector.Vector3i; +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.object.Location; +import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotCluster; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotLoc; +import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.SetBlockQueue; +import com.intellectualcrafters.plot.util.TaskManager; +import com.plotsquared.sponge.SpongeMain; +import com.plotsquared.sponge.util.SpongeUtil; + +public class AugmentedPopulator implements Populator { + + public final PlotWorld plotworld; + public final PlotManager manager; + public final SpongePlotGenerator generator; + public final GeneratorPopulator populator; + public final PlotCluster cluster; + public final Random r = new Random(); + public final boolean p; + public final boolean b; + public final boolean o; + private final int bx; + private final int bz; + private final int tx; + private final int tz; + + public AugmentedPopulator(String worldname, WorldGenerator gen, final SpongePlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) { +// MainUtil.initCache(); + // Initialize any chach that's needed + this.cluster = cluster; + this.generator = generator; + this.populator = generator.getBaseGeneratorPopulator(); + this.plotworld = generator.getNewPlotWorld(worldname); + this.manager = generator.getPlotManager(); + this.p = p; + this.b = b; + this.o = (this.plotworld.TERRAIN == 1) || (this.plotworld.TERRAIN == 2); + if (cluster != null) { + final Location bl = this.manager.getPlotBottomLocAbs(this.plotworld, cluster.getP1()); + final Location tl = this.manager.getPlotTopLocAbs(this.plotworld, cluster.getP2()).add(1, 0, 1); + this.bx = bl.getX(); + this.bz = bl.getZ(); + this.tx = tl.getX(); + this.tz = tl.getZ(); + } else { + this.bx = Integer.MIN_VALUE; + this.bz = Integer.MIN_VALUE; + this.tx = Integer.MAX_VALUE; + this.tz = Integer.MAX_VALUE; + } + // Add the populator + List populators = gen.getPopulators(); + if (this.o) { + populators.add(0, this); + } else { + populators.add(this); + } + } + + public static void removePopulator(final String worldname, final PlotCluster cluster) { + final World world = SpongeUtil.getWorld(worldname); + List populators = world.getWorldGenerator().getPopulators(); + for (final Iterator iterator = populators.iterator(); iterator.hasNext();) { + final Populator populator = iterator.next(); + if (populator instanceof AugmentedPopulator) { + if (((AugmentedPopulator) populator).cluster.equals(cluster)) { + iterator.remove(); + } + } + } + } + + @Override + public void populate(final Chunk chunk, Random r_unused) { + Vector3i min = chunk.getBlockMin(); + final World worldObj = chunk.getWorld(); + final String world = worldObj.getName(); + final int cx = min.getX() >> 4; + final int cz = min.getZ() >> 4; + final int bx = cx << 4; + final int bz = cz << 4; + final int tx = bx + 15; + final int tz = bz + 15; + final boolean inX1 = ((bx >= this.bx) && (bx <= this.tx)); + final boolean inX2 = ((tx >= this.bx) && (tx <= this.tx)); + final boolean inZ1 = ((bz >= this.bz) && (bz <= this.tz)); + final boolean inZ2 = ((tz >= this.bz) && (tz <= this.tz)); + final boolean inX = inX1 || inX2; + final boolean inZ = inZ1 || inZ2; + if (!inX || !inZ) { + return; + } + if (this.plotworld.TERRAIN == 3) { + int X = min.getX(); + int Z = min.getZ(); + if (ChunkManager.FORCE_PASTE) { + for (short x = 0; x < 16; x++) { + for (short z = 0; z < 16; z++) { + final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z)); + final HashMap blocks = ChunkManager.GENERATE_BLOCKS.get(loc); + HashMap datas = ChunkManager.GENERATE_DATA.get(loc); + for (final Entry entry : blocks.entrySet()) { + int y = entry.getKey(); + if (datas != null) { + SetBlockQueue.setBlock(world, x, y, z, new PlotBlock(blocks.get(y), datas.get(y))); + } + else { + SetBlockQueue.setBlock(world, x, y, z, blocks.get(y)); + } + } + } + } + return; + } + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + PlotLoc loc; + for (Entry> entry : ChunkManager.GENERATE_DATA.entrySet()) { + HashMap datas = ChunkManager.GENERATE_DATA.get(entry.getKey()); + for (Entry entry2 : entry.getValue().entrySet()) { + Short y = entry2.getKey(); + byte data; + if (datas != null) { + data = datas.get(y); + } + else { + data = 0; + } + loc = entry.getKey(); + int xx = loc.x - X; + int zz = loc.z - Z; + if (xx >= 0 && xx < 16) { + if (zz >= 0 && zz < 16) { + SetBlockQueue.setBlock(world, xx, y, zz, new PlotBlock(entry2.getValue(), data)); + } + } + } + } + } + return; + } + final boolean check; + check = !inX1 || !inX2 || !inZ1 || !inZ2; + if (this.plotworld.TERRAIN > 1) { + final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, bx, 0, bz); + final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, tx, 0, tz); + if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) { + return; + } + } + if (this.o) { + populateBlocks(worldObj, chunk, cx, cz, bx, bz, check); + } else { + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + // TODO populate biome + } + }, 20 + r.nextInt(10)); + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + populateBlocks(worldObj, chunk, cx, cz, bx, bz, check); + } + }, 40 + r.nextInt(40)); + } + } + + private void populateBlocks(final World world, final Chunk chunk, final int X, final int Z, final int x, final int z, final boolean check) { + final String worldname = world.getName(); + MutableBlockVolume blocks = new MutableBlockVolume() { + @Override + public void setBlock(int x, int y, int z, BlockState t) { + if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) { + return; + } + if (p) { + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) { + return; + } + } else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) { + return; + } + } + PlotBlock block = SpongeMain.THIS.getPlotBlock(t); + if (block != null) { + SetBlockQueue.setBlock(worldname, x, y, z, block); + } + } + + @Override + public void setBlock(Vector3i v, BlockState t) { + setBlock(v.getX(), v.getY(), v.getZ(), t); + } + + @Override + public BlockType getBlockType(int x, int y, int z) { + return world.getBlockType(x, y, z); + } + + @Override + public BlockType getBlockType(Vector3i v) { + return getBlockType(v.getX(), v.getY(), v.getZ()); + } + + @Override + public Vector3i getBlockSize() { + return chunk.getBlockSize(); + } + + @Override + public Vector3i getBlockMin() { + return chunk.getBlockMin(); + } + + @Override + public Vector3i getBlockMax() { + return chunk.getBlockMax(); + } + + @Override + public BlockState getBlock(int x, int y, int z) { + return world.getBlock(x, y, z); + } + + @Override + public BlockState getBlock(Vector3i v) { + return getBlock(v.getX(), v.getY(), v.getZ()); + } + + @Override + public boolean containsBlock(int x, int y, int z) { + return ((x) >= bz) && ((z) <= tz) && ((x) >= bx) && ((z) <= tx); + } + + @Override + public boolean containsBlock(Vector3i v) { + return containsBlock(v.getX(), v.getY(), v.getZ()); + } + + @Override + public void setBlockType(int x, int y, int z, BlockType t) { + if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) { + return; + } + if (p) { + if (ChunkManager.CURRENT_PLOT_CLEAR != null) { + if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) { + return; + } + } else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) { + return; + } + } + PlotBlock block = SpongeMain.THIS.getPlotBlock(t.getDefaultState()); + if (block != null) { + SetBlockQueue.setBlock(worldname, x, y, z, block); + } + } + + @Override + public void setBlockType(Vector3i v, BlockType t) { + setBlockType(v.getX(), v.getY(), v.getZ(), t); + } + }; + this.populator.populate(world, blocks , null); + } + +} diff --git a/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java b/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java index 97ada8997..dff2de73f 100644 --- a/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java +++ b/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java @@ -7,6 +7,7 @@ import org.spongepowered.api.block.BlockState; import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.world.gen.BiomeGenerator; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.HybridPlotManager; import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.object.PlotManager; @@ -15,11 +16,7 @@ import com.plotsquared.sponge.SpongeMain; public class SpongeBasicGen extends SpongePlotGenerator { - public final BlockState ROAD_BLOCK = BlockTypes.QUARTZ_BLOCK.getDefaultState(); // Quartz - public final BlockState MAIN_BLOCK = BlockTypes.STONE.getDefaultState(); // Stone - public final BlockState WALL_BLOCK = BlockTypes.BEDROCK.getDefaultState(); // Bedrock - public final BlockState BORDER_BLOCK = BlockTypes.STONE_SLAB.getDefaultState(); // Stone slab - public final BlockState[] FLOOR_BLOCK = new BlockState[] {BlockTypes.GRASS.getDefaultState(), BlockTypes.SPONGE.getDefaultState(), BlockTypes.PLANKS.getDefaultState() }; // Grass and sponge + public final BlockState AIR = BlockTypes.AIR.getDefaultState(); private static HybridPlotManager manager; public HybridPlotWorld plotworld; @@ -93,7 +90,10 @@ public class SpongeBasicGen extends SpongePlotGenerator { @Override public PlotWorld getNewPlotWorld(String world) { if (this.plotworld == null) { - this.plotworld = new HybridPlotWorld(world); + this.plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world); + if (this.plotworld == null) { + this.plotworld = new HybridPlotWorld(world); + } } return this.plotworld; } diff --git a/src/main/java/com/plotsquared/sponge/generator/SpongeGeneratorWrapper.java b/src/main/java/com/plotsquared/sponge/generator/SpongeGeneratorWrapper.java index 5f7e3d542..292cbc5f8 100644 --- a/src/main/java/com/plotsquared/sponge/generator/SpongeGeneratorWrapper.java +++ b/src/main/java/com/plotsquared/sponge/generator/SpongeGeneratorWrapper.java @@ -1,5 +1,6 @@ package com.plotsquared.sponge.generator; +import org.spongepowered.api.world.World; import org.spongepowered.api.world.gen.WorldGenerator; import com.intellectualcrafters.plot.PS; @@ -8,6 +9,7 @@ import com.intellectualcrafters.plot.object.PlotCluster; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.SetupObject; +import com.plotsquared.sponge.util.SpongeUtil; public class SpongeGeneratorWrapper extends PlotGenerator{ @@ -29,13 +31,14 @@ public class SpongeGeneratorWrapper extends PlotGenerator{ public void augment(PlotCluster cluster, PlotWorld plotworld) { if (generator instanceof SpongePlotGenerator) { SpongePlotGenerator plotgen = (SpongePlotGenerator) generator; - if (cluster != null) { - // TODO Augment partial - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); - } - else { - // TODO augment full - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); + World worldObj = SpongeUtil.getWorld(world); + if (worldObj != null) { + if (cluster != null) { + new AugmentedPopulator(world, worldObj.getWorldGenerator(), plotgen, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); + } + else { + new AugmentedPopulator(world, worldObj.getWorldGenerator(), plotgen, null, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); + } } } } diff --git a/src/main/java/com/plotsquared/sponge/generator/SpongePlotPopulator.java b/src/main/java/com/plotsquared/sponge/generator/SpongePlotPopulator.java index f9c57dd55..ae17e052f 100644 --- a/src/main/java/com/plotsquared/sponge/generator/SpongePlotPopulator.java +++ b/src/main/java/com/plotsquared/sponge/generator/SpongePlotPopulator.java @@ -55,7 +55,6 @@ public abstract class SpongePlotPopulator impleme populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz); } catch (Exception e) { - PS.debug("ERROR GENERATING CHUNK!"); e.printStackTrace(); } }; diff --git a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java index 1f9d9febb..c5e458a63 100644 --- a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java +++ b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java @@ -5,23 +5,38 @@ import org.spongepowered.api.world.WorldCreationSettings; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; +import com.intellectualcrafters.plot.object.PlotCluster; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.ClusterManager; + public class WorldModify implements WorldGeneratorModifier { private SpongePlotGenerator plotgen; + private boolean augment; - public WorldModify(SpongePlotGenerator plotgen) { + public WorldModify(SpongePlotGenerator plotgen, boolean augment) { this.plotgen = plotgen; + this.augment = augment; } @Override public void modifyWorldGenerator(WorldCreationSettings world, DataContainer settings, WorldGenerator gen) { - gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator()); - gen.setBiomeGenerator(plotgen.getBiomeGenerator()); -// if (gen instanceof SpongeWorldGenerator) { -// SpongePlotGenerator plotgen = (SpongePlotGenerator) gen; -// plotgen.setBaseGeneratorPopulator(plotgen.getGenerator()); -// plotgen.setBiomeGenerator(plotgen.getPlotBiomeProvider()); -// } + if (augment) { + String worldname = plotgen.world; + PlotWorld plotworld = plotgen.getNewPlotWorld(worldname); + if (plotworld.TYPE == 2) { + for (PlotCluster cluster : ClusterManager.getClusters(worldname)) { + new AugmentedPopulator(worldname, gen, plotgen, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); + } + } + else { + new AugmentedPopulator(worldname, gen, plotgen, null, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); + } + } + else { + gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator()); + gen.setBiomeGenerator(plotgen.getBiomeGenerator()); + } } @Override