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>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.10.6</version>
<version>2.10.7</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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");

View File

@ -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();
}
}

View File

@ -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
*/

View File

@ -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 {

View File

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