package com.bitnix.dirtguilds.gui;

import com.bitnix.dirtguilds.DirtGuildsPlugin;
import com.bitnix.dirtguilds.guild.Guild;
import com.bitnix.dirtguilds.util.MessageUtil;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

public class GuildVaultMenu {

    private final DirtGuildsPlugin plugin;

    public GuildVaultMenu(DirtGuildsPlugin plugin) {
        this.plugin = plugin;
    }

    public void open(Player player, Guild guild) {
        String title = plugin.getConfig().getString("gui.vault.title", "<gold>Guild Vault</gold>");
        int size = guild.getVaultContents().length;

        Inventory inventory = Bukkit.createInventory(player, size, MessageUtil.mm(title));
        ItemStack[] contents = guild.getVaultContents();

        for (int i = 0; i < Math.min(size, contents.length); i++) {
            inventory.setItem(i, contents[i]);
        }

        player.openInventory(inventory);
    }
}
