package com.loganmagnan.eventcore.managers.hotbar.types;

import com.loganmagnan.eventcore.EventCore;
import com.loganmagnan.eventcore.managers.hotbar.ClickableItem;
import com.loganmagnan.eventcore.managers.hotbar.HotBar;
import com.loganmagnan.eventcore.menusystem.menus.StaffOnlineMenu;
import com.loganmagnan.eventcore.utils.ColorUtils;
import com.loganmagnan.eventcore.utils.Constants;
import com.loganmagnan.eventcore.utils.ItemBuilder;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.HashMap;
import java.util.Map;

@Getter
@Setter
public class StaffModeHotBar extends HotBar {

    private EventCore main = EventCore.getInstance();

    public StaffModeHotBar(String id) {
        super(id);

        this.registerClickableItems();
    }

    @Override
    public Map<Integer, ClickableItem> getClickableItemsToApply(Player player) {
        Map<Integer, ClickableItem> clickableItems = new HashMap<Integer, ClickableItem>();
        clickableItems.put(0, this.getClickableItem("teleport-compass"));
        clickableItems.put(1, this.getClickableItem("inventory-inspect"));
        clickableItems.put(2, this.getClickableItem("better-looking"));

        if (player.hasPermission("worldedit.wand")) {
            clickableItems.put(3, this.getClickableItem("world-edit-wand"));
        }

        clickableItems.put(7, this.getClickableItem("staff-online"));
        clickableItems.put(8, this.getClickableItem("unvanish"));

        return clickableItems;
    }

    public void registerClickableItems() {
        this.addClickableItem("teleport-compass", new ClickableItem(player -> {

        }, new ItemBuilder(Material.COMPASS).name(ColorUtils.getMessageType("&bTeleport Compass")).build(), false, false, false));

        this.addClickableItem("inventory-inspect", new ClickableItem(player -> {

        }, new ItemBuilder(Material.BOOK).name(ColorUtils.getMessageType("&bInventory Inspect")).build(), false, false, false));

        this.addClickableItem("world-edit-wand", new ClickableItem(player -> {

        }, new ItemBuilder(Material.WOODEN_AXE).name(ColorUtils.getMessageType("&bWorld Edit Wand")).build(), false, false, false));

        this.addClickableItem("better-looking", new ClickableItem(player -> {

        }, new ItemBuilder(Material.RED_CARPET).name(ColorUtils.getMessageType("&bBetter Looking")).build(), false, false, false));

        this.addClickableItem("staff-online", new ClickableItem(player -> {
            new StaffOnlineMenu(this.main.getPlayerMenuUtil(player)).open(player);
        }, new ItemBuilder(Material.PLAYER_HEAD).name(ColorUtils.getMessageType("&bStaff Online")).build(), false, false, false));

        this.addClickableItem("vanish", new ClickableItem(player -> {
            this.applyToPlayer(player, this.getClickableItem("unvanish"), 8);
            this.main.getStaffManager().setVanish(player, true);

            player.sendMessage(ColorUtils.getMessageType(Constants.STAFF_MANAGEMENT_MESSAGES.get("vanish.enabled").get(0)));
        }, new ItemBuilder(Material.GRAY_DYE).name(ColorUtils.getMessageType("&bVanish")).build(), false, false, false));

        this.addClickableItem("unvanish", new ClickableItem(player -> {
            this.applyToPlayer(player, this.getClickableItem("vanish"), 8);
            this.main.getStaffManager().setVanish(player, false);

            player.sendMessage(ColorUtils.getMessageType(Constants.STAFF_MANAGEMENT_MESSAGES.get("vanish.disabled").get(0)));
        }, new ItemBuilder(Material.LIME_DYE).name(ColorUtils.getMessageType("&bUnvanish")).build(), false, false, false));
    }
}
