mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 15:16:45 +01:00
Fixed world initialization for augmented plot worlds.
This commit is contained in:
parent
98a4a9889e
commit
ceb4ffa45e
@ -35,6 +35,8 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||
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.DefaultTitle;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
@ -99,7 +101,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
} else {
|
||||
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
|
||||
@ -295,12 +297,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
|
||||
@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);
|
||||
if ((gen_plugin != null) && gen_plugin.isEnabled()) {
|
||||
gen_plugin.getDefaultWorldGenerator(world, "");
|
||||
return gen_plugin.getDefaultWorldGenerator(world, "");
|
||||
} else {
|
||||
new HybridGen();
|
||||
return new HybridGen();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,8 @@ package com.intellectualcrafters.plot;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
@ -53,5 +55,5 @@ public interface IPlotMain {
|
||||
|
||||
public boolean initPlotMeConverter();
|
||||
|
||||
public void getGenerator(String world, String name);
|
||||
public ChunkGenerator getGenerator(String world, String name);
|
||||
}
|
||||
|
@ -218,7 +218,7 @@ public class PlotSquared {
|
||||
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);
|
||||
if (plotWorld != null) {
|
||||
if (generator != null) {
|
||||
@ -263,10 +263,11 @@ public class PlotSquared {
|
||||
try {
|
||||
final String gen_string = config.getString("worlds." + world + "." + "generator.plugin");
|
||||
if (gen_string == null) {
|
||||
new HybridGen();
|
||||
generator = new HybridGen();
|
||||
} else {
|
||||
IMP.getGenerator(world, gen_string);
|
||||
generator = (PlotGenerator) IMP.getGenerator(world, gen_string);
|
||||
}
|
||||
loadWorld(world, generator);
|
||||
} catch (final Exception e) {
|
||||
log("&d=== Oh no! Please set the generator for the " + world + " ===");
|
||||
e.printStackTrace();
|
||||
|
@ -208,6 +208,10 @@ public class HybridGen extends PlotGenerator {
|
||||
}
|
||||
else {
|
||||
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
|
||||
// populator, ore populator
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.listeners;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
@ -11,7 +12,7 @@ import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class WorldEvents {
|
||||
public class WorldEvents implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public static void onWorldInit(final WorldInitEvent event) {
|
||||
final World world = event.getWorld();
|
||||
@ -19,7 +20,7 @@ public class WorldEvents {
|
||||
if (gen instanceof PlotGenerator) {
|
||||
PlotSquared.loadWorld(world.getName(), (PlotGenerator) gen);
|
||||
} else {
|
||||
if (PlotSquared.isPlotWorld(world.getName())) {
|
||||
if (PlotSquared.config.contains("worlds." + world.getName())) {
|
||||
PlotSquared.loadWorld(world.getName(), null);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user