Search in sources :

Example 1 with Placeholder

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

the class IslandRewardsGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().islandReward.background);
    List<Placeholder> placeholders = new PlaceholderBuilder().applyIslandPlaceholders(getIsland()).build();
    // slot 0
    int maxSize = inventory.getSize() - 1;
    AtomicInteger atomicInteger = new AtomicInteger(0);
    for (IslandReward islandReward : IridiumSkyblock.getInstance().getDatabaseManager().getIslandRewardTableManager().getEntries(getIsland())) {
        if (atomicInteger.get() > maxSize)
            break;
        inventory.setItem(atomicInteger.getAndIncrement(), ItemStackUtils.makeItem(islandReward.getReward().item, placeholders));
    }
    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) IslandReward(com.iridium.iridiumskyblock.database.IslandReward) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder)

Example 2 with Placeholder

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

the class IslandTrustedGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().trustedGUI.background);
    List<IslandTrusted> islandTrustedList = IridiumSkyblock.getInstance().getDatabaseManager().getIslandTrustedTableManager().getEntries(getIsland());
    AtomicInteger slot = new AtomicInteger(0);
    for (IslandTrusted islandTrusted : islandTrustedList) {
        int itemSlot = slot.getAndIncrement();
        List<Placeholder> placeholderList = new PlaceholderBuilder().applyPlayerPlaceholders(islandTrusted.getUser()).applyIslandPlaceholders(getIsland()).build();
        placeholderList.add(new Placeholder("trustee", islandTrusted.getTruster().getName()));
        inventory.setItem(itemSlot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().trustedGUI.item, placeholderList));
        members.put(itemSlot, islandTrusted.getUser());
    }
}
Also used : Placeholder(com.iridium.iridiumcore.utils.Placeholder) IslandTrusted(com.iridium.iridiumskyblock.database.IslandTrusted) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder)

Example 3 with Placeholder

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

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

the class IslandPermissionsGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().islandPermissionsGUI.background);
    inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
    inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
    for (Map.Entry<String, Permission> permission : IridiumSkyblock.getInstance().getPermissionList().entrySet()) {
        if (permission.getValue().getPage() != page)
            continue;
        if (!permission.getValue().isModifiable())
            continue;
        boolean allowed = IridiumSkyblock.getInstance().getIslandManager().getIslandPermission(getIsland(), islandRank, permission.getValue(), permission.getKey());
        inventory.setItem(permission.getValue().getItem().slot, ItemStackUtils.makeItem(permission.getValue().getItem(), Collections.singletonList(new Placeholder("permission", allowed ? IridiumSkyblock.getInstance().getPermissions().allowed : IridiumSkyblock.getInstance().getPermissions().denied))));
    }
    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) Permission(com.iridium.iridiumskyblock.Permission) Map(java.util.Map)

Example 5 with Placeholder

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

the class IslandRanksGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    IslandRanksInventoryConfig islandRanks = IridiumSkyblock.getInstance().getInventories().islandRanksGUI;
    InventoryUtils.fillInventory(inventory, islandRanks.background);
    List<User> members = IridiumSkyblock.getInstance().getIslandManager().getIslandMembers(getIsland());
    inventory.setItem(islandRanks.owner.slot, ItemStackUtils.makeItem(islandRanks.owner, Collections.singletonList(new Placeholder("members", getIsland().getOwner().getName()))));
    inventory.setItem(islandRanks.coOwner.slot, ItemStackUtils.makeItem(islandRanks.coOwner, Collections.singletonList(new Placeholder("members", members.stream().filter(member -> member.getIslandRank().equals(IslandRank.CO_OWNER)).map(User::getName).collect(Collectors.joining(", "))))));
    inventory.setItem(islandRanks.moderator.slot, ItemStackUtils.makeItem(islandRanks.moderator, Collections.singletonList(new Placeholder("members", members.stream().filter(member -> member.getIslandRank().equals(IslandRank.MODERATOR)).map(User::getName).collect(Collectors.joining(", "))))));
    inventory.setItem(islandRanks.member.slot, ItemStackUtils.makeItem(islandRanks.member, Collections.singletonList(new Placeholder("members", members.stream().filter(member -> member.getIslandRank().equals(IslandRank.MEMBER)).map(User::getName).collect(Collectors.joining(", "))))));
    inventory.setItem(islandRanks.visitor.slot, ItemStackUtils.makeItem(islandRanks.visitor));
    if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
        inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
    }
}
Also used : IslandRanksInventoryConfig(com.iridium.iridiumskyblock.configs.inventories.IslandRanksInventoryConfig) Placeholder(com.iridium.iridiumcore.utils.Placeholder) User(com.iridium.iridiumskyblock.database.User)

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