Solved can't remove a displaySlot.BELOW_NAME for certain players?

Discussion in 'Spigot Plugin Development' started by Swiftlicious, Feb 6, 2020.

Thread Status:
Not open for further replies.
  1. Code (Text):
        public static void updateHealth (Scoreboard s, boolean isSpectator) {
         
            if (!GameManager.isState(GameManager.GAME)) {
                s.getObjective("showhealth").getScoreboard().clearSlot(DisplaySlot.BELOW_NAME);
            }
         
            for (Player p : Bukkit.getOnlinePlayers()) {
                if (isSpectator) {
                    s.getObjective("showhealth").getScore(p.getName()).getScoreboard().resetScores(p.getName());
                }

                if (!Spectator.isSpectator(p) && GameManager.isState(GameManager.GAME)) {
                    if (p.getHealth() > 0) {
                        s.getObjective("showhealth").getScore(p.getName()).setScore((int)p.getHealth());
                    }
                }
            }
        }
    What i'm attempting to do is make it so my spectator list don't have a BELOW_NAME displaySlot with health while alive players on a team do (but spectators can still see the alive players one they just won't be able to see their own or other spectators) but for some reason at best even if I reset the scores it'l just set it to 0 instead of removing it completely. I tried clearing the slot but that removed it for alive players in a spectator's view as well. I'm not sure what other options there are. I've tried removing the team as well.
     
  2. that's how below name works, if you set it, it's set for all players, cannot disable it for specific ones without disabling it for all
    best way to prevent this would be to show health in player's display name or in a hologram above player
     
  3. a hologram would be wonky from movement though. I guess I could try inside their display names though.
     
  4. if the hologram is entity riding on player's head, it would be okay as long as you don't show the entity to the player
     
Thread Status:
Not open for further replies.