Search in sources :

Example 11 with PlaceholderBuilder

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

the class IslandBansGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
    inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
    inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
    islandBans = new ArrayList<>(IridiumSkyblock.getInstance().getDatabaseManager().getIslandBanTableManager().getEntries(getIsland()));
    final long elementsPerPage = inventory.getSize() - 9;
    AtomicInteger slot = new AtomicInteger(0);
    islandBans.stream().skip((page - 1) * elementsPerPage).limit(elementsPerPage).forEachOrdered(islandBan -> {
        List<Placeholder> placeholderList = new PlaceholderBuilder().applyPlayerPlaceholders(islandBan.getBannedUser()).applyIslandPlaceholders(getIsland()).build();
        placeholderList.add(new Placeholder("ban_time", islandBan.getBanTime().format(DateTimeFormatter.ofPattern(IridiumSkyblock.getInstance().getConfiguration().dateTimeFormat))));
        placeholderList.add(new Placeholder("banned_by", islandBan.getBanner().getName()));
        inventory.setItem(slot.getAndIncrement(), ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().bansGUI.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 : Placeholder(com.iridium.iridiumcore.utils.Placeholder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder)

Example 12 with PlaceholderBuilder

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

the class VisitGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().visitGUI.background);
    inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
    inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
    int elementsPerPage = inventory.getSize() - 9;
    List<Island> islands = IridiumSkyblock.getInstance().getDatabaseManager().getIslandTableManager().getEntries().stream().filter(island -> viewer.isBypassing() || island.isVisitable()).skip((long) (page - 1) * elementsPerPage).limit(elementsPerPage).collect(Collectors.toList());
    AtomicInteger slot = new AtomicInteger(0);
    for (Island island : islands) {
        inventory.setItem(slot.getAndIncrement(), ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().visitGUI.item, new PlaceholderBuilder().applyIslandPlaceholders(island).build()));
    }
}
Also used : List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InventoryUtils(com.iridium.iridiumcore.utils.InventoryUtils) ItemStackUtils(com.iridium.iridiumcore.utils.ItemStackUtils) User(com.iridium.iridiumskyblock.database.User) 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) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) Island(com.iridium.iridiumskyblock.database.Island)

Aggregations

PlaceholderBuilder (com.iridium.iridiumskyblock.PlaceholderBuilder)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Island (com.iridium.iridiumskyblock.database.Island)6 Placeholder (com.iridium.iridiumcore.utils.Placeholder)5 User (com.iridium.iridiumskyblock.database.User)5 Inventory (org.bukkit.inventory.Inventory)4 InventoryUtils (com.iridium.iridiumcore.utils.InventoryUtils)3 ItemStackUtils (com.iridium.iridiumcore.utils.ItemStackUtils)3 IridiumSkyblock (com.iridium.iridiumskyblock.IridiumSkyblock)3 List (java.util.List)3 Player (org.bukkit.entity.Player)3 InventoryClickEvent (org.bukkit.event.inventory.InventoryClickEvent)3 NotNull (org.jetbrains.annotations.NotNull)3 ArrayList (java.util.ArrayList)2 Collectors (java.util.stream.Collectors)2 Item (com.iridium.iridiumcore.Item)1 StringUtils (com.iridium.iridiumcore.utils.StringUtils)1 LogAction (com.iridium.iridiumskyblock.LogAction)1 UserChatToggleEvent (com.iridium.iridiumskyblock.api.UserChatToggleEvent)1 LogInventoryConfig (com.iridium.iridiumskyblock.configs.inventories.LogInventoryConfig)1