Paper
Paper copied to clipboard
Fix players are invisible after using setPlayerProfile
Fixes #9061
I am not sure this is the proper solution to fix the issue, but after changing an existing online player's profile using #9061 reproduction code the player appeared to others.
It's probably best that we document that the player's uuid won't be swapped, only their name and gameprofile properties..
Shouldn't the profile you set have the same UUID? I'm not quite understanding what the issue is I guess. I would assume as an api consumer setting the game profile to have a different UUID would do some wacky stuff.
Well, it's previously supported setting a separate uuid. Should we enforce an exception or something if there is a uuid mismatch?
I feel like an exception is better if those are the options. But there probably is a use case for changing the UUID, so isn't it on plugins to ensure that stuff is the same?
But there probably is a use case for changing the UUID, so isn't it on plugins to ensure that stuff is the same?
Yes, we're only changing the UUID to the new profile's id during the update player info packet is being sent and changing back to the original to allow for plugins to retrieve the same player with the changed profile properties.
Or I thought another solution would be to not change the entire gameprofile on player, but only the skin and other properties, with the exception of the name and UUID.
But this most likely requires adding extra packets to actually update player's name in game without affecting plugins which uses this.
I think an exception is better here. Especially with the cryptographically signed messages, it's rather tricky since that is dependent on the uuid of the player entity. And at least currently, it doesn't seem as easy to change the uuid anymore for other players while supporting all of that.
In this case the Server#createProfile(String) method should be marked as @Obsolete or @Deprecated because the UUID must match every time with the current player to avoid the exception if it not matches.
So basically I added this condition into setPlayerProfile impl in which if the UUID not matches it will throws this exception
if (!self.getUUID().equals(gameProfile.getId())) {
throw new IllegalStateException("The UUID of player does not matches");
}
Let me know this is what you want.
Just a side note, the warning log message which coming from the client Server attempted to add player prior to sending player info can not be caught via server.
Updated to 1.20 and resolved conflicts
Edit: Also updated to 1.20.1