use of org.bukkit.WorldCreator in project TotalFreedomMod by TotalFreedom.
the class AdminWorld method generateWorld.
@Override
protected World generateWorld() {
final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
final World world = Bukkit.getServer().createWorld(worldCreator);
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.SIGN_POST);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
signData.setFacingDirection(BlockFace.NORTH);
welcomeSign.setLine(0, ChatColor.GREEN + "AdminWorld");
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
welcomeSign.update();
plugin.gr.commitGameRules();
return world;
}
use of org.bukkit.WorldCreator in project TotalFreedomMod by TotalFreedom.
the class Flatlands method generateWorld.
@Override
protected World generateWorld() {
if (!ConfigEntry.FLATLANDS_GENERATE.getBoolean()) {
return null;
}
wipeFlatlandsIfFlagged();
final WorldCreator worldCreator = new WorldCreator(getName());
worldCreator.generateStructures(false);
worldCreator.type(WorldType.NORMAL);
worldCreator.environment(World.Environment.NORMAL);
worldCreator.generator(new CleanroomChunkGenerator(GENERATION_PARAMETERS));
final World world = Bukkit.getServer().createWorld(worldCreator);
world.setSpawnFlags(false, false);
world.setSpawnLocation(0, 50, 0);
final Block welcomeSignBlock = world.getBlockAt(0, 50, 0);
welcomeSignBlock.setType(Material.SIGN_POST);
org.bukkit.block.Sign welcomeSign = (org.bukkit.block.Sign) welcomeSignBlock.getState();
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) welcomeSign.getData();
signData.setFacingDirection(BlockFace.NORTH);
welcomeSign.setLine(0, ChatColor.GREEN + "Flatlands");
welcomeSign.setLine(1, ChatColor.DARK_GRAY + "---");
welcomeSign.setLine(2, ChatColor.YELLOW + "Spawn Point");
welcomeSign.setLine(3, ChatColor.DARK_GRAY + "---");
welcomeSign.update();
plugin.gr.commitGameRules();
return world;
}
use of org.bukkit.WorldCreator in project Denizen-For-Bukkit by DenizenScript.
the class CreateWorldCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
Element worldName = scriptEntry.getElement("world_name");
Element generator = scriptEntry.getElement("generator");
Element worldType = scriptEntry.getElement("worldtype");
Element environment = scriptEntry.getElement("environment");
Element copy_from = scriptEntry.getElement("copy_from");
Element seed = scriptEntry.getElement("seed");
dB.report(scriptEntry, getName(), worldName.debug() + (generator != null ? generator.debug() : "") + environment.debug() + (copy_from != null ? copy_from.debug() : "") + worldType.debug() + (seed != null ? seed.debug() : ""));
if (copy_from != null) {
try {
if (copy_from.asString().contains("..")) {
dB.echoError(scriptEntry.getResidingQueue(), "Invalid copy from world name!");
return;
}
File newFolder = new File(worldName.asString());
File folder = new File(copy_from.asString().replace("w@", ""));
if (!folder.exists() || !folder.isDirectory()) {
dB.echoError(scriptEntry.getResidingQueue(), "Invalid copy from world folder - does not exist!");
return;
}
FileUtils.copyDirectory(folder, newFolder);
File file = new File(worldName.asString() + "/uid.dat");
if (file.exists()) {
file.delete();
}
File file2 = new File(worldName.asString() + "/session.lock");
if (file2.exists()) {
file2.delete();
}
} catch (Exception ex) {
dB.echoError(ex);
return;
}
}
World world;
WorldCreator worldCreator = WorldCreator.name(worldName.asString()).environment(World.Environment.valueOf(environment.asString().toUpperCase())).type(WorldType.valueOf(worldType.asString().toUpperCase()));
if (generator != null) {
worldCreator.generator(generator.asString());
}
if (seed != null) {
worldCreator.seed(seed.asLong());
}
world = Bukkit.getServer().createWorld(worldCreator);
if (world == null) {
dB.echoDebug(scriptEntry, "World is null, something went wrong in creation!");
}
}
Aggregations