Changeable names

Discussion in 'Plugin Development' started by Nogtail, Mar 7, 2014.

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


    So it seems that Mojang has confirmed that you will be able to change your username some time in the future and I have a few questions about it and how Bukkit will support it.

    Firstly, as usernames have been a popular way to uniquely identify players (perhaps the only way?) how will you be able to uniquely identify players without a constant username?

    Secondly, (this is assuming Mojang adds some form of unique id associated with each account) how will plugins that have been storing players by username switch to using whatever form of ID Mojang adds? Is it possible that they will let the ID be a name players pick when they create their account that cannot change (like the currant username)?

    Thanks in advance :)
  2. Offline


    Nogtail Bukkit has already implemented a system with unique UUID's that Mojang introduced.

    you can get that UUID with Player.getUniqueId();
  3. Offline


    spoljo666 Is there a way of getting a players UUID without the player being online so to convert databases that use the username to use the UUID?
  4. Offline


    Nogtail I don't think so, but there isn't much point of getting a list of players if most of them are not going to join again. If you implement a conversion feature now, by the time the changeable names is implemented, you should of converted most people over.
  5. Offline


    TopTobster5 I can also see other problems such as I am storing players bans under name and even if I can convert all the ones in the database to UUID I will still need to ban players which are offline. I would like to use their username in the command as I don't fancy typing out a large UUID every time I want to ban a player but I see this as a problem as their username could have changed by the time I ban them.
  6. Offline


    A solution would be to store the LastKnownPlayerName<->UUID mapping yourself for each player which connects to your server (I assume you don't ban players which didn't ever join your server in the past).
    So if you want to ban an offline player by name you go into your local database and search an uuid for that name.
    Note however that you might get multiple results if a player has changed his name (from X to Y), didn't yet connected to your server since that name change, and an other player changed his name as well to the other players old name (X) and connected to your server then.
    So maybe you might want to also store timestamps of their last connection as well so you can prefer banning the last user which connected with that name.
  7. Offline


    Yes. Mojang published an API for this.
    A plugin that utilizes this is here:
    But you need to query the UUID in a separate thread because the retrieval can take quite some time.
    The above mentioned plugin does not do this properly. So better not use it as-is, as it will lag your server.

    And be aware that the method "Player.getUniqueId()" will only return the UUID if the server runs in ONLINE mode.
    Otherwise it will return a checksum of the name which is useless.
    And also the Bukkit-Method "Player.getUniqueId()" will have "-" characters in it while the original Mojang UUID does not have those. So to be compatible, remove those "-" chars if using the Bukkit method.
Thread Status:
Not open for further replies.

Share This Page