In the UserStorageService, there’s a method to get a User by UUID or String. Note that User is both at the same time a Player and can be an offline Player’s data representation.
if I’m trying to get a User, who wasn’t online at all. The UserStorageService.getUser(String name) fails to get an User. And the resulting Optional isn’t present.
I stumbled over another Method in the UserStorageService class: getOrCreate(GameProfile arg0)
But I don’t know how to initialize a new GameProfile Object.
When I could create this new GameProfile, i could easily get the UUID by: GameProfile.getUniqueID()
This doesn’t work for me. It says that I have to provide java.lang.Class<T> instead of java.lang.Class<org.spongepowered.api.service.user.UserStorageService>
Make sure your uuid object is in fact an instance of UUID and not String because the get(String) searches by name not UUID.
If uuid is a string, just do UUID.fromString(uuid);
OK, are you sure the player UUID actually existed on the server? The service will look for known players (those who have player data in the playerdata folder), players on the whitelist and players on the ban list.
Weird. it just just throws a NullPointerException no matter whether the playerdata exists or not. Does it matter where the UserStorageService is being initialized? (post- or pre- GameInitialization etc.)