Fixed world initialization for augmented plot worlds.

This commit is contained in:
boy0001 2015-02-26 20:27:49 +11:00
parent 98a4a9889e
commit ceb4ffa45e
5 changed files with 20 additions and 10 deletions

View File

@ -35,6 +35,8 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents;
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.PlotPlusListener;
import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.listeners.WorldEditListener;
import com.intellectualcrafters.plot.listeners.WorldEvents;
import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.AbstractTitle;
import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.titles.DefaultTitle;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
@ -99,7 +101,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} else { } else {
log("&dUsing metrics will allow us to improve the plugin, please consider it :)"); log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
} }
getServer().getPluginManager().registerEvents(this, this); getServer().getPluginManager().registerEvents(new WorldEvents(), this);
} }
@Override @Override
@ -295,12 +297,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} }
@Override @Override
public void getGenerator(final String world, final String name) { public ChunkGenerator getGenerator(final String world, final String name) {
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name); final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
if ((gen_plugin != null) && gen_plugin.isEnabled()) { if ((gen_plugin != null) && gen_plugin.isEnabled()) {
gen_plugin.getDefaultWorldGenerator(world, ""); return gen_plugin.getDefaultWorldGenerator(world, "");
} else { } else {
new HybridGen(); return new HybridGen();
} }
} }

View File

@ -2,6 +2,8 @@ package com.intellectualcrafters.plot;
import java.io.File; import java.io.File;
import org.bukkit.generator.ChunkGenerator;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
@ -53,5 +55,5 @@ public interface IPlotMain {
public boolean initPlotMeConverter(); public boolean initPlotMeConverter();
public void getGenerator(String world, String name); public ChunkGenerator getGenerator(String world, String name);
} }

View File

@ -218,7 +218,7 @@ public class PlotSquared {
return true; return true;
} }
public static void loadWorld(final String world, final PlotGenerator generator) { public static void loadWorld(final String world, PlotGenerator generator) {
PlotWorld plotWorld = getPlotWorld(world); PlotWorld plotWorld = getPlotWorld(world);
if (plotWorld != null) { if (plotWorld != null) {
if (generator != null) { if (generator != null) {
@ -263,10 +263,11 @@ 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) {
new HybridGen(); generator = new HybridGen();
} else { } else {
IMP.getGenerator(world, gen_string); generator = (PlotGenerator) IMP.getGenerator(world, gen_string);
} }
loadWorld(world, generator);
} catch (final Exception e) { } catch (final Exception e) {
log("&d=== Oh no! Please set the generator for the " + world + " ==="); log("&d=== Oh no! Please set the generator for the " + world + " ===");
e.printStackTrace(); e.printStackTrace();

View File

@ -208,6 +208,10 @@ public class HybridGen extends PlotGenerator {
} }
else { else {
world.setSpawnFlags(true, true); world.setSpawnFlags(true, true);
world.setAmbientSpawnLimit(-1);
world.setAnimalSpawnLimit(-1);
world.setMonsterSpawnLimit(-1);
world.setWaterAnimalSpawnLimit(-1);
} }
// You can have as many populators as you would like, e.g. tree // You can have as many populators as you would like, e.g. tree
// populator, ore populator // populator, ore populator

View File

@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.listeners;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldInitEvent; import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@ -11,7 +12,7 @@ import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotGenerator;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
public class WorldEvents { public class WorldEvents implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public static void onWorldInit(final WorldInitEvent event) { public static void onWorldInit(final WorldInitEvent event) {
final World world = event.getWorld(); final World world = event.getWorld();
@ -19,7 +20,7 @@ public class WorldEvents {
if (gen instanceof PlotGenerator) { if (gen instanceof PlotGenerator) {
PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen); PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen);
} else { } else {
if (PlotSquared.isPlotWorld(world.getName())) { if (PlotSquared.config.contains("worlds." + world.getName())) {
PlotSquared.loadWorld(world.getName(), null); PlotSquared.loadWorld(world.getName(), null);
} }
} }