getting a killers display name

Discussion in 'Plugin Development' started by nitrousspark, Aug 15, 2012.

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

    nitrousspark

    im making a plugin that gives people money when they kill somebody. but when i type player killer = player.getKiller() it always outputs CraftPlayer(name=nitrousspark)
    i need just nitrousspark.

    help?
     
  2. Offline

    Courier

    getKiller().getName()

    EDIT: will get a NPE if killer is null.
    Should do this instead:
    Code:java
    1. Player killer = player.getKiller();
    2. if(killer == null)
    3. {
    4. //handle the error
    5. //this means there was no killer
    6. //the entity died from a non-player
    7. }
    8. else
    9. {
    10. doSomething(killer.getName());
    11. }
     
  3. Offline

    nitrousspark

    now im running into a new problem. i have permissions and when i do killer.getDisplayName() it puts [Owner]Nitrousspark
     
  4. Offline

    ZeusAllMighty11

    GetDisplayName returns the CraftPlayer crap...

    GetName gets the name of the player, for instance

    player Kid

    getDisplayName() // returns CraftPlayer(Kid awiejfapwejfiwefjiawehafejhaowef~~~~)
    getName() // returns Kid
     
  5. Offline

    Don Redhorse

    ähmmm no, it is the other way around

    well, you are using a plugin to change the displayname... you would probably (depending on how your naming scheme is) cut off the first part of the string.

    this would only make sense if you keep that plugin private...

    an otherway would be to let the admin decide via the config what the delimiters are an cut that part off with regex.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 27, 2016
Thread Status:
Not open for further replies.

Share This Page