Search in sources :

Example 1 with Item

use of com.iridium.iridiumcore.Item 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)

Example 2 with Item

use of com.iridium.iridiumcore.Item in project IridiumSkyblock by Iridium-Development.

the class IslandBoostersGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
    for (Map.Entry<String, Booster> entry : IridiumSkyblock.getInstance().getBoosterList().entrySet()) {
        Item item = entry.getValue().item;
        IslandBooster islandBooster = IridiumSkyblock.getInstance().getIslandManager().getIslandBooster(getIsland(), entry.getKey());
        long minutes = LocalDateTime.now().until(islandBooster.getTime(), ChronoUnit.MINUTES);
        long seconds = LocalDateTime.now().until(islandBooster.getTime(), ChronoUnit.SECONDS) - minutes * 60;
        inventory.setItem(item.slot, ItemStackUtils.makeItem(item, Arrays.asList(new Placeholder("timeremaining_minutes", String.valueOf(Math.max(minutes, 0))), new Placeholder("timeremaining_seconds", String.valueOf(Math.max(seconds, 0))), new Placeholder("crystalcost", IridiumSkyblock.getInstance().getNumberFormatter().format(entry.getValue().crystalsCost)), new Placeholder("vaultcost", IridiumSkyblock.getInstance().getNumberFormatter().format(entry.getValue().vaultCost)))));
    }
    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) IslandBooster(com.iridium.iridiumskyblock.database.IslandBooster) IslandBooster(com.iridium.iridiumskyblock.database.IslandBooster) Booster(com.iridium.iridiumskyblock.Booster) Map(java.util.Map)

Example 3 with Item

use of com.iridium.iridiumcore.Item in project IridiumSkyblock by Iridium-Development.

the class IslandLogsGUI method setItemStack.

public void setItemStack(Inventory inventory, Item item, int page, LogAction... logActions) {
    ItemStack itemStack = ItemStackUtils.makeItem(item, new PlaceholderBuilder().applyIslandPlaceholders(getIsland()).build());
    ItemMeta itemMeta = itemStack.getItemMeta();
    List<String> lore = new ArrayList<>();
    List<IslandLog> islandLogs = IridiumSkyblock.getInstance().getDatabaseManager().getIslandLogTableManager().getEntries(getIsland()).stream().filter(islandLog -> Arrays.stream(logActions).anyMatch(logAction -> logAction.equals(islandLog.getLogAction()))).sorted(Comparator.comparing(IslandLog::getTime).reversed()).collect(Collectors.toList());
    int index = 0;
    for (IslandLog islandLog : islandLogs) {
        if ((page - 1) * 10 <= index && page * 10 > index) {
            long time = (System.currentTimeMillis() - islandLog.getTime()) / 1000L;
            int days = (int) TimeUnit.SECONDS.toDays(time);
            int hours = (int) Math.floor(TimeUnit.SECONDS.toHours(time - days * 86400L));
            int minutes = (int) Math.floor((time - (days * 86400) - (hours * 3600)) / 60.0D);
            int seconds = (int) Math.floor((time - (days * 86400) - (hours * 3600)) % 60.0D);
            lore.add(StringUtils.color(getLore(islandLog.getLogAction()).replace("%type%", islandLog.getData()).replace("%amount%", String.valueOf(islandLog.getAmount())).replace("%user%", islandLog.getUser().getName())).replace("%target%", islandLog.getTarget().getName()).replace("%seconds%", String.valueOf(seconds)).replace("%minutes%", String.valueOf(minutes)).replace("%hours%", String.valueOf(hours)).replace("%days%", String.valueOf(days)));
        }
        index++;
    }
    if (itemMeta.getLore() != null) {
        lore.addAll(itemMeta.getLore());
    }
    int maxPage = (int) Math.ceil(islandLogs.size() / 10.00);
    itemMeta.setLore(lore.stream().map(loreLine -> loreLine.replace("%current_page%", String.valueOf(page)).replace("%max_page%", String.valueOf(maxPage > 0 ? maxPage : 1))).collect(Collectors.toList()));
    itemStack.setItemMeta(itemMeta);
    inventory.setItem(item.slot, itemStack);
}
Also used : ClickType(org.bukkit.event.inventory.ClickType) IslandLog(com.iridium.iridiumskyblock.database.IslandLog) Arrays(java.util.Arrays) ItemMeta(org.bukkit.inventory.meta.ItemMeta) ItemStackUtils(com.iridium.iridiumcore.utils.ItemStackUtils) Item(com.iridium.iridiumcore.Item) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) Island(com.iridium.iridiumskyblock.database.Island) InventoryClickEvent(org.bukkit.event.inventory.InventoryClickEvent) Collectors(java.util.stream.Collectors) Inventory(org.bukkit.inventory.Inventory) StringUtils(com.iridium.iridiumcore.utils.StringUtils) ItemStack(org.bukkit.inventory.ItemStack) ArrayList(java.util.ArrayList) LogAction(com.iridium.iridiumskyblock.LogAction) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) InventoryUtils(com.iridium.iridiumcore.utils.InventoryUtils) LogInventoryConfig(com.iridium.iridiumskyblock.configs.inventories.LogInventoryConfig) NotNull(org.jetbrains.annotations.NotNull) Comparator(java.util.Comparator) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) IslandLog(com.iridium.iridiumskyblock.database.IslandLog) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) ArrayList(java.util.ArrayList) ItemStack(org.bukkit.inventory.ItemStack) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Aggregations

Item (com.iridium.iridiumcore.Item)3 Placeholder (com.iridium.iridiumcore.utils.Placeholder)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 InventoryUtils (com.iridium.iridiumcore.utils.InventoryUtils)1 ItemStackUtils (com.iridium.iridiumcore.utils.ItemStackUtils)1 StringUtils (com.iridium.iridiumcore.utils.StringUtils)1 Booster (com.iridium.iridiumskyblock.Booster)1 IridiumSkyblock (com.iridium.iridiumskyblock.IridiumSkyblock)1 LogAction (com.iridium.iridiumskyblock.LogAction)1 PlaceholderBuilder (com.iridium.iridiumskyblock.PlaceholderBuilder)1 Upgrade (com.iridium.iridiumskyblock.Upgrade)1 LogInventoryConfig (com.iridium.iridiumskyblock.configs.inventories.LogInventoryConfig)1 Island (com.iridium.iridiumskyblock.database.Island)1 IslandBooster (com.iridium.iridiumskyblock.database.IslandBooster)1 IslandLog (com.iridium.iridiumskyblock.database.IslandLog)1 UpgradeData (com.iridium.iridiumskyblock.upgrades.UpgradeData)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1