package rip.tilly.bedwars.playerdata;

import lombok.Getter;
import org.bukkit.ChatColor;
import org.bukkit.Color;

import java.util.Arrays;

@Getter
public enum PlayerTeam {

    WHITE("White", Color.WHITE, ChatColor.WHITE, (byte) 0),
    SILVER("Silver", Color.SILVER, ChatColor.GRAY, (byte) 8),
    GRAY("Gray", Color.GRAY, ChatColor.DARK_GRAY, (byte) 7),
    BLACK("Black", Color.BLACK, ChatColor.BLACK, (byte) 15),
    BLUE("Blue", Color.BLUE, ChatColor.BLUE, (byte) 11),
    CYAN("Cyan", Color.TEAL, ChatColor.DARK_AQUA, (byte) 9),
    AQUA("Aqua", Color.AQUA, ChatColor.AQUA, (byte) 3),
    LIME("Lime", Color.LIME, ChatColor.GREEN, (byte) 5),
    GREEN("Green", Color.GREEN, ChatColor.DARK_GREEN, (byte) 13),
    YELLOW("Yellow", Color.YELLOW, ChatColor.YELLOW, (byte) 4),
    ORANGE("Orange", Color.ORANGE, ChatColor.GOLD, (byte) 1),
    RED("Red", Color.RED, ChatColor.RED, (byte) 14),
    PURPLE("Purple", Color.PURPLE, ChatColor.DARK_PURPLE, (byte) 10),
    PINK("Pink", Color.FUCHSIA, ChatColor.LIGHT_PURPLE, (byte) 6);

    private final String name;
    private final Color color;
    private final ChatColor chatColor;
    private final byte colorData;

    PlayerTeam(String name, Color color, ChatColor chatColor, byte colorData) {
        this.name = name;
        this.color = color;
        this.chatColor = chatColor;
        this.colorData = colorData;
    }

    public static PlayerTeam getFromName(String name) {
        return Arrays.stream(values()).filter((team) -> team.name.equalsIgnoreCase(name) || team.getName().equalsIgnoreCase(name)).findFirst().orElse(null);
    }
}
