mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 03:43:28 +01:00
You may now set a generator to a default world using plugin.yml
This commit is contained in:
parent
d647e2098e
commit
7f0126a364
@ -24,7 +24,9 @@ import org.bukkit.craftbukkit.LoggerOutputStream;
|
|||||||
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
import org.bukkit.craftbukkit.command.ColouredConsoleSender;
|
||||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||||
import org.bukkit.craftbukkit.util.ServerShutdownThread;
|
import org.bukkit.craftbukkit.util.ServerShutdownThread;
|
||||||
|
import org.bukkit.event.world.WorldInitEvent;
|
||||||
import org.bukkit.event.world.WorldSaveEvent;
|
import org.bukkit.event.world.WorldSaveEvent;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.PluginLoadOrder;
|
import org.bukkit.plugin.PluginLoadOrder;
|
||||||
// CraftBukkit
|
// 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) {
|
for (int j = 0; j < (this.propertyManager.getBoolean("allow-nether", true) ? 2 : 1); ++j) {
|
||||||
WorldServer world;
|
WorldServer world;
|
||||||
int dimension = j == 0 ? 0 : -1;
|
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) {
|
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 {
|
} else {
|
||||||
String worldType = Environment.getEnvironment(dimension).toString().toLowerCase();
|
|
||||||
String name = s + "_" + worldType;
|
|
||||||
String dim = "DIM-1";
|
String dim = "DIM-1";
|
||||||
|
|
||||||
File newWorld = new File(new File(name), dim);
|
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.tracker = new EntityTracker(this, dimension);
|
||||||
world.addIWorldAccess(new WorldManager(this, world));
|
world.addIWorldAccess(new WorldManager(this, world));
|
||||||
world.spawnMonsters = this.propertyManager.getBoolean("spawn-monsters", true) ? 1 : 0;
|
world.spawnMonsters = this.propertyManager.getBoolean("spawn-monsters", true) ? 1 : 0;
|
||||||
|
@ -576,4 +576,33 @@ public final class CraftServer implements Server {
|
|||||||
public boolean getOnlineMode() {
|
public boolean getOnlineMode() {
|
||||||
return this.console.onlineMode;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user