Scoreboard | Need Help

Discussion in 'Plugin Development' started by ToastHelmi, Mar 30, 2014.

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

    ToastHelmi

    Hello want to display a level (1-5) under a players name
    each player could have a different level this is what i do to set the scoreboard of a player

    Code:java
    1. public void setScoreBoard(Player p, DisplaySlot s,String name, int score){
    2. Scoreboard board;
    3. Objective o;
    4. board = manager.getNewScoreboard();
    5.  
    6. o = board.registerNewObjective(name, "dummy");
    7. o.setDisplaySlot(s);
    8. o.setDisplayName(name);
    9. o.getScore(p).setScore(score);
    10. p.setScoreboard(board);
    11.  
    12.  
    13. }


    but instad of displayinh a player level under his name it displays "0 Stars" under the other players name

    what is my mistake
     
  2. Offline

    Wizehh

    It's hard to tell, but I'm assuming you want to create a a unique scoreboard for each individual player? You'll have to use a HashMap<String (the player's name), Scoreboard>.
    Also, the scoreboard won't display unless you have a score set.
     
  3. Offline

    F9Alejandro

    looks like you forgot to add how players gain the score... if not then at least a getrandom function to try and see if the code is working properly:

    Code:java
    1. import java.util.Random;
    2.  
    3. //note a single Random object is reused here
    4. Random randomGenerator = new Random();
    5. for (int idx = 1; idx <= 1; ++idx){
    6. int score = randomGenerator.nextInt(5);
    7. }
     
  4. Offline

    ToastHelmi

    Wizehh
    Yes i want unique scoreboards per player
    Do I relay have to use a hashmap until now every time I register a new scoreboard and unregister it if it don't should be displayed
    And havend I set the score with line 9

    F9Alejandro
    The score is definitely set since I'm using the bossbar to display the value to the player him self

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  5. Offline

    F9Alejandro

    Wait... you want the players level, not score that you see when you die... or is there more defined items/articles that are not shown
     
  6. Offline

    ToastHelmi

    Basically the "level" is number I generated based on data my plugin collects
    It should display for example "5 Stars" or what I would more prefer
    " ✪✪✪✪✪"
    F9Alejandro
     
  7. Offline

    F9Alejandro

    looks like you are left with the hashmap
     
  8. Offline

    ToastHelmi

    But it should make absolutely no difference using the same board stored in map or register and unregister board
     
Thread Status:
Not open for further replies.

Share This Page