Search in sources :

Example 1 with WorldCreator

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;
}
Also used : WorldCreator(org.bukkit.WorldCreator) Block(org.bukkit.block.Block) World(org.bukkit.World)

Example 2 with WorldCreator

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;
}
Also used : WorldCreator(org.bukkit.WorldCreator) Block(org.bukkit.block.Block) World(org.bukkit.World)

Example 3 with WorldCreator

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!");
    }
}
Also used : WorldCreator(org.bukkit.WorldCreator) Element(net.aufdemrand.denizencore.objects.Element) World(org.bukkit.World) File(java.io.File) InvalidArgumentsException(net.aufdemrand.denizencore.exceptions.InvalidArgumentsException) CommandExecutionException(net.aufdemrand.denizencore.exceptions.CommandExecutionException)

Aggregations

World (org.bukkit.World)3 WorldCreator (org.bukkit.WorldCreator)3 Block (org.bukkit.block.Block)2 File (java.io.File)1 CommandExecutionException (net.aufdemrand.denizencore.exceptions.CommandExecutionException)1 InvalidArgumentsException (net.aufdemrand.denizencore.exceptions.InvalidArgumentsException)1 Element (net.aufdemrand.denizencore.objects.Element)1