Residences dB does not make use of UUIDs
danthedaniel opened this issue ยท 10 comments
This means server administrators need to manually update the database when a user changes their name.
Hopefully just converted the residence owner part to use UUID's, I don't currently have a server set up to test with to see if it worked. Flags that are set are still using player names instead of UUID's so that code will have to be converted next.
Are you retroactively putting UUIDs in existing databases?
If there's an owner in a YAML file that's changed their name you won't really be able to resolve their current name because you don't have the epoch time from when they last logged in with their old name (as per the username --> UUID standard http://wiki.vg/Mojang_API).
You could scan through the entire /world/playerdata/*.dat and try to find if any of the UUIDs there were last logged in as the old username (["bukkit"]["lastKnownName"] in the NBT data).
Anyway, thanks for working on this! I'll test out your plugin when you've finalized the YAML database updates.
For converting the old way of storing player names into UUID's what I was trying to do was something like this:
Get the owner name from YAML,
Put it into Bukkit.getServer().getPlayer()
Call Player.getUniqueID()
I don't know if this will work (need to get a test server going again...), and I'm certain that it won't work for users who have already changed their name (as its using their old username) but I think it should convert user's who have not changed their name. Conversion is one time, once I have the UUID of the player, when the server next saves it will save the UUID of the owner in the YAML, and then it wont matter if they change their name anymore as they will always have the same UUID. Server owners may just have to fix the people who have already changed their names manually as I'm just not sure there is a reliable way to get the UUID from an old username (except doing as you said, and digging into the NBT data).
Well looking through the NBT data on a one-time upgrade basis isn't so bad IMO. But if that fails as well (which will happen if someone changes their name, logs in, then doesn't request their old residences) you could transfer ownership to the server and the user will then have to request ownership.
Yea, I already set it up so that if it fails to find the owner (if they already changed their name) the new owner UUID field gets set to a random UUID. Any getOwner() calls on that residence then return as "Server Land" at which point only an admin can fix it. :)
Got a test server working, so far saving and loading via UUID works fine, however converting from an old format failed... working on a solution hopefully...
Another possibility would be to use the mojang api, there you can ask for a time stamp and get back who had the name at the time stamp