Solved Player UUID

Discussion in 'Plugin Development' started by SuperOmegaCow, Jan 11, 2014.

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

    SuperOmegaCow

    Recently I have been making a global banning system, along the lines of McBans and after hearing about Mojang allowing people to change their name I have started using UUIDs. Only problem I need to get player UUIDs that are offline and it seems that this is the only option: https://github.com/Mojang/AccountsClient
    Only problem I have no idea how to get this to work.
     
  2. Offline

    Stealth2800

  3. Offline

    metalhedd

    I'm storing some data under player UUID's too. I've been doing it with a custom plugin which listens for new logins and stores a mapping of UUID->Player-Name and persists it to disk between server restarts, then I use that to look up offline players by UUID when I need to.
     
  4. Offline

    SuperOmegaCow

    metalhedd hmm I might try that with a little MySQL magic.

    Stealth2800 metalhedd another question, does the player.getUniqueId actually return the correct UUID?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
  5. Offline

    Stealth2800

    If the server is on online-mode: true, yes. If not, it returns a hash of the player's username.
     
  6. Offline

    SuperOmegaCow

    Last edited by a moderator: Jun 6, 2016
  7. Offline

    Maurdekye

    You do all know that you can just use Player.getUniqueId();, right?
     
  8. Offline

    SuperOmegaCow

    Maurdekye yes but... I want to be able to access UUIDs of offline players.
     
  9. Offline

    Maurdekye

    You could just store them in a text file after they log on.
     
  10. Offline

    metalhedd


    That can get you a players UUID, assuming the player is online, but it doesn't allow you to do the reverse lookup. (Player from UUID) even if the player is online bukkit doesn't provide a good way to look up a player by that UUID other than looping through all online players.
     
  11. Offline

    SuperOmegaCow

    Maurdekye but again, I want to access offline players UUIDs.
     
  12. Offline

    metalhedd


    That's exactly what my plugin does :) It stores the mapping of UUID->PlayerName in a yaml file and loads it into memory on startup so that I can always get a player, online or not, solely from their UUID (as long as they've logged in before)
     
  13. Offline

    Maurdekye

    Looping through the players is the only way to do it. There is no other, better workaround other than looping. It's not even very resource intensive (unless it gets called every tick in which case it always is pretty intensive). If at all you should reduce your dependency on third party sources as much as possible. If something on their side changes, and you don't change your side to reflect that, then your whole program is broken until you patch it.
     
  14. Offline

    SuperOmegaCow

  15. Offline

    RawCode

    when player joined game - store UUID in database.

    a bit unexpected but still obvious solution.
     
  16. Offline

    Maurdekye

    Well, i'm here to tell you that the way Bukkit does it is fine. And as much overhead as you would need working with it, it will always be more worth it than depending on a third party.
     
  17. Offline

    SuperOmegaCow

  18. Offline

    RawCode

    if you want to use mojang just use it, i give you my blessing. SuperOmegaCow
     
  19. Offline

    SuperOmegaCow

    RawCode thanks I think? but where can I find this JSON class.
     
  20. Offline

    RawCode

    its to dangerous to google alone, take this;
    import com.google.gson.Gson; SuperOmegaCow
     
  21. Offline

    jojodmo

    Just saying, I would recommend storing the user's UUID in a hashmap so that you don't have to get it from mojang's servers all the time - It's a lot faster.
     
  22. Offline

    SuperOmegaCow

    @jojodmo201
    This was solved a while ago.
     
Thread Status:
Not open for further replies.

Share This Page