use of com.iridium.iridiumcore.Item 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));
}
}
use of com.iridium.iridiumcore.Item in project IridiumSkyblock by Iridium-Development.
the class IslandBoostersGUI method addContent.
@Override
public void addContent(Inventory inventory) {
inventory.clear();
InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
for (Map.Entry<String, Booster> entry : IridiumSkyblock.getInstance().getBoosterList().entrySet()) {
Item item = entry.getValue().item;
IslandBooster islandBooster = IridiumSkyblock.getInstance().getIslandManager().getIslandBooster(getIsland(), entry.getKey());
long minutes = LocalDateTime.now().until(islandBooster.getTime(), ChronoUnit.MINUTES);
long seconds = LocalDateTime.now().until(islandBooster.getTime(), ChronoUnit.SECONDS) - minutes * 60;
inventory.setItem(item.slot, ItemStackUtils.makeItem(item, Arrays.asList(new Placeholder("timeremaining_minutes", String.valueOf(Math.max(minutes, 0))), new Placeholder("timeremaining_seconds", String.valueOf(Math.max(seconds, 0))), new Placeholder("crystalcost", IridiumSkyblock.getInstance().getNumberFormatter().format(entry.getValue().crystalsCost)), new Placeholder("vaultcost", IridiumSkyblock.getInstance().getNumberFormatter().format(entry.getValue().vaultCost)))));
}
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.iridiumcore.Item in project IridiumSkyblock by Iridium-Development.
the class IslandLogsGUI method setItemStack.
public void setItemStack(Inventory inventory, Item item, int page, LogAction... logActions) {
ItemStack itemStack = ItemStackUtils.makeItem(item, new PlaceholderBuilder().applyIslandPlaceholders(getIsland()).build());
ItemMeta itemMeta = itemStack.getItemMeta();
List<String> lore = new ArrayList<>();
List<IslandLog> islandLogs = IridiumSkyblock.getInstance().getDatabaseManager().getIslandLogTableManager().getEntries(getIsland()).stream().filter(islandLog -> Arrays.stream(logActions).anyMatch(logAction -> logAction.equals(islandLog.getLogAction()))).sorted(Comparator.comparing(IslandLog::getTime).reversed()).collect(Collectors.toList());
int index = 0;
for (IslandLog islandLog : islandLogs) {
if ((page - 1) * 10 <= index && page * 10 > index) {
long time = (System.currentTimeMillis() - islandLog.getTime()) / 1000L;
int days = (int) TimeUnit.SECONDS.toDays(time);
int hours = (int) Math.floor(TimeUnit.SECONDS.toHours(time - days * 86400L));
int minutes = (int) Math.floor((time - (days * 86400) - (hours * 3600)) / 60.0D);
int seconds = (int) Math.floor((time - (days * 86400) - (hours * 3600)) % 60.0D);
lore.add(StringUtils.color(getLore(islandLog.getLogAction()).replace("%type%", islandLog.getData()).replace("%amount%", String.valueOf(islandLog.getAmount())).replace("%user%", islandLog.getUser().getName())).replace("%target%", islandLog.getTarget().getName()).replace("%seconds%", String.valueOf(seconds)).replace("%minutes%", String.valueOf(minutes)).replace("%hours%", String.valueOf(hours)).replace("%days%", String.valueOf(days)));
}
index++;
}
if (itemMeta.getLore() != null) {
lore.addAll(itemMeta.getLore());
}
int maxPage = (int) Math.ceil(islandLogs.size() / 10.00);
itemMeta.setLore(lore.stream().map(loreLine -> loreLine.replace("%current_page%", String.valueOf(page)).replace("%max_page%", String.valueOf(maxPage > 0 ? maxPage : 1))).collect(Collectors.toList()));
itemStack.setItemMeta(itemMeta);
inventory.setItem(item.slot, itemStack);
}
Aggregations