summaryrefslogtreecommitdiffstats
path: root/src/main/java
diff options
context:
space:
mode:
authorDinnerbone <dinnerbone@dinnerbone.com>2011-06-22 18:27:27 +0100
committerDinnerbone <dinnerbone@dinnerbone.com>2011-06-22 18:27:52 +0100
commit7f0126a364ee8a1419424dc09ca0cfc488236373 (patch)
tree3df73d05cd26037ac6c6d243c71120551638a84f /src/main/java
parentd647e2098eb48c51fff9d200be1d71b94b2ade6b (diff)
downloadcraftbukkit-7f0126a364ee8a1419424dc09ca0cfc488236373.tar
craftbukkit-7f0126a364ee8a1419424dc09ca0cfc488236373.tar.gz
craftbukkit-7f0126a364ee8a1419424dc09ca0cfc488236373.tar.lz
craftbukkit-7f0126a364ee8a1419424dc09ca0cfc488236373.tar.xz
craftbukkit-7f0126a364ee8a1419424dc09ca0cfc488236373.zip
You may now set a generator to a default world using plugin.yml
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/net/minecraft/server/MinecraftServer.java18
-rw-r--r--src/main/java/org/bukkit/craftbukkit/CraftServer.java29
2 files changed, 43 insertions, 4 deletions
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 81e36680..00cd628c 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -24,7 +24,9 @@ import org.bukkit.craftbukkit.LoggerOutputStream;
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
import org.bukkit.craftbukkit.util.ServerShutdownThread;
+import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.event.world.WorldSaveEvent;
+import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.PluginLoadOrder;
// CraftBukkit
@@ -168,12 +170,14 @@ public class MinecraftServer implements Runnable, ICommandListener {
for (int j = 0; j < (this.propertyManager.getBoolean("allow-nether", true) ? 2 : 1); ++j) {
WorldServer world;
int dimension = j == 0 ? 0 : -1;
+ String worldType = Environment.getEnvironment(dimension).toString().toLowerCase();
+ String name = (dimension == 0) ? s : s + "_" + worldType;
+
+ ChunkGenerator gen = server.getGenerator(name);
if (j == 0) {
- world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, i, org.bukkit.World.Environment.getEnvironment(dimension), null); // CraftBukkit
+ world = new WorldServer(this, new ServerNBTManager(new File("."), s, true), s, dimension, i, org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit
} else {
- String worldType = Environment.getEnvironment(dimension).toString().toLowerCase();
- String name = s + "_" + worldType;
String dim = "DIM-1";
File newWorld = new File(new File(name), dim);
@@ -202,9 +206,15 @@ public class MinecraftServer implements Runnable, ICommandListener {
}
}
- world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, i, worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), null); // CraftBukkit
+ world = new SecondaryWorldServer(this, new ServerNBTManager(new File("."), name, true), name, dimension, i, worlds.get(0), org.bukkit.World.Environment.getEnvironment(dimension), gen); // CraftBukkit
+ }
+
+ if (gen != null) {
+ world.getWorld().getPopulators().addAll(gen.getDefaultPopulators(world.getWorld()));
}
+ server.getPluginManager().callEvent(new WorldInitEvent(world.getWorld()));
+
world.tracker = new EntityTracker(this, dimension);
world.addIWorldAccess(new WorldManager(this, world));
world.spawnMonsters = this.propertyManager.getBoolean("spawn-monsters", true) ? 1 : 0;
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index a7cc8e4c..86f7cf55 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -576,4 +576,33 @@ public final class CraftServer implements Server {
public boolean getOnlineMode() {
return this.console.onlineMode;
}
+
+ public ChunkGenerator getGenerator(String world) {
+ ConfigurationNode node = configuration.getNode("worlds");
+ ChunkGenerator result = null;
+
+ if (node != null) {
+ node = node.getNode(world);
+
+ if (node != null) {
+ String name = node.getString("generator");
+
+ if ((name != null) && (!name.isEmpty())) {
+ String[] split = name.split(":", 2);
+ String id = (split.length > 1) ? split[1] : null;
+ Plugin plugin = pluginManager.getPlugin(split[0]);
+
+ if (plugin == null) {
+ getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' does not exist");
+ } else if (!plugin.isEnabled()) {
+ getLogger().severe("Could not set generator for default world '" + world + "': Plugin '" + split[0] + "' is not enabled yet (is it load:STARTUP?)");
+ } else {
+ result = plugin.getDefaultWorldGenerator(world, id);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
}