package eu.mhsl.minenet.minigames.instance.hub.inventory;

import eu.mhsl.minenet.minigames.instance.room.Room;
import eu.mhsl.minenet.minigames.message.component.TranslatedComponent;
import eu.mhsl.minenet.minigames.shared.inventory.InteractableInventory;
import net.minestom.server.entity.Player;
import net.minestom.server.inventory.InventoryType;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;

public class HubInventory extends InteractableInventory {
    public HubInventory(Player p) {
        super(InventoryType.CHEST_3_ROW, TranslatedComponent.assemble("hub#invTitle", p));

        setClickableItem(
                ItemStack
                        .builder(Material.WRITABLE_BOOK)
                        .customName(TranslatedComponent.assemble("hub#create", p))
                        .lore(TranslatedComponent.assemble("hub#create_description", p))
                        .build(),
                12,
                itemClick -> Room.createRoom(itemClick.getPlayer()),
                true
        );

        setClickableItem(
                ItemStack
                        .builder(Material.KNOWLEDGE_BOOK)
                        .customName(TranslatedComponent.assemble("hub#join", p))
                        .lore(TranslatedComponent.assemble("hub#join_description", p))
                        .build(),
                14,
                itemClick -> itemClick.getPlayer().openInventory(new JoinInventory(itemClick.getPlayer()))
        );
    }
}
