Core/src/de/joethei/core/api/BossBar.java

89 lines
3.4 KiB
Java

package de.joethei.core.api;
import de.joethei.core.api.utils.FakeDragon;
import de.joethei.core.api.utils.FakeWither;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.entity.Player;
public class BossBar
{
public static Map<Player, String> playerdragonbartask = new HashMap<Player, String>();
public static Map<Player, Float> healthdragonbartask = new HashMap<Player, Float>();
public static Map<Player, Integer> cooldownsdragonbar = new HashMap<Player, Integer>();
public static Map<Player, Integer> starttimerdragonbar = new HashMap<Player, Integer>();
public static Map<Player, String> playerwitherbartask = new HashMap<Player, String>();
public static Map<Player, Float> healthwitherbartask = new HashMap<Player, Float>();
public static Map<Player, Integer> cooldownswitherbar = new HashMap<Player, Integer>();
public static Map<Player, Integer> starttimerwitherbar = new HashMap<Player, Integer>();
public static void setBarDragon(Player p, String text) {
playerdragonbartask.put(p, text);
FakeDragon.setBossBartext(p, text);
}
public static void setBarDragonHealth(Player p, String text, float health)
{
if ((health <= 0.0F) || (health > 100.0F)) { health = 100.0F; text = "health must be between 1 and 100 it's a %"; }
playerdragonbartask.put(p, text);
healthdragonbartask.put(p, Float.valueOf(health / 100.0F * 200.0F));
FakeDragon.setBossBar(p, text, health);
}
public static void setBarDragonTimer(Player p, String text, int timer) {
playerdragonbartask.put(p, text);
cooldownsdragonbar.put(p, Integer.valueOf(timer));
if (!starttimerdragonbar.containsKey(p)) starttimerdragonbar.put(p, Integer.valueOf(timer));
int unite = Math.round(200 / starttimerdragonbar.get(p).intValue());
FakeDragon.setBossBar(p, text, unite * timer);
}
public static void removeBarDragon(Player p)
{
playerdragonbartask.remove(p);
healthdragonbartask.remove(p);
cooldownsdragonbar.remove(p);
starttimerdragonbar.remove(p);
FakeDragon.removeBossBar(p);
}
public static boolean hasBarDragon(Player p) {
return playerdragonbartask.get(p) != null;
}
public static void setBarWither(Player p, String text)
{
playerwitherbartask.put(p, text);
FakeWither.setBossBartext(p, text);
}
public static void setBarWitherHealth(Player p, String text, float health)
{
if ((health <= 0.0F) || (health > 100.0F)) { health = 100.0F; text = "health must be between 1 and 100 it's a %"; }
playerwitherbartask.put(p, text);
healthwitherbartask.put(p, Float.valueOf(health / 100.0F * 300.0F));
FakeWither.setBossBar(p, text, health);
}
public static void setBarWitherTimer(Player p, String text, int timer) {
playerwitherbartask.put(p, text);
cooldownswitherbar.put(p, Integer.valueOf(timer));
if (!starttimerwitherbar.containsKey(p)) starttimerwitherbar.put(p, Integer.valueOf(timer));
int unite = Math.round(300 / starttimerwitherbar.get(p).intValue());
FakeWither.setBossBar(p, text, unite * timer);
}
public static void removeBarWither(Player p)
{
playerwitherbartask.remove(p);
healthwitherbartask.remove(p);
cooldownswitherbar.remove(p);
starttimerwitherbar.remove(p);
FakeWither.removeBossBar(p);
}
public static boolean hasBarWither(Player p) {
return playerwitherbartask.get(p) != null;
}
}