Search in sources :

Example 1 with Upgrade

use of com.iridium.iridiumskyblock.Upgrade in project IridiumSkyblock by Iridium-Development.

the class IslandUpgradesGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().upgradesGUI.background);
    for (Map.Entry<String, Upgrade<?>> upgrade : IridiumSkyblock.getInstance().getUpgradesList().entrySet()) {
        Item item = upgrade.getValue().item;
        int level = IridiumSkyblock.getInstance().getIslandManager().getIslandUpgrade(getIsland(), upgrade.getKey()).getLevel();
        List<Placeholder> placeholderList = new ArrayList<>();
        placeholderList.add(new Placeholder("level", String.valueOf(level)));
        if (upgrade.getValue().upgrades.get(level) != null) {
            UpgradeData upgradeData = upgrade.getValue().upgrades.get(level);
            placeholderList.addAll(upgradeData.getPlaceholders());
        }
        if (upgrade.getValue().upgrades.get(level + 1) != null) {
            UpgradeData upgradeData = upgrade.getValue().upgrades.get(level + 1);
            placeholderList.add(new Placeholder("crystalscost", String.valueOf(upgradeData.crystals)));
            placeholderList.add(new Placeholder("vaultcost", String.valueOf(upgradeData.money)));
        } else if (!upgrade.getValue().upgrades.containsKey(level + 1)) {
            placeholderList.add(new Placeholder("crystalscost", IridiumSkyblock.getInstance().getPlaceholders().crystalCost));
            placeholderList.add(new Placeholder("vaultcost", IridiumSkyblock.getInstance().getPlaceholders().vaultCost));
        }
        inventory.setItem(item.slot, ItemStackUtils.makeItem(item, placeholderList));
    }
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : Item(com.iridium.iridiumcore.Item) Placeholder(com.iridium.iridiumcore.utils.Placeholder) UpgradeData(com.iridium.iridiumskyblock.upgrades.UpgradeData) ArrayList(java.util.ArrayList) Map(java.util.Map) Upgrade(com.iridium.iridiumskyblock.Upgrade)

Aggregations

Item (com.iridium.iridiumcore.Item)1 Placeholder (com.iridium.iridiumcore.utils.Placeholder)1 Upgrade (com.iridium.iridiumskyblock.Upgrade)1 UpgradeData (com.iridium.iridiumskyblock.upgrades.UpgradeData)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1