Scoreboard Problem (Bug?)

Discussion in 'Plugin Development' started by AaronL98, Dec 31, 2013.

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

    AaronL98

    Hello. I am currently coding a plugin which displays the player's stats on a scoreboard, such as kills and money etc. Ignore the "[insert <feature>]" scores on the board, those are just placeholders for the future. When I create a blank score to represent a space in the scoreboard, it doesnt appear, except from only 1 of them i created.

    Here's the Scoreboard:
    [​IMG]

    And here's the code:
    Code:java
    1. private Scoreboard sBoard;
    2. private ScoreboardManager sbManager;
    3. private Objective obj;
    4.  
    5. private Score sp1;
    6. private Score sp2;
    7. private Score sp3;
    8. private Score sp4;
    9. private Score sp5;
    10. private Score sp6;
    11. private Score sp7;
    12. private Score sp8;
    13.  
    14. private Score kills;
    15. private Score killsInt;
    16. private Score deaths;
    17. private Score deathsInt;
    18. private Score votes;
    19. private Score votesInt;
    20. private Score tokens;
    21. private Score tokensInt;
    22. private Score balance;
    23. private Score balInt;
    24. private Score website;
    25. private Score websiteLink;
    26.  
    27.  
    28. public void onEnable(){
    29. getServer().getPluginManager().registerEvents(this, this);
    30.  
    31. sbManager = Bukkit.getScoreboardManager();
    32. sBoard = sbManager.getNewScoreboard();
    33.  
    34. obj = sBoard.registerNewObjective("Statbar", "dummy");
    35. obj.setDisplaySlot(DisplaySlot.SIDEBAR);
    36. obj.setDisplayName(ChatColor.BOLD + " Union Networks ");
    37.  
    38. sp1 = obj.getScore(Bukkit.getOfflinePlayer(""));
    39. sp1.setScore(-1);
    40.  
    41. kills = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA +""+ChatColor.BOLD+ "Kills:"));
    42. kills.setScore(-2);
    43. killsInt = obj.getScore(Bukkit.getOfflinePlayer("[Insert Kills]"));
    44. killsInt.setScore(-3);
    45.  
    46. sp2 = obj.getScore(Bukkit.getOfflinePlayer(""));
    47. sp2.setScore(-4);
    48.  
    49.  
    50. deaths = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA +""+ChatColor.BOLD+ "Deaths:"));
    51. deaths.setScore(-5);
    52. deathsInt = obj.getScore(Bukkit.getOfflinePlayer("[Insert Deaths]"));
    53. deathsInt.setScore(-6);
    54.  
    55. sp3 = obj.getScore(Bukkit.getOfflinePlayer(""));
    56. sp3.setScore(-7);
    57.  
    58. votes = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA +""+ChatColor.BOLD+"Votes:"));
    59. votes.setScore(-8);
    60. votesInt = obj.getScore(Bukkit.getOfflinePlayer("[Insert Votes]"));
    61. votesInt.setScore(-9);
    62.  
    63. sp4 = obj.getScore(Bukkit.getOfflinePlayer(""));
    64. sp4.setScore(-10);
    65.  
    66. tokens = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + "Tokens"));
    67. tokens.setScore(-11);
    68. tokensInt = obj.getScore(Bukkit.getOfflinePlayer("[Insert Tokens]"));
    69. tokensInt.setScore(-12);
    70.  
    71. sp5 = obj.getScore(Bukkit.getOfflinePlayer(""));
    72. sp5.setScore(-13);
    73.  
    74.  
    75. balance = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA+""+ChatColor.BOLD+"Balance:"));
    76. balance.setScore(-14);
    77. balInt = obj.getScore(Bukkit.getOfflinePlayer("[Insert Balance]"));
    78. balInt.setScore(-15);
    79.  
    80. sp6 = obj.getScore(Bukkit.getOfflinePlayer(""));
    81. sp6.setScore(-16);
    82.  
    83. website = obj.getScore(Bukkit.getOfflinePlayer(ChatColor.DARK_AQUA+""+ChatColor.BOLD+"Website:"));
    84. website.setScore(-17);
    85. websiteLink = obj.getScore(Bukkit.getOfflinePlayer("[Insert Link]"));
    86. websiteLink.setScore(-18);
    87.  
    88.  
    89.  
    90.  
    91.  
    92.  
    93. }


    It seems to be only creating the space under Balance Score.

    Thanks

    **EDIT**

    The variables named sp<#> are the scores which are supposed to create a space.
     
  2. Offline

    RainoBoy97

    As scores are fake players, and each player has an unique name. You need to add a space for each blank name :)
     
  3. Offline

    AaronL98

    RainoBoy97 Ahh. now i get it :) Thanks. So its basically thinks that "" is a player, and cannot be on the scoreboard more than once. thanks ;)

    **EDIT**
    Tried this, does not work. i put an extra [space] in each score 'name' so all the scores do not have the same data, and my scoreboard just disappeared.

    Still looking for some help. :/

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

    AoH_Ruthless

    AaronL98
    Show what you are trying now. I did not really understand what you meant in post #3.
     
  5. Offline

    AaronL98

    AoH_Ruthless

    As seen on the original post of this thread, i have a screenshot of my current scoreboard with the code. Where you seen under "[Insert Balance]"(That is just a place holder until i get player stats) there is a space. In the code i have coded it so there is a space under every title. (Variables "sp<#>")

    In post three, RainoBoy97 told me instead of using the same empty string ("") for each space, use like for the first one (" "), second (" "), so each space does not have the same amount of spaces. This is because the score is stored as an OfflinePlayer, and the server will think i am refrencing the same player for each space. I tried it the way he said, with 1 more space in each string, and the scoreboard disappeared.
     
  6. Offline

    AoH_Ruthless

  7. Offline

    AaronL98

    Yeah. After i put the extra spaces in, my scoreboard completely disappeared. There was no errors in console too.
     
  8. Offline

    AoH_Ruthless

    AaronL98
    Maybe it's because you are setting a score for blank players (I am not sure if that's actually the issue). So I would try not setting a score for the blank players.
     
  9. Offline

    AaronL98


    Hmm. I dont know. If the spaces dont have a score, they wont be in the specific order.
     
  10. Offline

    AaronL98

    I've also tried implementing chat colors and the empty string "" to give it a unique name. no luck

    Still an issue :/

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

Share This Page