Solved Update Player Health Without Changing it?

Discussion in 'Spigot Plugin Development' started by ReadySetPawn, Sep 25, 2017.

  1. Yes this is about the scoreboard health issue. When a player joins, they see everyone as having 0 health until that player's health updates. I tried damaging all online players very slightly once a player joins but that is not very clean, because all players get the hit effect which is very annoying. I even tried using packets to update the score and that doesn't update the health.

    Here's the code:
    Code (Java):
    public static void updateHealth(Player player, Player player1, Scoreboard scoreboard){
            ScoreboardObjective scoreboardObjective = new ScoreboardObjective(scoreboard, "health", IScoreboardCriteria.g);
            ScoreboardScore scoreboardScore = new ScoreboardScore(scoreboard, scoreboardObjective, player1.getName());
            PacketPlayOutScoreboardScore packet = new PacketPlayOutScoreboardScore(scoreboardScore);
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
    Any help is appreciated.
  2. The problem is that the scoreboard score you create does not have a value. You need to set that health value with scroebaordscore.setScroe((int)targetplayer.getHealth())
    • Informative Informative x 1
  3. Good call. Testing it out right now. And thanks for the speedy reply!


    That was the problem :D It works now. Thanks!
    #3 ReadySetPawn, Sep 25, 2017
    Last edited: Sep 25, 2017