Minigame scoreboard problem.

Discussion in 'Plugin Development' started by xFoundation, Apr 29, 2017.

Thread Status:
Not open for further replies.
  1. Hey guys,

    Today I have a little problem with my scoreboard.


    I have a leaderboard like this:
    [​IMG]

    When the game is starting, every player name are in this scoreboard.

    I added a HashMap to store player kills:

    Code:
    public Map<String, Integer> kills = new HashMap<String, Integer>();

    Code:
    ScoreboardManager sb = Bukkit.getScoreboardManager();
                        org.bukkit.scoreboard.Scoreboard board = sb.getNewScoreboard();
    
                        Objective obj = board.registerNewObjective("Stats", "dummy");
                        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
                        obj.setDisplayName(ChatColor.RED.toString() + ChatColor.BOLD + "LeaderBoard");
    
                        for (Player s : Bukkit.getOnlinePlayers()) {
                            Score kill = obj.getScore(s.getName());
                            kill.setScore(s.getStatistic(Statistic.PLAYER_KILLS));
                            p.setStatistic(Statistic.PLAYER_KILLS, 0);
    
                            p.setScoreboard(board);
    I don't know how to update the scoreboard every time a player kill another player.

    Thanks for your help!
     
    Last edited: Apr 30, 2017
  2. Offline

    MrGeneralQ

    Create a method in the killer event , Call the setScore and update there.
     
  3. I fixed the error but, when the Statistic.PLAYER_KILLS is 0. The first kill doesn't count :/
     
  4. Offline

    MrGeneralQ

    Mark your thread as solved
     
Thread Status:
Not open for further replies.

Share This Page