Development Assistance How to get the UUID of an offline player?

Discussion in 'Plugin Help/Development/Requests' started by ianjohnson315, Mar 29, 2015.

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

    ianjohnson315

    I'm making a cross server economy plugin that uses mysql. I am using UUIDs to store the amount of cubes (my currency) each player has. It was all working, then I realized I can't change or view the value of a player when their offline, because I was doing this by "String uuid = player.getUniqueId()" and this doesn't work for offline players. I have changed all the parameters of the functions to accept strings, and then changed the strings into offline players within each function, but I do not know how to get the UUID of a Bukkit.getOfflinePlayer. Would anyone be able to tell me how this is done?
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    ianjohnson315

    @timtower You can't do ".getUniqueId()" from an offline player.
     
  4. Offline

    timtower Administrator Administrator Moderator

  5. Offline

    ianjohnson315

    @timtower I'm doing it right now, the ".getUniqueId() only works if it's not an offline player. It comes up red if you do it.
     
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline

    ianjohnson315

    @timtower It says to add a cast to player. And then makes it ((Entity) player).getUniqueId().toString().

    Then when I try this out on the server, it gives a null pointer error.

    I should point out I'm using 1.6 bukkit because my server is on a modpack.

    Do you know of any way around this?

    <Edit by mrCookieSlime: Merged posts. Please don't triple post. There is an Edit Button right next to the Date.>
     
    Last edited by a moderator: Mar 29, 2015
  8. Offline

    Permeer

    @ianjohnson315 offlineplayer.getPlayer().getUniqueID().toString();
     
  9. Offline

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
    @ianjohnson315 Don't know if 1.6 already had offline players uuid, you could use names though, just tell the players to let you know when they change their names
     
  10. Offline

    ianjohnson315

    Thanks for all the help guys, I guess I will just have to make it so that it only works for online users.
     
Thread Status:
Not open for further replies.

Share This Page