Search in sources :

Example 1 with WorldType

use of com.eintosti.buildsystem.object.world.data.WorldType in project BuildSystem by einTosti.

the class WorldManager method loadWorld.

public BuildWorld loadWorld(String worldName) {
    FileConfiguration configuration = worldConfig.getFile();
    if (configuration == null) {
        return null;
    }
    String creator = configuration.isString("worlds." + worldName + ".creator") ? configuration.getString("worlds." + worldName + ".creator") : "-";
    UUID creatorId = parseCreatorId(configuration, worldName, creator);
    WorldType worldType = configuration.isString("worlds." + worldName + ".type") ? WorldType.valueOf(configuration.getString("worlds." + worldName + ".type")) : WorldType.UNKNOWN;
    boolean privateWorld = configuration.isBoolean("worlds." + worldName + ".private") && configuration.getBoolean("worlds." + worldName + ".private");
    XMaterial material = parseMaterial(configuration, worldName);
    WorldStatus worldStatus = WorldStatus.valueOf(configuration.getString("worlds." + worldName + ".status"));
    String project = configuration.getString("worlds." + worldName + ".project");
    String permission = configuration.getString("worlds." + worldName + ".permission");
    long date = configuration.isLong("worlds." + worldName + ".date") ? configuration.getLong("worlds." + worldName + ".date") : -1;
    boolean physics = configuration.getBoolean("worlds." + worldName + ".physics");
    boolean explosions = !configuration.isBoolean("worlds." + worldName + ".explosions") || configuration.getBoolean("worlds." + worldName + ".explosions");
    boolean mobAI = !configuration.isBoolean("worlds." + worldName + ".mobai") || configuration.getBoolean("worlds." + worldName + ".mobai");
    String customSpawn = configuration.getString("worlds." + worldName + ".spawn");
    boolean blockBreaking = !configuration.isBoolean("worlds." + worldName + ".block-breaking") || configuration.getBoolean("worlds." + worldName + ".block-breaking");
    boolean blockPlacement = !configuration.isBoolean("worlds." + worldName + ".block-placement") || configuration.getBoolean("worlds." + worldName + ".block-placement");
    boolean blockInteractions = !configuration.isBoolean("worlds." + worldName + ".block-interactions") || configuration.getBoolean("worlds." + worldName + ".block-interactions");
    boolean buildersEnabled = configuration.isBoolean("worlds." + worldName + ".builders-enabled") && configuration.getBoolean("worlds." + worldName + ".builders-enabled");
    List<Builder> builders = parseBuilders(configuration, worldName);
    String chunkGeneratorString = configuration.getString("worlds." + worldName + ".chunk-generator");
    ChunkGenerator chunkGenerator = parseChunkGenerator(configuration, worldName);
    if (worldType == WorldType.PRIVATE) {
        privateWorld = true;
        worldType = WorldType.FLAT;
    }
    BuildWorld buildWorld = new BuildWorld(plugin, worldName, creator, creatorId, worldType, privateWorld, material, worldStatus, project, permission, date, physics, explosions, mobAI, customSpawn, blockBreaking, blockPlacement, blockInteractions, buildersEnabled, builders, chunkGenerator, chunkGeneratorString);
    buildWorlds.add(buildWorld);
    return buildWorld;
}
Also used : FileConfiguration(org.bukkit.configuration.file.FileConfiguration) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) WorldType(com.eintosti.buildsystem.object.world.data.WorldType) Builder(com.eintosti.buildsystem.object.world.Builder) UUID(java.util.UUID) XMaterial(com.cryptomorin.xseries.XMaterial) ChunkGenerator(org.bukkit.generator.ChunkGenerator) WorldStatus(com.eintosti.buildsystem.object.world.data.WorldStatus)

Example 2 with WorldType

use of com.eintosti.buildsystem.object.world.data.WorldType in project BuildSystem by einTosti.

the class CreateInventory method onInventoryClick.

@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
    if (!inventoryManager.checkIfValidClick(event, "create_title")) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    CreateInventory.Page newPage = null;
    switch(event.getSlot()) {
        case 12:
            newPage = CreateInventory.Page.PREDEFINED;
            break;
        case 13:
            newPage = CreateInventory.Page.GENERATOR;
            break;
        case 14:
            newPage = CreateInventory.Page.TEMPLATES;
            break;
    }
    if (newPage != null) {
        openInventory(player, newPage, this.createPrivateWorld);
        XSound.ENTITY_CHICKEN_EGG.play(player);
        return;
    }
    Inventory inventory = event.getClickedInventory();
    if (inventory == null) {
        return;
    }
    int slot = event.getSlot();
    switch(Page.getCurrentPage(inventory)) {
        case PREDEFINED:
            {
                WorldType worldType = null;
                switch(slot) {
                    case 29:
                        worldType = WorldType.NORMAL;
                        break;
                    case 30:
                        worldType = WorldType.FLAT;
                        break;
                    case 31:
                        worldType = WorldType.NETHER;
                        break;
                    case 32:
                        worldType = WorldType.END;
                        break;
                    case 33:
                        worldType = WorldType.VOID;
                        break;
                }
                if (worldType != null) {
                    worldManager.startWorldNameInput(player, worldType, null, createPrivateWorld);
                    XSound.ENTITY_CHICKEN_EGG.play(player);
                }
                break;
            }
        case GENERATOR:
            {
                if (slot == 31) {
                    worldManager.startWorldNameInput(player, WorldType.CUSTOM, null, createPrivateWorld);
                    XSound.ENTITY_CHICKEN_EGG.play(player);
                }
                break;
            }
        case TEMPLATES:
            {
                ItemStack itemStack = event.getCurrentItem();
                if (itemStack == null) {
                    return;
                }
                XMaterial xMaterial = XMaterial.matchXMaterial(itemStack);
                switch(xMaterial) {
                    case FILLED_MAP:
                        worldManager.startWorldNameInput(player, WorldType.TEMPLATE, itemStack.getItemMeta().getDisplayName(), createPrivateWorld);
                        break;
                    case PLAYER_HEAD:
                        if (slot == 38) {
                            decrementInv(player);
                        } else if (slot == 42) {
                            incrementInv(player);
                        }
                        openInventory(player, CreateInventory.Page.TEMPLATES, createPrivateWorld);
                        break;
                    default:
                        return;
                }
                XSound.ENTITY_CHICKEN_EGG.play(player);
                break;
            }
    }
}
Also used : Player(org.bukkit.entity.Player) WorldType(com.eintosti.buildsystem.object.world.data.WorldType) ItemStack(org.bukkit.inventory.ItemStack) XMaterial(com.cryptomorin.xseries.XMaterial) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 3 with WorldType

use of com.eintosti.buildsystem.object.world.data.WorldType in project BuildSystem by einTosti.

the class WorldManager method finishPreparationsAndGenerate.

/**
 * Certain {@link WorldType}s require modifications to the world after its generation.
 *
 * @param buildWorld The build world object
 */
private void finishPreparationsAndGenerate(BuildWorld buildWorld) {
    WorldType worldType = buildWorld.getType();
    World bukkitWorld = generateBukkitWorld(buildWorld.getName(), worldType);
    switch(worldType) {
        case VOID:
            if (configValues.isVoidBlock()) {
                bukkitWorld.getBlockAt(0, 64, 0).setType(Material.GOLD_BLOCK);
            }
            bukkitWorld.setSpawnLocation(0, 65, 0);
            break;
        case FLAT:
            int y = XMaterial.supports(18) ? -60 : 4;
            bukkitWorld.setSpawnLocation(0, y, 0);
            break;
        default:
            break;
    }
}
Also used : WorldType(com.eintosti.buildsystem.object.world.data.WorldType) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 4 with WorldType

use of com.eintosti.buildsystem.object.world.data.WorldType in project BuildSystem by Trichtern.

the class WorldManager method finishPreparationsAndGenerate.

/**
 * Certain {@link WorldType}s require modifications to the world after its generation.
 *
 * @param buildWorld The build world object
 */
private void finishPreparationsAndGenerate(BuildWorld buildWorld) {
    WorldType worldType = buildWorld.getType();
    World bukkitWorld = generateBukkitWorld(buildWorld.getName(), worldType, buildWorld.getDifficulty(), buildWorld.getChunkGenerator());
    switch(worldType) {
        case VOID:
            if (configValues.isVoidBlock()) {
                bukkitWorld.getBlockAt(0, 64, 0).setType(Material.GOLD_BLOCK);
            }
            bukkitWorld.setSpawnLocation(0, 65, 0);
            break;
        case FLAT:
            int y = XMaterial.supports(18) ? -60 : 4;
            bukkitWorld.setSpawnLocation(0, y, 0);
            break;
        default:
            break;
    }
}
Also used : WorldType(com.eintosti.buildsystem.object.world.data.WorldType) World(org.bukkit.World) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld)

Example 5 with WorldType

use of com.eintosti.buildsystem.object.world.data.WorldType in project BuildSystem by Trichtern.

the class WorldManager method loadWorld.

public BuildWorld loadWorld(String worldName) {
    FileConfiguration configuration = worldConfig.getFile();
    if (configuration == null) {
        return null;
    }
    String creator = configuration.isString("worlds." + worldName + ".creator") ? configuration.getString("worlds." + worldName + ".creator") : "-";
    UUID creatorId = parseCreatorId(configuration, worldName, creator);
    WorldType worldType = configuration.isString("worlds." + worldName + ".type") ? WorldType.valueOf(configuration.getString("worlds." + worldName + ".type")) : WorldType.UNKNOWN;
    boolean privateWorld = configuration.isBoolean("worlds." + worldName + ".private") && configuration.getBoolean("worlds." + worldName + ".private");
    XMaterial material = parseMaterial(configuration, worldName);
    WorldStatus worldStatus = WorldStatus.valueOf(configuration.getString("worlds." + worldName + ".status"));
    String project = configuration.getString("worlds." + worldName + ".project");
    String permission = configuration.getString("worlds." + worldName + ".permission");
    long date = configuration.isLong("worlds." + worldName + ".date") ? configuration.getLong("worlds." + worldName + ".date") : -1;
    boolean physics = configuration.getBoolean("worlds." + worldName + ".physics");
    boolean explosions = !configuration.isBoolean("worlds." + worldName + ".explosions") || configuration.getBoolean("worlds." + worldName + ".explosions");
    boolean mobAI = !configuration.isBoolean("worlds." + worldName + ".mobai") || configuration.getBoolean("worlds." + worldName + ".mobai");
    String customSpawn = configuration.getString("worlds." + worldName + ".spawn");
    boolean blockBreaking = !configuration.isBoolean("worlds." + worldName + ".block-breaking") || configuration.getBoolean("worlds." + worldName + ".block-breaking");
    boolean blockPlacement = !configuration.isBoolean("worlds." + worldName + ".block-placement") || configuration.getBoolean("worlds." + worldName + ".block-placement");
    boolean blockInteractions = !configuration.isBoolean("worlds." + worldName + ".block-interactions") || configuration.getBoolean("worlds." + worldName + ".block-interactions");
    boolean buildersEnabled = configuration.isBoolean("worlds." + worldName + ".builders-enabled") && configuration.getBoolean("worlds." + worldName + ".builders-enabled");
    Difficulty difficulty = Difficulty.valueOf(configuration.getString("worlds." + worldName + ".difficulty", "PEACEFUL").toUpperCase());
    List<Builder> builders = parseBuilders(configuration, worldName);
    String chunkGeneratorString = configuration.getString("worlds." + worldName + ".chunk-generator");
    ChunkGenerator chunkGenerator = parseChunkGenerator(configuration, worldName);
    BuildWorld buildWorld = new BuildWorld(plugin, worldName, creator, creatorId, worldType, privateWorld, material, worldStatus, project, permission, date, physics, explosions, mobAI, customSpawn, blockBreaking, blockPlacement, blockInteractions, buildersEnabled, difficulty, builders, chunkGenerator, chunkGeneratorString);
    buildWorlds.add(buildWorld);
    return buildWorld;
}
Also used : Difficulty(org.bukkit.Difficulty) Builder(com.eintosti.buildsystem.object.world.Builder) XMaterial(com.cryptomorin.xseries.XMaterial) WorldStatus(com.eintosti.buildsystem.object.world.data.WorldStatus) FileConfiguration(org.bukkit.configuration.file.FileConfiguration) BuildWorld(com.eintosti.buildsystem.object.world.BuildWorld) WorldType(com.eintosti.buildsystem.object.world.data.WorldType) UUID(java.util.UUID) ChunkGenerator(org.bukkit.generator.ChunkGenerator)

Aggregations

WorldType (com.eintosti.buildsystem.object.world.data.WorldType)6 XMaterial (com.cryptomorin.xseries.XMaterial)4 BuildWorld (com.eintosti.buildsystem.object.world.BuildWorld)4 Builder (com.eintosti.buildsystem.object.world.Builder)2 WorldStatus (com.eintosti.buildsystem.object.world.data.WorldStatus)2 UUID (java.util.UUID)2 World (org.bukkit.World)2 FileConfiguration (org.bukkit.configuration.file.FileConfiguration)2 Player (org.bukkit.entity.Player)2 EventHandler (org.bukkit.event.EventHandler)2 ChunkGenerator (org.bukkit.generator.ChunkGenerator)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 Difficulty (org.bukkit.Difficulty)1