Search in sources :

Example 1 with DeprecatedVoidGenerator

use of com.eintosti.buildsystem.object.world.generator.DeprecatedVoidGenerator in project BuildSystem by einTosti.

the class WorldManager method generateBukkitWorld.

/**
 * Generate the {@link World} linked to a {@link BuildWorld}.
 *
 * @param worldName       The name of the world
 * @param worldType       The world type
 * @param chunkGenerators Custom chunk generator to be used, if any
 * @return The world object
 */
public World generateBukkitWorld(String worldName, WorldType worldType, ChunkGenerator... chunkGenerators) {
    WorldCreator worldCreator = new WorldCreator(worldName);
    org.bukkit.WorldType bukkitWorldType;
    switch(worldType) {
        case VOID:
            worldCreator.generateStructures(false);
            bukkitWorldType = org.bukkit.WorldType.FLAT;
            if (XMaterial.supports(17)) {
                worldCreator.generator(new ModernVoidGenerator());
            } else if (XMaterial.supports(13)) {
                worldCreator.generator(new DeprecatedVoidGenerator());
            } else {
                worldCreator.generatorSettings("2;0;1");
            }
            break;
        case FLAT:
        case PRIVATE:
            worldCreator.generateStructures(false);
            bukkitWorldType = org.bukkit.WorldType.FLAT;
            break;
        case NETHER:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.NETHER);
            break;
        case END:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.THE_END);
            break;
        case CUSTOM:
            if (chunkGenerators != null && chunkGenerators.length > 0) {
                worldCreator.generator(chunkGenerators[0]);
            }
        default:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.NORMAL);
            break;
    }
    worldCreator.type(bukkitWorldType);
    World bukkitWorld = Bukkit.createWorld(worldCreator);
    if (bukkitWorld != null) {
        bukkitWorld.setDifficulty(configValues.getWorldDifficulty());
        bukkitWorld.setTime(configValues.getNoonTime());
        bukkitWorld.getWorldBorder().setSize(configValues.getWorldBorderSize());
        bukkitWorld.setKeepSpawnInMemory(configValues.isTeleportAfterCreation());
        configValues.getDefaultGameRules().forEach(bukkitWorld::setGameRuleValue);
    }
    return bukkitWorld;
}
Also used : DeprecatedVoidGenerator(com.eintosti.buildsystem.object.world.generator.DeprecatedVoidGenerator) WorldCreator(org.bukkit.WorldCreator) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) ModernVoidGenerator(com.eintosti.buildsystem.object.world.generator.ModernVoidGenerator)

Example 2 with DeprecatedVoidGenerator

use of com.eintosti.buildsystem.object.world.generator.DeprecatedVoidGenerator in project BuildSystem by Trichtern.

the class WorldManager method generateBukkitWorld.

/**
 * Generate the {@link World} linked to a {@link BuildWorld}.
 *
 * @param worldName       The name of the world
 * @param worldType       The world type
 * @param difficulty      The world's difficulty
 * @param chunkGenerators Custom chunk generator to be used, if any
 * @return The world object
 */
public World generateBukkitWorld(String worldName, WorldType worldType, Difficulty difficulty, ChunkGenerator... chunkGenerators) {
    WorldCreator worldCreator = new WorldCreator(worldName);
    org.bukkit.WorldType bukkitWorldType;
    switch(worldType) {
        case VOID:
            worldCreator.generateStructures(false);
            bukkitWorldType = org.bukkit.WorldType.FLAT;
            if (XMaterial.supports(17)) {
                worldCreator.generator(new ModernVoidGenerator());
            } else if (XMaterial.supports(13)) {
                worldCreator.generator(new DeprecatedVoidGenerator());
            } else {
                worldCreator.generatorSettings("2;0;1");
            }
            break;
        case FLAT:
        case PRIVATE:
            worldCreator.generateStructures(false);
            bukkitWorldType = org.bukkit.WorldType.FLAT;
            break;
        case NETHER:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.NETHER);
            break;
        case END:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.THE_END);
            break;
        case CUSTOM:
            if (chunkGenerators != null && chunkGenerators.length > 0) {
                worldCreator.generator(chunkGenerators[0]);
            }
        default:
            worldCreator.generateStructures(true);
            bukkitWorldType = org.bukkit.WorldType.NORMAL;
            worldCreator.environment(Environment.NORMAL);
            break;
    }
    worldCreator.type(bukkitWorldType);
    World bukkitWorld = Bukkit.createWorld(worldCreator);
    if (bukkitWorld != null) {
        bukkitWorld.setDifficulty(difficulty);
        bukkitWorld.setTime(configValues.getNoonTime());
        bukkitWorld.getWorldBorder().setSize(configValues.getWorldBorderSize());
        bukkitWorld.setKeepSpawnInMemory(configValues.isTeleportAfterCreation());
        configValues.getDefaultGameRules().forEach(bukkitWorld::setGameRuleValue);
    }
    return bukkitWorld;
}
Also used : DeprecatedVoidGenerator(com.eintosti.buildsystem.object.world.generator.DeprecatedVoidGenerator) WorldCreator(org.bukkit.WorldCreator) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) ModernVoidGenerator(com.eintosti.buildsystem.object.world.generator.ModernVoidGenerator)

Aggregations

BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)2 DeprecatedVoidGenerator (com.eintosti.buildsystem.object.world.generator.DeprecatedVoidGenerator)2 ModernVoidGenerator (com.eintosti.buildsystem.object.world.generator.ModernVoidGenerator)2 World (org.bukkit.World)2 WorldCreator (org.bukkit.WorldCreator)2