package tools;

import org.bukkit.boss.BarColor;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;

import java.util.List;

public class BossBarUtil {

    public static void setBarColor(BossBar bossBar, double percent){
        if (percent >= 0 && percent <= 0.3333) {
            bossBar.setColor(BarColor.RED);
        } else if (percent <= 0.6666) {
            bossBar.setColor(BarColor.YELLOW);
        } else {
            bossBar.setColor(BarColor.GREEN);
        }
    }

    public static void setBarProgress(BossBar bossBar,double percent){
        if (percent <= 0) {
            percent = 0;
        } else if (percent >= 1) {
            percent = 1;
        }
        bossBar.setProgress(percent);
    }

    // BossBarUtil.addBossBar(player,new ArrayList<>(Arrays.asList(bossBar1,bossBar3,bossBar2)));
    public static void addBossBar(Player player, List<BossBar> bossBarList){
        for (BossBar bossBar : bossBarList) {
            bossBar.addPlayer(player);
        }
    }

    public static void removeBossBar(Player player,List<BossBar> bossBarList){
        for (BossBar bossBar : bossBarList) {
            bossBar.removePlayer(player);
        }
    }

}
