nametags

Discussion in 'Spigot Plugin Development' started by William029, May 29, 2017.

  1. Im trying to get it to show someones prefix under there name but it shows there own rank under the other peoples head
    Code (Text):
        @EventHandler
        public void onEvent(PlayerJoinEvent e) {
            Player player = e.getPlayer();
           
            String playersprefix = MainClass.getChat().getPlayerPrefix(player);
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Team team = board.registerNewTeam(player.getName().toString());
            Objective objective = board.registerNewObjective(replaceSymbols(playersprefix.toString()), replaceSymbols(e.getPlayer().getName().toString()));
            team.setPrefix(playersprefix);
            e.getPlayer().setScoreboard(board);
            team.addPlayer(e.getPlayer());
            objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
           
           

        }
     
  2. Its probably because you're setting every player that joins to be on the same team, try making a new team for each player/rank instead of having one big team for all of the players.
     
  3. ohhhhhhh yea thanks for the help
     
  4. Any time! Let me know if it works! :) And can you pm me? I really want to see this in action!
     
  5. how would I do that though? like rename for each player
     
  6. wait i dont think team is one big team is it?
     
  7. No, it isn't one big team. I think your issue is that you're still working on the objective code even after you set the scoreboard of the player. Try setting the scoreboard at the VERY end.

    Call #setScoreboard() AFTER you're done with everything regarding the scoreboard.
     
  8. what do u mean setscoreboard?
     
  9. Move
    Code (Text):
    e.getPlayer().setScoreboard(board);
    to the very bottom
     
  10. still no hmm got any other ideas?
     
  11. I think its because u can only see ur own scoreboard anyone have ideas to fix
     
  12. How about have everyone on the same team just with a different objective. Try that and get back to me.
     
  13. still same results