Search in sources :

Example 6 with Placeholder

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

the class IslandBankGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
    for (BankItem bankItem : IridiumSkyblock.getInstance().getBankItemList()) {
        IslandBank islandBank = IridiumSkyblock.getInstance().getIslandManager().getIslandBank(getIsland(), bankItem);
        inventory.setItem(bankItem.getItem().slot, ItemStackUtils.makeItem(bankItem.getItem(), Collections.singletonList(new Placeholder("amount", IridiumSkyblock.getInstance().getNumberFormatter().format(islandBank.getNumber())))));
    }
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : IslandBank(com.iridium.iridiumskyblock.database.IslandBank) Placeholder(com.iridium.iridiumcore.utils.Placeholder) BankItem(com.iridium.iridiumskyblock.bank.BankItem)

Example 7 with Placeholder

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

the class IslandBiomeGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().biomeGUI.background);
    inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
    inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
    AtomicInteger index = new AtomicInteger(0);
    final long elementsPerPage = IridiumSkyblock.getInstance().getInventories().biomeGUI.size - 9;
    biomes.stream().skip((page - 1) * elementsPerPage).limit(elementsPerPage).forEach(xBiome -> inventory.setItem(index.getAndIncrement(), ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().biomeGUI.item, Collections.singletonList(new Placeholder("biome", WordUtils.capitalizeFully(xBiome.name().toLowerCase().replace("_", " ")))))));
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : Placeholder(com.iridium.iridiumcore.utils.Placeholder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 8 with Placeholder

use of com.iridium.iridiumcore.utils.Placeholder 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 9 with Placeholder

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

the class PlaceholderBuilder method applyIslandPlaceholders.

public PlaceholderBuilder applyIslandPlaceholders(Island island) {
    IslandUpgrade islandUpgrade = IridiumSkyblock.getInstance().getIslandManager().getIslandUpgrade(island, "member");
    int memberLimit = IridiumSkyblock.getInstance().getUpgrades().memberUpgrade.upgrades.get(islandUpgrade.getLevel()).amount;
    placeholderList.add(new Placeholder("island_name", island.getName()));
    placeholderList.add(new Placeholder("island_owner", island.getOwner().getName()));
    placeholderList.add(new Placeholder("island_value", IridiumSkyblock.getInstance().getNumberFormatter().format(island.getValue())));
    placeholderList.add(new Placeholder("island_rank", IridiumSkyblock.getInstance().getNumberFormatter().format(island.getRank())));
    placeholderList.add(new Placeholder("island_members", IridiumSkyblock.getInstance().getNumberFormatter().format(island.getMembers().size())));
    placeholderList.add(new Placeholder("island_members_limit", IridiumSkyblock.getInstance().getNumberFormatter().format(memberLimit)));
    placeholderList.add(new Placeholder("island_level", IridiumSkyblock.getInstance().getNumberFormatter().format(island.getLevel())));
    placeholderList.add(new Placeholder("island_create", island.getCreateTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))));
    IridiumSkyblock.getInstance().getBlockValues().blockValues.keySet().stream().map(material -> new Placeholder(material.name() + "_AMOUNT", IridiumSkyblock.getInstance().getNumberFormatter().format(IridiumSkyblock.getInstance().getIslandManager().getIslandBlockAmount(island, material)))).forEach(placeholderList::add);
    return this;
}
Also used : IslandUpgrade(com.iridium.iridiumskyblock.database.IslandUpgrade) List(java.util.List) IslandUpgrade(com.iridium.iridiumskyblock.database.IslandUpgrade) User(com.iridium.iridiumskyblock.database.User) DateTimeFormatter(java.time.format.DateTimeFormatter) Island(com.iridium.iridiumskyblock.database.Island) Placeholder(com.iridium.iridiumcore.utils.Placeholder) ArrayList(java.util.ArrayList) Placeholder(com.iridium.iridiumcore.utils.Placeholder)

Example 10 with Placeholder

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

the class IslandInvitesGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    List<IslandInvite> islandInvites = IridiumSkyblock.getInstance().getDatabaseManager().getIslandInviteTableManager().getEntries(getIsland());
    inventory.clear();
    InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
    AtomicInteger slot = new AtomicInteger(0);
    for (int i = 0; i < islandInvites.size(); i++) {
        Bukkit.getScheduler().runTaskAsynchronously(IridiumSkyblock.getInstance(), () -> {
            int itemSlot = slot.getAndIncrement();
            List<Placeholder> placeholderList = new PlaceholderBuilder().applyPlayerPlaceholders(islandInvites.get(itemSlot).getUser()).applyIslandPlaceholders(getIsland()).build();
            placeholderList.add(new Placeholder("inviter", islandInvites.get(itemSlot).getInviter().getName()));
            placeholderList.add(new Placeholder("time", islandInvites.get(itemSlot).getTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))));
            inventory.setItem(itemSlot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().islandInvitesGUI.item, placeholderList));
            invites.put(itemSlot, islandInvites.get(itemSlot).getUser().getName());
        });
    }
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : Placeholder(com.iridium.iridiumcore.utils.Placeholder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) IslandInvite(com.iridium.iridiumskyblock.database.IslandInvite)

Aggregations

Placeholder (com.iridium.iridiumcore.utils.Placeholder)17 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)8 PlaceholderBuilder (com.iridium.iridiumskyblock.PlaceholderBuilder)5 Map (java.util.Map)5 Island (com.iridium.iridiumskyblock.database.Island)3 User (com.iridium.iridiumskyblock.database.User)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Item (com.iridium.iridiumcore.Item)2 InventoryUtils (com.iridium.iridiumcore.utils.InventoryUtils)2 ItemStackUtils (com.iridium.iridiumcore.utils.ItemStackUtils)2 IridiumSkyblock (com.iridium.iridiumskyblock.IridiumSkyblock)2 InventoryClickEvent (org.bukkit.event.inventory.InventoryClickEvent)2 Inventory (org.bukkit.inventory.Inventory)2 ItemStack (org.bukkit.inventory.ItemStack)2 NotNull (org.jetbrains.annotations.NotNull)2 NBTCompound (com.iridium.iridiumcore.dependencies.nbtapi.NBTCompound)1 NBTItem (com.iridium.iridiumcore.dependencies.nbtapi.NBTItem)1 Booster (com.iridium.iridiumskyblock.Booster)1 Mission (com.iridium.iridiumskyblock.Mission)1