下面列出了org.bukkit.WorldCreator#type ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private static World createArenaWorld(ConfigArena arena, String name) {
World world;
world = Bukkit.getServer().getWorld(name);
if (world == null) {
WorldCreator wc = new WorldCreator(name);
wc.environment(Environment.NORMAL);
wc.type(WorldType.FLAT);
wc.generateStructures(false);
world = Bukkit.getServer().createWorld(wc);
world.setAutoSave(false);
world.setSpawnFlags(false, false);
world.setKeepSpawnInMemory(false);
ChunkCoord.addWorld(world);
}
return world;
}
/**
* Generate a new DResourceWorld.
*
* @return the automatically created DEditWorld instance
*/
public DEditWorld generate() {
int id = DInstanceWorld.counter;
String name = DInstanceWorld.generateName(false, id);
File folder = new File(Bukkit.getWorldContainer(), name);
WorldCreator creator = new WorldCreator(name);
creator.type(WorldType.FLAT);
creator.generateStructures(false);
DEditWorld editWorld = new DEditWorld(plugin, this, folder);
this.editWorld = editWorld;
EditWorldGenerateEvent event = new EditWorldGenerateEvent(editWorld);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return null;
}
if (!RAW.exists()) {
createRaw();
}
FileUtil.copyDir(RAW, folder, DungeonsXL.EXCLUDED_FILES);
editWorld.generateIdFile();
editWorld.world = creator.createWorld().getName();
editWorld.generateIdFile();
return editWorld;
}
/**
* Creates the "raw" world that is copied for new instances.
*/
public static void createRaw() {
WorldCreator rawCreator = WorldCreator.name(".raw");
rawCreator.type(WorldType.FLAT);
rawCreator.generateStructures(false);
World world = rawCreator.createWorld();
File worldFolder = new File(Bukkit.getWorldContainer(), ".raw");
FileUtil.copyDir(worldFolder, RAW, DungeonsXL.EXCLUDED_FILES);
Bukkit.unloadWorld(world, /* SPIGOT-5225 */ !Version.isAtLeast(Version.MC1_14_4));
FileUtil.removeDir(worldFolder);
}
public void create_cmd() throws CivException {
String name = getNamedString(1, "enter a world name");
WorldCreator wc = new WorldCreator(name);
wc.environment(Environment.NORMAL);
wc.type(WorldType.FLAT);
wc.generateStructures(false);
World world = Bukkit.getServer().createWorld(wc);
world.setSpawnFlags(false, false);
ChunkCoord.addWorld(world);
CivMessage.sendSuccess(sender, "World "+name+" created.");
}