health bar

This commit is contained in:
NK 2022-12-27 19:45:06 +00:00
parent ce5ad39302
commit 66fef835eb

View file

@ -7,7 +7,7 @@ import org.bukkit.scoreboard.*;
public class BelowNameManager { public class BelowNameManager {
public void setBelowName(Player player) { public void setBelowName(Player player) {
Scoreboard board = player.getScoreboard(); Scoreboard board = player.getScoreboard();
Objective obj = board.registerNewObjective("HealthBar", Criteria.create("CustomHealth"), ChatColor.RED.toString() + player.getHealth() + ""); Objective obj = board.registerNewObjective("HealthBar", Criteria.HEALTH, ChatColor.RED + "");
obj.setDisplaySlot(DisplaySlot.BELOW_NAME); obj.setDisplaySlot(DisplaySlot.BELOW_NAME);
player.setScoreboard(board); player.setScoreboard(board);
} }