Help with Scoreboard!!!

Discussion in 'Plugin Development' started by Plo124, Sep 26, 2013.

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

    Plo124

    Hi, I'm having difficulties, (which is why I'm posting this,) with the Scoreboard API. I am making a plugin for a server I'm dev on, and what I need is to add a colored [*] before and after their name in the tab list, and above the physical player themselves.

    The problem is, when I restart or reload the server, when I log in, my name goes white again, but the [ ]'s and * keep their proper color. The important parts of the code is below:
    Code:java
    1. getConfig().set(e.getWhoClicked().getName()+".race", "E");
    2. getConfig().set(e.getWhoClicked().getName()+".tag", "7"); getConfig().set(e.getWhoClicked().getName()+".star", "E");
    3. saveConfig()

    ^ Setting the "Races", the possible values are E, H, and O

    Code:java
    1. this.getConfig().options().copyDefaults(true);
    2. Bukkit.getPluginManager().registerEvents(this, this);
    3. ScoreboardManager sb = Bukkit.getScoreboardManager();
    4. sc = sb.getNewScoreboard();
    5. sc.registerNewObjective("Races", "dummy");
    6. for (Player pl : Bukkit.getOnlinePlayers()){
    7. nameTagUpdater(pl);
    8. }
    9.  

    ^ The functions performed in the onEnable() event, this basically handles reloads, because the players will be online when the server reloads, but then the code below is hooked to a PlayerLoginEvent for when they log in:

    Code:java
    1. public void nameTagUpdater(Player pl){
    2. String race = "new";
    3. String raceCol = "f";
    4. String color = "7";
    5. String star = "E";
    6. if (this.getConfig().isSet(pl.getName()+".race") && this.getConfig().getString(pl.getName()+".race") != null){
    7. race = this.getConfig().getString(pl.getName()+".race");
    8. color = this.getConfig().getString(pl.getName()+".tag");
    9. star = this.getConfig().getString(pl.getName()+".star");
    10. }
    11. if (race == "E"){
    12. raceCol = "2";
    13. }
    14. if (race == "H"){
    15. raceCol = "3";
    16. }
    17. if (race == "O"){
    18. raceCol = "c";
    19. }
    20. if (sc.getTeams().contains(sc.getTeam(pl.getName()))){
    21. sc.getTeam(pl.getName()).unregister();
    22. }
    23. Team tm = sc.registerNewTeam(pl.getName());
    24. tm.addPlayer(pl);
    25. tm.setPrefix("§"+color+"[§"+star+"*§"+color+"]§"+raceCol);
    26. tm.setSuffix("§"+color+"[§"+star+"*§"+color+"]");
    27. for (Player player : Bukkit.getOnlinePlayers()){
    28. player.setScoreboard(sc);
    29. }
    30. }

    ^ The method in which the plugin updates the tab list.

    As I have said above (I think), this works the first time you select a race, and you can relog and stuff, and then when it restarts or reloads, the tab list goes white, but the stars are kept.
     
  2. Offline

    Plo124

    Bump :3
     
  3. aren't there other plugins messing up with the color of the name?
     
  4. Offline

    Plo124

    ferrybig Not that Im aware of, I don't have any plugin that changes name colors
     
  5. Try using it in a server with no plugins but this one and see if it works if it doesn't I'll try to fix the code for you
     
  6. Offline

    Plo124

  7. I'll loo at the code

    Look*

    Can you post the whole code

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

Share This Page