[Solved] Getting a User from UUID

I want to get a offline user from a UUID. I know it is possible after #580 update with UserStorage. Despite it being in the services folder, ServiceManager can not get it. So my actual question is how do i get UserStorage. Thanks again.

Edit: This is just a copy and paste from one of my post before, just so its all close together

Ok maybe im not making myself clear, so let me try explaining it in another way.

I have a players UUID who joined the server, I want to go into the local catch (Not online … thought that was implied because I had the UUID to start with) and I need a User … not a GameProfile. GameProfile does not store the last known location of a player, User does. SpongeAPI provides its plugin developers to access a interface called UserStorage. UserStorage allows plugin developers to get offline Users from Sponges local catch. I am struggling with finding out how to get the UserStorage. I have been searching for a solution for how to get this interface for some time now, but have failed. Any guidance would be appreciated.

Do you need the player or just their username?

I need the User interface for the player I have the UUID for. I know what you were going to suggest and GameProfile will not do

Source

Ok maybe im not making myself clear, so let me try explaining it in another way.

I have a players UUID who joined the server, I want to go into the local catch (Not online … thought that was implied because I had the UUID to start with) and I need a User … not a GameProfile. GameProfile does not store the last known location of a player, User does. SpongeAPI provides its plugin developers to access a interface called UserStorage. UserStorage allows plugin developers to get offline Users from Sponges local catch. I am struggling with finding out how to get the UserStorage. I have been searching for a solution for how to get this interface for some time now, but have failed. Any guidance would be appreciated.

You could get the location of the player when he quit the server. After you store that in a file.

UserStorage as it’s package describes, is a service.
Get an instance like so:

UserStorage storage = game.getServiceManager().provide(UserStorage.class).get()

Also, to note, Player extends User so if you have a Player object you can use it as a User object.

1 Like

OMG, i didnt import UserStorage when i tried it the first time XD. Thanks