Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5337

Playername in Tablist/Scoreboard is allways white

XMLWordPrintable

    • 1.14.4
    • Yes

      It isn't possible to create a scoreboard via SpigotAPI for the Tablist/Playerheadname without the playername is white.

       

      import org.bukkit.Bukkit;
      import org.bukkit.entity.Player;
      import org.bukkit.event.EventHandler;
      import org.bukkit.event.Listener;
      import org.bukkit.event.player.PlayerJoinEvent;
      import org.bukkit.scoreboard.Scoreboard;
      import org.bukkit.scoreboard.Team;
      
      public class Tablist2 implements Listener {
      
      
          public static void initScoreboard(Player p) {
              if(p.getScoreboard()==null){
                  p.setScoreboard(p.getServer().getScoreboardManager().getNewScoreboard());
              }
      
          }
      
          public static void setTeam(Player p) {
              String teamName;
              String prefix;
              if(p.hasPermission("test.admin")) {
                  teamName = "00Admin";
                  prefix="§4Admin §7| §4";
              } else {
                  teamName = "01Spieler";
                  prefix="§7Spieler §8| §7";
              }
      
              Team team= p.getScoreboard().getTeam(teamName);
              if(team==null){
                  team=p.getScoreboard().registerNewTeam(teamName);
              }
              team.setPrefix(prefix);
              team.addEntry(p.getName());
              p.setDisplayName("§9"+p.getName());
          }
      
          @EventHandler
          public void onJoin(PlayerJoinEvent e) {
              Player p = e.getPlayer();
              initScoreboard(p);
              for(Player all: Bukkit.getOnlinePlayers()) {
                  setTeam(all);
              }
          }
      }
      
      

            Unassigned Unassigned
            awfjaiowfiawgfawf segsgesge
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: