External generators

Fixed an issue with external generators not working correctly (caused by
another "fix").
The following will need to be updated:
- AdvPlots
- IslandPlots
This commit is contained in:
boy0001 2015-05-09 16:24:03 +10:00
parent 7d25cccf4a
commit dcf1475d92
8 changed files with 18 additions and 7 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.10.6</version> <version>2.10.7</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -328,7 +328,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if (!PlotSquared.setupPlotWorld(world, id)) { if (!PlotSquared.setupPlotWorld(world, id)) {
return null; return null;
} }
HybridGen result = new HybridGen(); HybridGen result = new HybridGen(world);
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -440,7 +440,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
if ((gen_plugin != null) && gen_plugin.isEnabled()) { if ((gen_plugin != null) && gen_plugin.isEnabled()) {
return gen_plugin.getDefaultWorldGenerator(world, ""); return gen_plugin.getDefaultWorldGenerator(world, "");
} else { } else {
return new HybridGen(); return new HybridGen(world);
} }
} }

View File

@ -350,7 +350,7 @@ public class PlotSquared {
try { try {
final String gen_string = config.getString("worlds." + world + "." + "generator.plugin"); final String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
if (gen_string == null) { if (gen_string == null) {
generator = new HybridGen(); generator = new HybridGen(world);
} else { } else {
generator = (PlotGenerator) IMP.getGenerator(world, gen_string); generator = (PlotGenerator) IMP.getGenerator(world, gen_string);
} }

View File

@ -30,6 +30,7 @@ import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
@ -87,7 +88,8 @@ public class Template extends SubCommand {
PlotSquared.config.set("worlds." + world, worldConfig.get("")); PlotSquared.config.set("worlds." + world, worldConfig.get(""));
try { try {
PlotSquared.config.save(PlotSquared.configFile); PlotSquared.config.save(PlotSquared.configFile);
} catch (IOException e) { PlotSquared.config.load(PlotSquared.configFile);
} catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
String manager = worldConfig.getString("generator.plugin"); String manager = worldConfig.getString("generator.plugin");

View File

@ -266,7 +266,7 @@ public class PlotMeConverter {
// Load using Bukkit API // Load using Bukkit API
// - User must set generator manually // - User must set generator manually
Bukkit.getServer().unloadWorld(world, true); 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(); myworld.save();
} }
} }

View File

@ -46,6 +46,11 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
* @author Empire92 * @author Empire92
*/ */
public class HybridGen extends PlotGenerator { 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 * Set to static to re-use the same managet for all Default World Generators
*/ */

View File

@ -17,7 +17,7 @@ public class WorldEvents implements Listener {
public static String lastWorld = null; public static String lastWorld = null;
public static String getName(World world) { public static String getName(World world) {
if (lastWorld != null) { if (lastWorld != null && !lastWorld.equals("CheckingPlotSquaredGenerator")) {
return lastWorld; return lastWorld;
} }
else { else {

View File

@ -42,6 +42,10 @@ public abstract class PlotGenerator extends ChunkGenerator {
public int Z; public int Z;
private PseudoRandom random = new PseudoRandom(); private PseudoRandom random = new PseudoRandom();
public PlotGenerator(String world) {
WorldEvents.lastWorld = world;
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public List<BlockPopulator> getDefaultPopulators(World world) { public List<BlockPopulator> getDefaultPopulators(World world) {