Difference between getName(); and getDisplayName();

Discussion in 'Plugin Development' started by retsrif, Feb 26, 2011.

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

    retsrif

    That's all I want to know. Documentation doesn't help. Thanks :)
     
  2. Offline

    Plague

    IIRC getName returns the name used for everything internal, it's the player's D if you want (it is not, but look at it this way). Display name is used for chat.
     
  3. Offline

    retsrif

    So, as long as I don't do anything related to chat, and only use getName(); from events and use that consistently through the plugin, I should be safe right?
     
  4. Offline

    Plague

    I think so, I never used it for anything like it and my first thought would be if I could use entityID for that, but I think name is used via hasmaps or something.
     
  5. Offline

    retsrif

    I use getName() and store that as a string in an ArrayList, and then after another event, I use getName(); again and store it to a temporary string and see if the two strings match... Or is there a better way ?
     
  6. Offline

    Plague

    I don't really know, but I hate to use strings for identification, so I'd suggest trying to use entityID. Just store it on join at it could work? Maybe it gets changed on respawn, but then just store the name also and only test the string on respawn to set the entityID to a new value. But this way you'll be using IDs which is just a short number and not a long string, this more speed ;)
     
  7. Offline

    retsrif

    Can I get the ID of a person who right clicks on a block? Left clicks?
     
  8. Offline

    Edward Hand

    blockRightClickEvent.getPlayer().getEntityID()
     
  9. Offline

    Plague

    everywhere where you can get to player you should be able to get his entityID...
    Edit: ninja'd :)
     
  10. Offline

    retsrif

    Haha! Though, in onBlockInteract, I can't get to the player?
     
  11. Offline

    Edward Hand

    blockInteractEvent.getEntity().getEntityId()
     
  12. Offline

    retsrif

    I think I am getting more idiotic by the second. -.- Thanks :D
     
  13. Offline

    clash

    I wrote a personal plugin to support local nicknames. I set the nickname with setDisplayName(). It seems that chat messages use getDisplayName() as expected. However, I just installed HeroicDeath and it appears to use getName() -- hence the nickname is not shown in death messages. [​IMG]

    Since I am fairly new to the Bukkit API, I may be abusing setDisplayName for this purpose. Or am I?
     
Thread Status:
Not open for further replies.

Share This Page