use of com.henryfabio.minecraft.inventoryapi.editor.InventoryEditor in project NextEconomy by NextPlugins.
the class BankView method configureInventory.
@Override
protected void configureInventory(Viewer viewer, @NotNull InventoryEditor editor) {
val player = viewer.getPlayer();
val account = accountStorage.findAccount(player);
val instance = PurseAPI.getInstance();
val receiveType = ColorUtil.colored(account.isReceiveCoins() ? MessageValue.get(MessageValue::receiveCoinsOn) : MessageValue.get(MessageValue::receiveCoinsOff));
val discordName = ColorUtil.colored(account.getDiscordName() == null ? "&cNão vinculado" : account.getDiscordName());
val purse = instance != null ? instance.getPurseFormated() : "";
val isHigh = instance != null ? instance.getHighMessage() : "";
val nextUpdate = instance != null ? TimeUtils.format(instance.getNextUpdate() - System.currentTimeMillis()) : "";
val transactionName = account.getTransactionsQuantity() == 1 ? MessageValue.get(MessageValue::singularTransaction) : MessageValue.get(MessageValue::pluralTransaction);
val transactionsMessage = account.getTransactionsQuantity() + " " + transactionName;
for (val value : BUTTONS.values()) {
val inventorySlot = value.getInventorySlot();
if (inventorySlot == -1 || (value.getButtonType() == ButtonType.PURSE && instance == null))
continue;
val valueItem = new ItemBuilder(value.getItemStack(player.getName())).setLore(value.getLore().stream().map(line -> line.replace("$money", account.getBalanceFormated()).replace("$transactions", transactionsMessage).replace("$movimentedMoney", NumberUtils.format(account.getMovimentedBalance())).replace("$toggleMessage", receiveType).replace("$discord", discordName).replace("$value", purse).replace("$status", isHigh).replace("$time", nextUpdate)).collect(Collectors.toList())).wrap();
editor.setItem(inventorySlot, InventoryItem.of(valueItem).defaultCallback(value.getButtonType().getAction()));
}
}
Aggregations