Search in sources :

Example 1 with InventoryValue

use of com.nextplugins.economy.configuration.InventoryValue in project NextEconomy by NextPlugins.

the class HistoricBankView method createPageItems.

@Override
protected List<InventoryItemSupplier> createPageItems(PagedViewer viewer) {
    val player = viewer.getPlayer();
    val account = accountStorage.findAccount(player);
    List<InventoryItemSupplier> items = new LinkedList<>();
    for (AccountBankHistoric transaction : account.getTransactions()) {
        items.add(() -> {
            val targetName = transaction.getTarget();
            val date = DateFormatUtil.of(transaction.getMilli());
            val transactionMessage = (transaction.getType() == TransactionType.WITHDRAW ? InventoryValue.get(InventoryValue::withdrawMessage) : InventoryValue.get(InventoryValue::depositMessage)).replace("@target", targetName);
            val item = InventoryButton.builder().materialData(new MaterialData(Material.AIR)).displayName(InventoryValue.get(InventoryValue::historicDisplayName).replace("@message", transactionMessage)).nickname(InventoryValue.get(InventoryValue::historicSkullName)).lore(InventoryValue.get(InventoryValue::historicLore).stream().map(line -> line.replace("@target", targetName).replace("@date", date).replace("@action", transaction.getType().getMessage()).replace("@message", transactionMessage).replace("@amount", NumberUtils.format(transaction.getAmount()))).collect(Collectors.toList())).build();
            String target = transaction.getTarget();
            if (target.equalsIgnoreCase("Banco"))
                target = "MrSnowDK";
            if (target.equalsIgnoreCase("Cheque"))
                target = "Tom25W";
            return InventoryItem.of(item.getItemStack(target));
        });
    }
    return items;
}
Also used : lombok.val(lombok.val) InventoryEditor(com.henryfabio.minecraft.inventoryapi.editor.InventoryEditor) TransactionType(com.nextplugins.economy.model.account.transaction.TransactionType) PagedInventory(com.henryfabio.minecraft.inventoryapi.inventory.impl.paged.PagedInventory) ViewerConfigurationImpl(com.henryfabio.minecraft.inventoryapi.viewer.configuration.impl.ViewerConfigurationImpl) PagedViewer(com.henryfabio.minecraft.inventoryapi.viewer.impl.paged.PagedViewer) InventoryItemSupplier(com.henryfabio.minecraft.inventoryapi.item.supplier.InventoryItemSupplier) Viewer(com.henryfabio.minecraft.inventoryapi.viewer.Viewer) lombok.val(lombok.val) DefaultItem(com.henryfabio.minecraft.inventoryapi.item.enums.DefaultItem) AccountBankHistoric(com.nextplugins.economy.model.account.historic.AccountBankHistoric) NumberUtils(com.nextplugins.economy.util.NumberUtils) Border(com.henryfabio.minecraft.inventoryapi.viewer.configuration.border.Border) Collectors(java.util.stream.Collectors) MaterialData(org.bukkit.material.MaterialData) List(java.util.List) InventoryValue(com.nextplugins.economy.configuration.InventoryValue) InventoryItem(com.henryfabio.minecraft.inventoryapi.item.InventoryItem) DateFormatUtil(com.nextplugins.economy.util.DateFormatUtil) AccountStorage(com.nextplugins.economy.model.account.storage.AccountStorage) LinkedList(java.util.LinkedList) InventoryButton(com.nextplugins.economy.views.button.InventoryButton) Material(org.bukkit.Material) MaterialData(org.bukkit.material.MaterialData) AccountBankHistoric(com.nextplugins.economy.model.account.historic.AccountBankHistoric) InventoryItemSupplier(com.henryfabio.minecraft.inventoryapi.item.supplier.InventoryItemSupplier) LinkedList(java.util.LinkedList)

Aggregations

InventoryEditor (com.henryfabio.minecraft.inventoryapi.editor.InventoryEditor)1 PagedInventory (com.henryfabio.minecraft.inventoryapi.inventory.impl.paged.PagedInventory)1 InventoryItem (com.henryfabio.minecraft.inventoryapi.item.InventoryItem)1 DefaultItem (com.henryfabio.minecraft.inventoryapi.item.enums.DefaultItem)1 InventoryItemSupplier (com.henryfabio.minecraft.inventoryapi.item.supplier.InventoryItemSupplier)1 Viewer (com.henryfabio.minecraft.inventoryapi.viewer.Viewer)1 Border (com.henryfabio.minecraft.inventoryapi.viewer.configuration.border.Border)1 ViewerConfigurationImpl (com.henryfabio.minecraft.inventoryapi.viewer.configuration.impl.ViewerConfigurationImpl)1 PagedViewer (com.henryfabio.minecraft.inventoryapi.viewer.impl.paged.PagedViewer)1 InventoryValue (com.nextplugins.economy.configuration.InventoryValue)1 AccountBankHistoric (com.nextplugins.economy.model.account.historic.AccountBankHistoric)1 AccountStorage (com.nextplugins.economy.model.account.storage.AccountStorage)1 TransactionType (com.nextplugins.economy.model.account.transaction.TransactionType)1 DateFormatUtil (com.nextplugins.economy.util.DateFormatUtil)1 NumberUtils (com.nextplugins.economy.util.NumberUtils)1 InventoryButton (com.nextplugins.economy.views.button.InventoryButton)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 lombok.val (lombok.val)1