Solved Scoreboard Kicks Player

Discussion in 'Plugin Development' started by hanahouhanah, Jun 8, 2014.

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

    hanahouhanah

    Yea, sounds weird. Don't even know how I managed. However, I have reason to believe it has to do with getting an offline player to 'custom name' my scores.
    I've never worked with scoreboards before because whenever I try to learn about it I get a headache. Decided to power-through this time.
    Anyway, I can't test to see if this works.
    -
    This is what I originally tested with:
    Code:java
    1. public void setScoreBoard(Player p, FileConfiguration pF)
    2. {
    3. Scoreboard board = manager.getNewScoreboard();
    4. Objective objective = board.registerNewObjective("test", "dummy");
    5. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    6. objective.setDisplayName("McRPG");
    7. Score score1 = objective.getScore(Bukkit.getOfflinePlayer(ChatColor.RED + "Overall Level: "));
    8. Score score2 = objective.getScore(Bukkit.getOfflinePlayer("Max Health: "));
    9. Score score3 = objective.getScore(Bukkit.getOfflinePlayer("Health: "));
    10. Score score4 = objective.getScore(Bukkit.getOfflinePlayer("Strength: "));
    11. Score score5 = objective.getScore(Bukkit.getOfflinePlayer("Dexterity: "));
    12. Score score6 = objective.getScore(Bukkit.getOfflinePlayer("Intelligence: "));
    13. Score score7 = objective.getScore(Bukkit.getOfflinePlayer("Archery: "));
    14. Score score8 = objective.getScore(Bukkit.getOfflinePlayer("Agility: "));
    15. score1.setScore(pF.getInt("OverallLevel"));
    16. score2.setScore(pF.getInt("MaxHealth"));
    17. score3.setScore(pF.getInt("CurrentHealth"));
    18. score4.setScore(pF.getInt("Strength"));
    19. score5.setScore(pF.getInt("Dexterity"));
    20. score6.setScore(pF.getInt("Intelligence"));
    21. score7.setScore(pF.getInt("Archery"));
    22. score8.setScore(pF.getInt("Agility"));
    23. p.setScoreboard(board);
    24. }


    -
    Here's my 'kick' message:
    [​IMG]
    This is what I fixed it with:
    Code:java
    1. public void setScoreBoard(Player p, FileConfiguration pF)
    2. {
    3. Scoreboard board = manager.getNewScoreboard();
    4. Objective objective = board.registerNewObjective("test", "dummy");
    5. objective.setDisplaySlot(DisplaySlot.SIDEBAR);
    6. objective.setDisplayName("McRPG");
    7. Score score1 = objective.getScore(p);
    8. Score score2 = objective.getScore(p);
    9. Score score3 = objective.getScore(p);
    10. /*
    11.   Score score4 = objective.getScore(Bukkit.getOfflinePlayer("Strength: "));
    12.   Score score5 = objective.getScore(Bukkit.getOfflinePlayer("Dexterity: "));
    13.   Score score6 = objective.getScore(Bukkit.getOfflinePlayer("Intelligence: "));
    14.   Score score7 = objective.getScore(Bukkit.getOfflinePlayer("Archery: "));
    15.   Score score8 = objective.getScore(Bukkit.getOfflinePlayer("Agility: "));
    16.   */
    17. score1.setScore(pF.getInt("OverallLevel"));
    18. score2.setScore(pF.getInt("MaxHealth"));
    19. score3.setScore(pF.getInt("CurrentHealth"));
    20. /*
    21.   score4.setScore(pF.getInt("Strength"));
    22.   score5.setScore(pF.getInt("Dexterity"));
    23.   score6.setScore(pF.getInt("Intelligence"));
    24.   score7.setScore(pF.getInt("Archery"));
    25.   score8.setScore(pF.getInt("Agility"));
    26.   */
    27. p.setScoreboard(board);
    28. }

    (The fix works, but does not create multiple lines.)
    -
    So I guess my questions are:
    How would I go about making it work for custom names since using an offlineplayer doesn't work? And how could I make it multi-line as it doesn't seem to be working? It'll just show one line (the last score being set).
    -
    Thanks to anybody who contributes.

    Note: Using 1.7.9 build of Bukkit | getOfflinePlayer and getScore(OfflinePlayer) is deprecated.
     
  2. Offline

    leet4044

    Can you paste the stacktrace for when you get kicked?
     
  3. Offline

    hanahouhanah

    leet4044
    There is no error. Would've posted it if there was.
     
  4. Offline

    mine-care

    hanahouhanah try changing the offline player names to a or b or c ect, and try to see if the error continues, if it does means it is not the offline players , else it is :p btw give a look at the resources of forrums there is a class with methods that can help you :p
     
  5. Offline

    Plo124

    Bukkit.getOfflinePlayer(ChatColor.RED + "Overall Level: ")

    This appears to have a length of 17 after I counted this, which is obviously the error. Your first code should work, just shorten this, possible alternatives:
    - Overall Lvl
    - Overall
    - Total Level
     
    hanahouhanah likes this.
  6. Offline

    hanahouhanah

Thread Status:
Not open for further replies.

Share This Page