Solved Per player Scoreboard

Discussion in 'Plugin Development' started by rocket138, Dec 19, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    rocket138

    I'm working on a points plugin for my server, but I've run into an issue...
    I have absolutely no idea how to give players there own scoreboard. I can do scoreboard, but I'm having issues with having it show only the persons points and such.

    Like, do I need to make a hashmap full of scoreboards and stuff?
     
  2. Offline

    mrkirby153

    rocket138

    This is what I'm doing:
    Code:java
    1. private ScoreboardManager scoreboardManager = Bukkit.getScoreboardManager();
    2. private Scoreboard scoreboard = scoreboardManager.getNewScoreboard();
    3. private Objective o = scoreboard.registerNewObjective(arenaName + "-stats", "dummy");
    4. // ...
    5. public void someMethod(){
    6. o.setDisplayName(ChatColor.GREEN + "" + mins + ":" + secs + " left");
    7. // Put your scoreboard stuff heere
    8. for (String playerName : Bukit.getOnlinePlayers()) {
    9. Player player = Bukkit.getPlayerExact(playerName);
    10. player.setScoreboard(scoreboard);
    11. }
    12. }


    It seems to work.
    NOTE: This will display the same scoreborad to everyone
     
  3. Offline

    rocket138

    I need it to display the players score, like each players can see their points. So a different number per player.
     
  4. Offline

    mrkirby153

    rocket138
    Pass a player into someMethod() and then do
    Code:java
    1. Score score = o.getScore(Bukkit.getOfflinePlayer("FOO"));
    2. score.setScore(foo);
    3. player.setScoreboard(board);
     
  5. Offline

    rocket138

    StackTrace says that there is in error on the following line:
    Score score = o.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "Points: "));


    NEVERMIND, I FORGOT TO REGISTER THE SCOREBOARD T.T

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
Thread Status:
Not open for further replies.

Share This Page