1. Guest, as per the stickied thread, this forum has not been in use since 2014. All bugs and feature requests should be posted to JIRA.

Feature Implement Server.getUuid(String)

Discussion in 'Bugs & Feature Requests' started by ITr1ckst3rI, May 12, 2015.

  1. Returns the UUID from player name or display name.

    Bukkit.getServer.getPlayer(Bukkit.getServer.getUuid("MrJohn"));


    I am not sure how mojang is going to do character renaming, however if they still do not allow two people to have the same name then this method should work wonderfully.

    The main reason (I think) why people use Server.getPlayer() is to get the player object from arguments within the command. Usually display name or name. If you have the UUID (For getPlayer(UUID) ) already you most likely got it from Player().getUniqueId()); which means you already have the player object, so you wouldn't have to fetch it again. The only other cases (I can think of) would be 1) someone... wrote it out? or 2) it was stored and fetched.


    That or remove @Depreciated from Server().getPlayer :p
     
  2. Agree
     
  3. Unless it is a reference that you are only using while the player is online, anything you want to be persistent in storage should be referencing the UUID already. I don't see how getting the UUID by name would help unless you were updating something from usernames to UUID. If that is the case however, its a little too late, as name changes already happen.

    Anything that you need to reference by player that should be persistent across sessions should always be utilizing UUID's. I have a running database of every player that logs on to my server and their last known name and their UUID. This allows me to still use their name, and just look up what their stored UUID was. If they have logged on with a different name, then they will return as a player that is not found.
     
  4. Bingo. Mainly commands. /dosomethingwith Playername
    PlayerName - Get player object from name - get UUID from player object - Store UUID
    Also, Sever.GetPlayer(), means either offline or online player or JUST online players? If just online i think that would prove my point even better.
     
  5. But like I said.. you can easily counteract this by just storing a reference of UUID -> LastNameTheLoggedWith, which if you just have a simple onJoin event that updates this, it will always be up to date. Even if the player changes their name and you do something (like /ban somePlayer) and they try to change their name to 'anotherPlayer' it won't matter because you applied the changes with their UUID not their name.

    the problem with what you want.. is that you may be referencing a player that way that may no longer have ownership of that name. If I changed my name to 'iSmooch1' and then you ban 'iSmooch', for something I did, but another guy has already gotten that name, then you have just banned a player who was just in the wrong username at the wrong time. It would be accurate to store the names on your end, and then reference them so that way your 'Common Name' list is always referencing the players you want it to.
     
    • Useful Useful x 1
  6. Agreed. This puts a big hole in it. Unless it was only able to be used while the player was online and on the server, this pretty much throws it out the window. I agree with storing all the players uuid from onJoin but that's wasted memory if the players UUID is never used. (Big picture, Doesn't really matter to small servers)

    Whoops, forgot to mention storing them in memory not disk.
     
    #6 ITr1ckst3rI, May 12, 2015
    Last edited: May 12, 2015
  7. If you aren't already storing references for UUIDs to Names somewhere.. you are doing it wrong xD
     
  8. jflory7

    jflory7 Retired Moderator
    Retired Benefactor

    Thread moved => Bugs & Feature Requests
     
  9. me too
     
  10. Server#getPlayer(String) returns a player object (for offline players there is no Player object) for the player with the name matching the given string best.
    Server#getPlayerExact(String) is doing the same as Server#getPlayer(String), but just returns not null if there's a player with the exact name.

    These methods are just deprecated to get developers attention that names are changeable.

    Edit: More attention should be put on using Server#getOfflinePlayer(String)