Solved ScoreBoard Error??

Discussion in 'Plugin Development' started by lewysryan, Jun 26, 2014.

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

    lewysryan

    Im trying to make a scoreboard bub system for my mate but I got a error I can't solve as hard as I try.

    Code:java
    1. @EventHandler
    2. public void onJoin(final PlayerJoinEvent e){
    3. ScoreboardManager manager = Bukkit.getScoreboardManager();
    4.  
    5. final Scoreboard board = manager.getNewScoreboard();
    6.  
    7. final Objective objective = board.registerNewObjective("test", "dummy");
    8.  
    9. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    10.  
    11. objective.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Dexoria Network");
    12.  
    13. Score score = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.YELLOW + "" + ChatColor.BOLD + "Points"));
    14. score.setScore(16);
    15.  
    16. final Player p = e.getPlayer();
    17.  
    18. scoreboardTask.put(p, new BukkitRunnable() {
    19. public void run() {
    20.  
    21. Score score2 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.WHITE + Points.getPoints(e.getPlayer().getName())));
    22. score2.setScore(15);
    23.  
    24. if(!(e.getPlayer().isOnline())){
    25.  
    26. scoreboardTask.remove(p);
    27. cancel();
    28. }
    29. }
    30. });
    31.  
    32. scoreboardTask.get(p).runTaskTimer(Hub.getPluginInstance(), 20, 20);
    33.  
    34. Score score3 = objective.getScore(Bukkit.getOfflinePlayer(""));
    35. score3.setScore(14);
    36.  
    37. Score score4 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.GREEN + "" + ChatColor.BOLD + "Rank"));
    38. score4.setScore(13);
    39.  
    40. if(p.hasPermission("hub.owner")){
    41. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.RED + "OWNER"));
    42. score5.setScore(12);
    43. }else if(p.hasPermission("hub.admin")){
    44. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.RED + "ADMIN"));
    45. score5.setScore(12);
    46. }else if(p.hasPermission("hub.mod")){
    47. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.GOLD + "MOD"));
    48. score5.setScore(12);
    49. }else if(p.hasPermission("hub.helper")){
    50. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.GREEN + "HELPER"));
    51. score5.setScore(12);
    52. }else if(p.hasPermission("hub.ultimate")){
    53. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.AQUA + "ULTIMATE"));
    54. score5.setScore(12);
    55. }else if(p.hasPermission("hub.platinum")){
    56. Score score5 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.LIGHT_PURPLE + "PLATINUM"));
    57. score5.setScore(12);
    58. }
    59.  
    60. Score score6 = objective.getScore(Bukkit.getOfflinePlayer(""));
    61. score6.setScore(10);
    62.  
    63. Score score7 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.YELLOW +"Online Staff?"));
    64. score7.setScore(9);
    65.  
    66. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable(){
    67.  
    68. @Override
    69. public void run() {
    70.  
    71. for(Player p : Bukkit.getOnlinePlayers()){
    72. if(p.hasPermission("hub.staff")){
    73. Score score8 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.GREEN +"YES"));
    74. score8.setScore(8);
    75. }else{
    76. Score score8 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.WHITE +"NO"));
    77. score8.setScore(8);
    78. }
    79. }
    80. }
    81. }, 0, 20);
    82.  
    83. Score score9 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.BOLD + "" + ChatColor.WHITE +"---------"));
    84. score9.setScore(7);
    85.  
    86. e.getPlayer().setScoreboard(board);
    87. }


    Error:
    [​IMG]

    I know what's wrong im sending a string to long for the scoreboard but I can't see where! Please help
     
  2. Offline

    CMG

    That's Simple, If you take a look at line 11 (
    Code:java
    1. objective.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "Dexoria Network");
    )

    You can see the 'Dextoria Network' adds up to 15 characters, including the space between, but then you have the chat colours; each chat colour is two characters long (the colour symbol (§) and the colour char (eg 1) (§1), therefore your total character amount in that string is 19 characters, as said in the stacktrace which is exceeding the maximum amount of 16 characters.

    To fix the error you need to shorten the string.

    Nope.

    No offence dude, but posting something, then when the thread is solved changing your post to the correct answer is pretty silly if you ask me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 2, 2018
    lewysryan likes this.
  3. Offline

    mine-care

    Mabe on the first lines? The Deloria network is A 19 character thing
     
  4. Offline

    mine-care

    CMG I changed it before it was solved dude! Also I just noticed it after I post... I gave a better look on da code.. Sorry :'(
    If you want I can edit it back to the old reply
     
  5. Offline

    CMG

    Leave it, just forget about it.
     
  6. Offline

    mine-care

Thread Status:
Not open for further replies.

Share This Page