TagAPI - Change/color the name over people's heads!

Discussion in 'Resources' started by mbaxter, Sep 6, 2012.

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

    Krijn

    [​IMG]
    But I have seen on Hypixel players with a longer nametag. How do they do that?
    Or do they use scoreboard prefixes?
     
  2. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Scoreboard ;)
     
  3. Offline

    Krijn

    Ok thanks
     
  4. Offline

    TheRoflcopter

    Is there a method to set the player name to the original one ? And why doesn't everyones name get reset after doing the bukkit /reload ?
     
  5. Offline

    AdamQpzm

    TheRoflcopter You can still get the player's name with getName()
     
  6. Offline

    Speaw

    Nick Speaw and not skin.
    Code:java
    1. @EventHandler
    2. public void onNameTag(final PlayerReceiveNameTagEvent e){
    3. final Player p = e.getNamedPlayer();
    4. PermissionUser user = PermissionsEx.getUser(p);
    5. e.setTag(user.getPrefix().replaceAll("&", "§") + user.getName());
    6. }

    PHP:
      Kurucu:
        
    options:
          
    rank'1'
        
    default: false
        prefix
    '§c§lOWNER§f '
        
    suffix'&f'
        
    permissions:
        - 
    '*'
     
    Last edited: Apr 28, 2016
  7. Offline

    SniperFodder

    Looks like you exceeded the Character limit.
     
  8. Offline

    Speaw

    How can expand character limit?
     
    Last edited: Apr 28, 2016
  9. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Speaw You don't! Hurray!

    Instead, use the scoreboard API :)
     
    AdamQpzm likes this.
  10. Offline

    Joiner

    mbaxter Why to use TagAPI if the Scoreboard API allows us to create name tags up to 64 characters?
     
  11. Offline

    bigteddy98

    For example TagAPI allows you to change the name for every person-to-person individually. So for example I can see my own nametag as "Sander", while you see it as "Someone" and yet another person sees it as "Unknown", etc. TagAPI has a few more nice possibilities like this which scoreboardAPI doesn't.
     
  12. Offline

    Joiner

  13. Offline

    AdamQpzm

    Joiner 'twas just an example, good sir.
     
  14. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    TagAPI was created before scoreboards existed at all. Back then, it was useful for coloring.

    Now, it still is useful for completely changing a username. You can't do that with scoreboards! :)
     
    rbrick and AdamQpzm like this.
  15. Offline

    Joiner

    mbaxter Why should I completely change a nickname?... but ok.
     
  16. Offline

    fujiboy4

    How would you do this with cmd usage?
     
  17. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    However you like?
     
  18. Offline

    fujiboy4

    Well, I have a plugin that I'm creating and I don't want it to be using "@EventHandler" But, the "event" function only works with EventHandlers. I kinda need help with that. (If I'm going a little off topic just tell me to create a new forum or conversation)
     
  19. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Then you aren't going to be able to make many plugins.
     
    Techcable likes this.
  20. Offline

    fujiboy4

    Well.... I guess I really don't essentially need that but... It was just a thought I guess.
     
  21. Offline

    XgXXSnipz

    mbaxter How can I use this when making it so
    Code:java
    1. @EventHandler
    2. public void onHit(final EntityDamageByEntityEvent e){
    3.  
    4.  
    5. if(e.getDamager() instanceof Player){
    6. Bukkit.getScheduler().runTaskLater(this, new Runnable() {
    7. Player p =(Player)e.getEntity();
    8.  
    9.  
    10. @Override
    11. public void run() {
    12. //Set nametag RED
    13. }
    14.  
    15. }, 250L);
    16. }
    17.  
     
  22. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

  23. Offline

    MOMOTHEREAL

    Hey, I was wondering why my players are all Steves when I change their name color?
    How my code works is that players get their PlayerListName as their name tag, which works fine except they lose their skin.
    This is my TagAPI handler:
    Code:java
    1. /**
    2. * Handles TagAPI events
    3. */
    4. public class TagListener implements Listener {
    5. /**
    6.   * Fires when a player receives a name-tag from another player
    7.   */
    8. @EventHandler
    9. public void tagListen(AsyncPlayerReceiveNameTagEvent event) {
    10. event.setTag(event.getNamedPlayer().getPlayerListName());
    11. }
    12. }

    and this is how I set the Player List Name:
    Code:java
    1. player.setPlayerListName("§b§l" + player.getName());
    2. /* This is pseudo-code, I removed the parts where I trim the name in case it's too long*/

    Note that the account I tested on didn't need to trim, so the player name is the same.
    Also, I tried checking if the player name wasn't adding some messy stuff using a simple debug line:
    Code:java
    1. Player player = (Player) commandSender;
    2. player.sendMessage("[" + player.getPlayerListName().replace("§", "&" ) + "]");

    But it outputs it correctly without any extra spaces or trimed text:
    Code:
    [&b&lMOMOTHEREAL]
    I get no errors in my console, and I use CraftBukkit 1.7.10 with TagAPI v3.0.6.

    I know this pretty long, but I hope I can get some help!
    Thanks, Momo.
     
  24. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    In 1.7.10 there's no way to have anything but Steves without risking kicking players or other issues.

    If you just want to color usernames, use the Scoreboard API instead. Check the Bukkit javadocs.
     
  25. Offline

    MOMOTHEREAL

    mbaxter
    Hmm, interesting. What about if I want to change a player's list name, then I can't use the ScoreboardAPI? I've seen many servers that have colored names and are able to change a player's name, and they keep their skins (when using their right name)... while running 1.7.10!
    EDIT: Nevermind, got it: use Scoreboard for non-diguised players, then use TagAPI if disguised!
     
  26. Offline

    Barinade

    Use a map with uuid as key and boolean as value, set to true in the code you have there, refresh nametags after, and in the nametag receive event add a check for that map, if true change to red
     
  27. Offline

    Jumpingpea

    What are the commands, and how do I have players names?
     
  28. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    There are no commands.
     
  29. Offline

    Jumpingpea

    how do i give players different names then?
     
  30. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    Assuming TagAPI development weren't dead, you'd write a plugin that uses it :)
     
    nverdier likes this.
Thread Status:
Not open for further replies.

Share This Page