PlayerList prefix/sufix

Discussion in 'Spigot Plugin Development' started by NEON_PT, May 24, 2015.

  1. Hello , I am creating a minecraft server and programming the plugins for it . Yesterday, I came up with the doubt of how to add a suffix to the player in TabList and your name in your head !,

    I hope you help me with this ...
     
  2. foncused

    Moderator Patron

    You could use the scoreboard API.
     
  3. Can you give me an example code please :)
     
  4. Can you give me an example code please :), You can tell me how I can disable kick by afk?
     
    #6 NEON_PT, May 24, 2015
    Last edited: May 24, 2015
  5. Do you know any Java?
     
  6. Yes!
     
  7. I haven't tested it, but theoretically this code should work:

    ScoreboardManager board;
    public void onEnable(){
    board= Bukkit.getScoreboardManager().getMainScoreboard();
    Bukkit.getPluginManager().registerEvents(this,this);
    }
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e){
    setPlayerPrefixSuffix(e.getPlayer(),"prefix","suffix")
    }
    @EventHandler
    public void onPlayerLeave(PlayerQuitEvent e){
    board.getTeam(e.getPlayer().getName()).unregister();
    }
    public void setPlayerPrefixSuffix(Player plr,String prefix,String suffix){
    Team t=board.registerNewTeam(plr.getName());
    t.setPrefix(prefix);
    t.setSuffix(suffix);
    t.addPlayer(plr);
    }
     
  8. Thanks, I'l test!
     
  9. I'm sory but this code does't work:: :(
     
  10. public void setPlayerPrefixSuffix(Player plr,String prefix,String suffix){
    Team t=board.registerNewTeam(plr.getName());
    t.setPrefix(prefix);
    t.setSuffix(suffix);
    t.addPlayer(plr);

    //This is missing: (You have to add the player to the board oc.)

    plr.setScoreboard(board);
    }
     
  11. Because you are just copying and pasting it. You have no real idea what you are doing.
     
    • Agree Agree x 2
  12. This is't working.....
    I'm copying because I don't now nothing this!
     
  13. [​IMG]
     
    • Winner Winner x 4
  14. Is the goal to change the Player's display name (Above the head) to have a prefix infront of it?
     
  15. Please, help this kid. If you want to code. Please learn it and don't ask for some code when it doesn't work. Try doing it by yourself or just simple, quit coding.
     
    • Agree Agree x 1
    • Funny Funny x 1