Search in sources :

Example 11 with Placeholder

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

the class IslandMissionsGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().missionsGUI.background);
    AtomicInteger slot = new AtomicInteger(0);
    for (Map.Entry<String, Mission> entry : IridiumSkyblock.getInstance().getMissionsList().entrySet()) {
        if (entry.getValue().getMissionType() != Mission.MissionType.ONCE)
            continue;
        List<Placeholder> placeholders = IntStream.range(0, entry.getValue().getMissions().size()).boxed().map(integer -> IridiumSkyblock.getInstance().getIslandManager().getIslandMission(getIsland(), entry.getValue(), entry.getKey(), integer)).map(islandMission -> new Placeholder("progress_" + (islandMission.getMissionIndex() + 1), String.valueOf(islandMission.getProgress()))).collect(Collectors.toList());
        inventory.setItem(slot.getAndIncrement(), ItemStackUtils.makeItem(entry.getValue().getItem(), 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 : IntStream(java.util.stream.IntStream) ItemStackUtils(com.iridium.iridiumcore.utils.ItemStackUtils) Island(com.iridium.iridiumskyblock.database.Island) InventoryClickEvent(org.bukkit.event.inventory.InventoryClickEvent) Collectors(java.util.stream.Collectors) Inventory(org.bukkit.inventory.Inventory) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InventoryUtils(com.iridium.iridiumcore.utils.InventoryUtils) Map(java.util.Map) Mission(com.iridium.iridiumskyblock.Mission) NotNull(org.jetbrains.annotations.NotNull) Placeholder(com.iridium.iridiumcore.utils.Placeholder) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) Placeholder(com.iridium.iridiumcore.utils.Placeholder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Mission(com.iridium.iridiumskyblock.Mission) Map(java.util.Map)

Example 12 with Placeholder

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

the class IslandSettingsGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().islandSettingsGUI.background);
    for (Map.Entry<String, Setting> setting : IridiumSkyblock.getInstance().getSettingsList().entrySet()) {
        if (!setting.getValue().isModifiable())
            continue;
        IslandSetting islandSetting = IridiumSkyblock.getInstance().getIslandManager().getIslandSetting(getIsland(), setting.getKey(), setting.getValue().getDefaultValue());
        inventory.setItem(setting.getValue().getItem().slot, ItemStackUtils.makeItem(setting.getValue().getItem(), Collections.singletonList(new Placeholder("value", WordUtils.capitalize(islandSetting.getValue().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) IslandSetting(com.iridium.iridiumskyblock.database.IslandSetting) IslandSetting(com.iridium.iridiumskyblock.database.IslandSetting) Setting(com.iridium.iridiumskyblock.Setting) Map(java.util.Map)

Example 13 with Placeholder

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

the class IslandVisitorsGUI 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));
    final long elementsPerPage = inventory.getSize() - 9;
    AtomicInteger slot = new AtomicInteger(0);
    IridiumSkyblock.getInstance().getIslandManager().getPlayersOnIsland(getIsland()).stream().filter(user -> user.getIsland().map(Island::getId).orElse(0) != getIsland().getId()).skip((page - 1) * elementsPerPage).limit(elementsPerPage).forEachOrdered(user -> {
        visitors.add(user);
        List<Placeholder> placeholderList = new PlaceholderBuilder().applyPlayerPlaceholders(user).applyIslandPlaceholders(getIsland()).build();
        inventory.setItem(slot.getAndIncrement(), ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().visitorsGUI.item, placeholderList));
    });
}
Also used : 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) Player(org.bukkit.entity.Player) Inventory(org.bukkit.inventory.Inventory) ArrayList(java.util.ArrayList) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InventoryUtils(com.iridium.iridiumcore.utils.InventoryUtils) NotNull(org.jetbrains.annotations.NotNull) Placeholder(com.iridium.iridiumcore.utils.Placeholder) IridiumSkyblock(com.iridium.iridiumskyblock.IridiumSkyblock) Placeholder(com.iridium.iridiumcore.utils.Placeholder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) Island(com.iridium.iridiumskyblock.database.Island)

Example 14 with Placeholder

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

the class IslandWarpsGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().warpsGUI.background);
    AtomicInteger atomicInteger = new AtomicInteger(1);
    List<IslandWarp> islandWarps = IridiumSkyblock.getInstance().getDatabaseManager().getIslandWarpTableManager().getEntries(getIsland());
    Collections.reverse(islandWarps);
    for (IslandWarp islandWarp : islandWarps) {
        int slot = IridiumSkyblock.getInstance().getConfiguration().islandWarpSlots.get(atomicInteger.getAndIncrement());
        ItemStack itemStack = ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().warpsGUI.item, Arrays.asList(new Placeholder("island_name", getIsland().getName()), new Placeholder("warp_name", islandWarp.getName()), new Placeholder("description", islandWarp.getDescription() != null ? islandWarp.getDescription() : "")));
        Material material = islandWarp.getIcon().parseMaterial();
        if (material != null)
            itemStack.setType(material);
        inventory.setItem(slot, itemStack);
    }
    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) IslandWarp(com.iridium.iridiumskyblock.database.IslandWarp) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack)

Example 15 with Placeholder

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

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