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));
}
}
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());
}
}
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);
}
}
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;
}
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);
}
}
Aggregations