Search in sources :

Example 6 with WorldType

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

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)

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