/*
 *   This file is a part of the SteamWar software.
 *
 *   Copyright (C) 2025 SteamWar.de-Serverteam
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU Affero General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 *   GNU Affero General Public License for more details.
 *
 *   You should have received a copy of the GNU Affero General Public License
 *   along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package de.steamwar.fightsystem.utils;

import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;

import java.util.EnumMap;
import java.util.Map;

public class ColorConverter {
    private ColorConverter() {
    }

    private static final Map<ChatColor, DyeColor> chat2dyeColor = new EnumMap<>(ChatColor.class);
    private static final Map<ChatColor, Material> chat2dye = new EnumMap<>(ChatColor.class);

    static {
        chat2dyeColor.put(ChatColor.WHITE, DyeColor.WHITE);
        chat2dyeColor.put(ChatColor.GOLD, DyeColor.ORANGE);
        chat2dyeColor.put(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA);
        chat2dyeColor.put(ChatColor.BLUE, DyeColor.LIGHT_BLUE);
        chat2dyeColor.put(ChatColor.YELLOW, DyeColor.YELLOW);
        chat2dyeColor.put(ChatColor.GREEN, DyeColor.LIME);
        chat2dyeColor.put(ChatColor.RED, DyeColor.RED);
        chat2dyeColor.put(ChatColor.DARK_GRAY, DyeColor.GRAY);
        chat2dyeColor.put(ChatColor.DARK_AQUA, DyeColor.CYAN);
        chat2dyeColor.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE);
        chat2dyeColor.put(ChatColor.DARK_BLUE, DyeColor.BLUE);
        chat2dyeColor.put(ChatColor.AQUA, DyeColor.CYAN);
        chat2dyeColor.put(ChatColor.DARK_GREEN, DyeColor.GREEN);
        chat2dyeColor.put(ChatColor.DARK_RED, DyeColor.RED);
        chat2dyeColor.put(ChatColor.BLACK, DyeColor.BLACK);
        chat2dyeColor.put(ChatColor.GRAY, DyeColor.LIGHT_GRAY);

        chat2dye.put(ChatColor.WHITE, Material.WHITE_DYE);
        chat2dye.put(ChatColor.GOLD, Material.ORANGE_DYE);
        chat2dye.put(ChatColor.LIGHT_PURPLE, Material.MAGENTA_DYE);
        chat2dye.put(ChatColor.BLUE, Material.LIGHT_BLUE_DYE);
        chat2dye.put(ChatColor.YELLOW, Material.YELLOW_DYE);
        chat2dye.put(ChatColor.GREEN, Material.LIME_DYE);
        chat2dye.put(ChatColor.RED, Material.RED_DYE);
        chat2dye.put(ChatColor.DARK_GRAY, Material.GRAY_DYE);
        chat2dye.put(ChatColor.DARK_AQUA, Material.CYAN_DYE);
        chat2dye.put(ChatColor.DARK_PURPLE, Material.PURPLE_DYE);
        chat2dye.put(ChatColor.DARK_BLUE, Material.BLUE_DYE);
        chat2dye.put(ChatColor.AQUA, Material.CYAN_DYE);
        chat2dye.put(ChatColor.DARK_GREEN, Material.GREEN_DYE);
        chat2dye.put(ChatColor.DARK_RED, Material.RED_DYE);
        chat2dye.put(ChatColor.BLACK, Material.BLACK_DYE);
        chat2dye.put(ChatColor.GRAY, Material.LIGHT_GRAY_DYE);
    }

    public static DyeColor chat2dyeColor(ChatColor color) {
        return chat2dyeColor.get(color);
    }

    public static Material chat2dye(ChatColor color) {
        return chat2dye.get(color);
    }
}
