Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Fix players are invisible after using setPlayerProfile

Open montlikadani opened this issue 2 years ago • 9 comments

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.

montlikadani avatar Apr 16 '23 17:04 montlikadani

It's probably best that we document that the player's uuid won't be swapped, only their name and gameprofile properties..

Owen1212055 avatar Apr 16 '23 17:04 Owen1212055

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.

Machine-Maker avatar Apr 16 '23 18:04 Machine-Maker

Well, it's previously supported setting a separate uuid. Should we enforce an exception or something if there is a uuid mismatch?

Owen1212055 avatar Apr 16 '23 18:04 Owen1212055

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?

Machine-Maker avatar Apr 16 '23 18:04 Machine-Maker

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.

montlikadani avatar Apr 16 '23 20:04 montlikadani

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.

montlikadani avatar Apr 16 '23 20:04 montlikadani

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.

Owen1212055 avatar Apr 22 '23 17:04 Owen1212055

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.

montlikadani avatar Apr 22 '23 20:04 montlikadani

Updated to 1.20 and resolved conflicts

Edit: Also updated to 1.20.1

montlikadani avatar Jun 09 '23 17:06 montlikadani