Scoreboards / subStrings

Discussion in 'Plugin Development' started by MCCoding, Sep 6, 2013.

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

    MCCoding

    how would i change a players name tag above their head and keep their skin it is possible i have seen a few servers do this and players have prefixes to there names like [Admin] MCCoding etc, I know about tag API and i have tested it and it resets the skin and cuts off half the name here is a plugin i found that was open source but i could not find on where it adds the prefix to the players name.
    https://github.com/wacossusca34/nametagedit
     
  2. Offline

    turqmelon

    Use the Team's part of the scoreboard API, set a the team's prefix to Admin or whatever, then assign whatever players you like to the team. MCCoding
     
  3. Offline

    MCCoding

    turqmelon
    Ah so that's how its done but how would i do that? i know how to make a scoreboard but not a team, mind you i have not made a scoreboard for a while i don't know if its changed in the updates, Thanks for your help!

    Got it to work but the only issue is if the name is over 16 letters long it won't let you join the server, how do i make it cut off or something in the tab list?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 4, 2016
  4. Offline

    MCCoding

    Okay i have got the tab name to work (I think its working for my account), but its not setting the players above head prefix for some reason here is my code.

    Code:java
    1. for (Player p : Bukkit.getOnlinePlayers()) {
    2. p.setScoreboard(board);
    3.  
    4. if(player.isOp()) {
    5. String s = "[" + ChatColor.DARK_RED + "Admin" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + player.getName();
    6. if (s.length() > 16)
    7. s = s.substring(0, 14);
    8.  
    9. AdminTeam.addPlayer(player);
    10. AdminTeam.setPrefix(s);
    11. }
    12. }
    13. }


    i also have tried
    Code:java
    1. AdminTeam.setDisplayName(s);
    but still did not change anything any help is much appreciated.
     
  5. Offline

    MCCoding

    Can anyone help me with this?
     
  6. Offline

    MCCoding

  7. Offline

    MCCoding

    Okay i'm getting really annoyed now i don't see on why its not working it was working a a couple of mins then just stopped here is my new code ad its not working again :(. What it was doing when it was working it would set the tab name for each team but still was not setting the display name of the player, it ma be the sub string i'm not to sure. Any help with this is really appreciated and here is my new updated code.

    EDIT: I also have a side bar score board i'm not sure if that is interfering with this on but here is the code for that as well.

    Code:java
    1. @EventHandler
    2. public void onJoinEvent(PlayerJoinEvent event) {
    3. Player player = event.getPlayer();
    4.  
    5.  
    6. if(player.isOp()) {
    7. String AT = "[" + ChatColor.DARK_RED + "Admin" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + player.getName();
    8. if (AT.length() > 16)
    9. AT = AT.substring(0, 14);
    10.  
    11. AdminTeam.addPlayer(player);
    12. AdminTeam.setDisplayName(AT);
    13. AdminTeam.setPrefix(AT);
    14. AdminTeam.setAllowFriendlyFire(true);
    15.  
    16. } else if(player.hasPermission("Team.Moderator")) {
    17. String MT = "[" + ChatColor.DARK_PURPLE + "Moderator" + ChatColor.WHITE + "] " + ChatColor.LIGHT_PURPLE + player.getName();
    18. if (MT.length() > 16)
    19. MT = MT.substring(0, 16);
    20.  
    21. ModeratorTeam.addPlayer(player);
    22. ModeratorTeam.setDisplayName(MT);
    23. ModeratorTeam.setPrefix(MT);
    24. ModeratorTeam.setAllowFriendlyFire(true);
    25.  
    26. for (Player onlinePlayer : Bukkit.getOnlinePlayers()){
    27. onlinePlayer.setScoreboard(board);
    28. }
    29. }
    30. }
    31.  
    32.  
    33. Scoreboard statBoard = ScoreBoardManager.getNewScoreboard();
    34. Objective kills = board.registerNewObjective("kills", "playerKillCount");
    35.  
    36. @EventHandler
    37. public void onJoinSetScore(PlayerJoinEvent event) {
    38.  
    39. kills.setDisplaySlot(DisplaySlot.SIDEBAR);
    40. kills.setDisplayName(ChatColor.YELLOW + "Score");
    41. Score kill = kills.getScore(Bukkit.getOfflinePlayer(ChatColor.GOLD + "Kills:"));
    42. kill.setScore(0);
    43.  
    44. for(Player online : Bukkit.getOnlinePlayers()){
    45. online.setScoreboard(statBoard);
    46. }
    47. }
    48. }
    49.  
    50.  
    51.  
    52.  
    53.  
     
  8. Offline

    MCCoding

Thread Status:
Not open for further replies.

Share This Page