Search in sources :

Example 1 with PlaceholderBuilder

use of com.iridium.iridiumskyblock.PlaceholderBuilder 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 PlaceholderBuilder

use of com.iridium.iridiumskyblock.PlaceholderBuilder 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 PlaceholderBuilder

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

the class PlayerChatListener method onPlayerChat.

@EventHandler(ignoreCancelled = true)
public void onPlayerChat(AsyncPlayerChatEvent event) {
    User user = IridiumSkyblock.getInstance().getUserManager().getUser(event.getPlayer());
    Optional<Island> island = user.getIsland();
    if (user.isIslandChat() && island.isPresent()) {
        event.setCancelled(true);
        for (User islandUser : island.get().getMembers()) {
            Player recipient = Bukkit.getPlayer(islandUser.getUuid());
            if (recipient != null) {
                recipient.sendMessage(StringUtils.color(StringUtils.processMultiplePlaceholders(IridiumSkyblock.getInstance().getMessages().islandMemberChat, new PlaceholderBuilder().applyIslandPlaceholders(island.get()).build()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix).replace("%player%", event.getPlayer().getName()).replace("%message%", event.getMessage())));
            }
        }
        for (Player player : Bukkit.getOnlinePlayers()) {
            User onlineUser = IridiumSkyblockAPI.getInstance().getUser(player);
            if (onlineUser.isIslandChatSpying()) {
                player.sendMessage(StringUtils.color(StringUtils.processMultiplePlaceholders(IridiumSkyblock.getInstance().getMessages().islandChatSpyMessage, new PlaceholderBuilder().applyIslandPlaceholders(island.get()).build()).replace("%prefix%", IridiumSkyblock.getInstance().getConfiguration().prefix).replace("%island%", island.get().getName()).replace("%player%", event.getPlayer().getName()).replace("%message%", event.getMessage())));
            }
        }
    } else {
        String format = event.getFormat();
        for (Map.Entry<String, Placeholders.Placeholder> entry : Placeholders.placeholders.entrySet()) {
            if (format.contains(entry.getKey().toUpperCase())) {
                format = format.replace(entry.getKey().toUpperCase(), entry.getValue().placeholderProcess(event.getPlayer()));
            }
        }
        event.setFormat(format);
    }
}
Also used : Player(org.bukkit.entity.Player) User(com.iridium.iridiumskyblock.database.User) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) Island(com.iridium.iridiumskyblock.database.Island) Map(java.util.Map) EventHandler(org.bukkit.event.EventHandler)

Example 4 with PlaceholderBuilder

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

the class IslandGUI method getInventory.

@NotNull
@Override
public Inventory getInventory() {
    String title = StringUtils.processMultiplePlaceholders(getNoItemGUI().title, new PlaceholderBuilder().applyIslandPlaceholders(island).build());
    Inventory inventory = Bukkit.createInventory(this, getNoItemGUI().size, StringUtils.color(title));
    Bukkit.getScheduler().runTaskAsynchronously(IridiumSkyblock.getInstance(), () -> addContent(inventory));
    return inventory;
}
Also used : PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder) Inventory(org.bukkit.inventory.Inventory) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with PlaceholderBuilder

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

the class IslandMembersGUI method addContent.

@Override
public void addContent(Inventory inventory) {
    inventory.clear();
    members.clear();
    InventoryUtils.fillInventory(inventory, IridiumSkyblock.getInstance().getInventories().membersGUI.background);
    AtomicInteger slot = new AtomicInteger(0);
    for (User user : getIsland().getMembers()) {
        int itemSlot = slot.getAndIncrement();
        inventory.setItem(itemSlot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().membersGUI.item, new PlaceholderBuilder().applyPlayerPlaceholders(user).applyIslandPlaceholders(getIsland()).build()));
        members.put(itemSlot, user);
    }
}
Also used : User(com.iridium.iridiumskyblock.database.User) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) PlaceholderBuilder(com.iridium.iridiumskyblock.PlaceholderBuilder)

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