UUID Question

Discussion in 'Plugin Development' started by Quantum64, Apr 29, 2014.

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

    Quantum64

    So I want to have a command that takes a user's name as an argument. Say /somecommand [User Name]

    Now I need to get the UUID of that user's name to store in SQL, but how do I go about that without using Bukkit's temporary "hack" that allows that to happen.
     
  2. Offline

    thecrystalflame

  3. Offline

    desht

    If the player's online when you're running /somecommand, then Bukkit.getPlayer(playerName) will work fine (currently marked as deprecated, but it's still a valid thing to do). Once you have the Player object, you can get the UUID very simply with player.getUniqueId().

    If the player is offline, it's a bit harder. evilmidget38's UUIDFetcher class may be helpful, but you will need to run it async (which given you just want the UUID for SQL storage, hopefully won't be too much of a problem).
     
    Quantum64 likes this.
  4. Offline

    1Rogue Retired Staff

    While slow, you can still use Bukkit.getOfflinePlayer(name), which will return null if they have never played before (might be more of a functionality you want).
     
  5. Offline

    Garris0n

    I don't remember it returning null, but maybe I'm wrong.

    Edit: People use it for scoreboards all the time, it can't possibly return null. It has a "hasPlayedBefore" method or something like that, though, IIRC.
     
  6. Offline

    Quantum64

    Thanks for the info desht
     
  7. Offline

    xTigerRebornx

  8. Offline

    1Rogue Retired Staff


    That's correct, thanks for the correction.
     
Thread Status:
Not open for further replies.

Share This Page