Skip to content

Instantly share code, notes, and snippets.

@TigerHix
Created September 4, 2015 15:17
Show Gist options
  • Save TigerHix/fd594f354b64ae298ff6 to your computer and use it in GitHub Desktop.
Save TigerHix/fd594f354b64ae298ff6 to your computer and use it in GitHub Desktop.
import me.tigerhix.lib.bossbar.BossbarLib;
import me.tigerhix.lib.bossbar.handler.BossbarHandler;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
public final class BossbarHelper {
private BossbarHelper() {
}
public static boolean has(Player player) {
return getHandler().hasBossbar(player.getPlayer());
}
public static String getMessage(Player player) {
return getHandler().getBossbar(player).getMessage();
}
public static float getPercentage(Player player) {
return getHandler().getBossbar(player).getPercentage();
}
public static void updateMessage(Player player, String message) {
getHandler().getBossbar(player).setMessage(format(message));
getHandler().updateBossbar(player);
}
public static void updatePercentage(Player player, float percentage) {
getHandler().getBossbar(player).setPercentage(percentage);
getHandler().updateBossbar(player);
}
public static void updateAll(Player player, String message, float percentage) {
getHandler().getBossbar(player).setMessage(format(message));
getHandler().getBossbar(player).setPercentage(percentage);
getHandler().updateBossbar(player);
}
public static void clear(Player player) {
getHandler().clearBossbar(player.getPlayer());
}
private static BossbarHandler getHandler() {
return BossbarLib.getHandler();
}
private static String format(String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment