Alvin-LB / NameTagChanger

Library to be shaded into Bukkit Plugins to allow for modification of player name tags.
MIT License
31 stars 10 forks source link

Skin doesn't properly load when changing name. #6

Closed AxeVillager closed 6 years ago

AxeVillager commented 6 years ago

After changing nametag, other players don't see the outer layer of the skin of the player until the skin loads for them again. This can be fixed by reconnecting to the server or walking away and coming back, making the Minecraft client load the skin again. However, I would rather this was not needed. After changing name, I would like the player's skin to update properly without having to do anything else.

The code I am using is as following. I am using NameTagChanger's changePlayername(player, newName) method.

private void setNameTag(String name) {
    nameTagChanger.changePlayerName(player, name);
}

In the JavaDocs I am told it is not necessary to update the player by the use of the updatePlayer(player) method since changePlayerName(player, name) does that automatically. Even so, the skin is not updating properly.

I have tried to call the updatePlayer(player) method, to no avail. The skin still doesn't appear as it should.

The pictures below show this in action.

Axe_Villager stand ready to change name.

nametagchanger-issue-1-1

Axe_Villager changes name to "Name change". His skin now appears incomplete, the outer layer of the skin is not showing.

nametagchanger-issue-1-2

Axe_Villager reconnects to the server to force the other player's Minecraft client to load the skin. Now it appear as it should.

nametagchanger-issue-1-4 nametagchanger-issue-1-3

Tested on: Spigot 1.12.2, ProtocolLib 4.4.0-SNAPSHOT-b399 and NameTagChanger v1.1-SNAPSHOT.

Alvin-LB commented 6 years ago

Thank you for the well-documented report!

I managed to fix the issue. Turns out I had forgotten to write the DataWatcher when manually respawning players after their names changed on the ProtocolLib implementation. Download the latest version of 1.1-SNAPSHOT or run the command mvn clean -U install if you are using maven, and you should be good to go.

AxeVillager commented 6 years ago

Thank you so much, both for fixing the issue and responding so quickly! Truly marvelous!

Alvin-LB commented 6 years ago

Glad I could be of help!

AxeVillager commented 6 years ago

I apologize if this is not properly done. Because of little experience with GitHub I don't know if it is possible for you to open the issue now that you have closed it. I hesitate to create a new issue since I feel like the problem I encounter is very similar to what this issue is all about. Please excuse me if this is not handled correctly, I am willing to create a new issue if need be.

Even though the skin properly updates upon name change, the items the player is carrying and has equipped disappear when changing name. Identical to the original issue, the items appear invisible until the player is loaded anew by the Minecraft client.

Axe_Villager has armour and weapons equipped before changing name.

nametagchanger-issue-armour-1

The armour and weapons disappear upon name change. Axe_Villager does in fact still carry what he carried before, it is just not visible for the other player.

nametagchanger-issue-armour-2

Is it possible to make the items the player holds and carries reappear?

Tested on: Spigot 1.12.2, ProtocolLib 4.4.0-SNAPSHOT-b399 and NameTagChanger v1.1-SNAPSHOT (updated version).

Alvin-LB commented 6 years ago

Interesting. Like you say, the issue is quite similar to the previous one, so I think it might be a good idea to just reopen this issue (although I believe this issue is caused by something different in the code).

I'll see what I can do.

Alvin-LB commented 6 years ago

Turns out there is a whole separate packet for entity equipment. I have now fixed it so it gets sent when manually respawning the players.

Redownload the latest version of 1.1-SNAPSHOT and you should no longer have the issue.

AxeVillager commented 6 years ago

Now the outer skin layer, weapons and armour update as it should. However, it introduced a new issue: When a player changes name while other players are online, the other players are kicked from the server.

In the server's console, no stacktrace is sent apart from a sign of null pointer exceptions java.lang.NullPointerException, two for each player kicked, without any other information.

image

The picture below displays the exception in Minecraft a player receives upon being kicked when a player changes name.

nametagchanger-issue-3-1

In case it is needed, here is that same Internal Exception in text form:

Internal Exception: io.netty.handler.codec.DecoderException: 
java.lang.IndexOutOfBoundsException: readerIndex(4) + length(2) exceeds 
writerIndex(4): PooledUnsafeDirectByteBuf(ridx: 4, widx: 4, cap: 4)

I thought perhaps this was caused by something that wasn't related to the plugin, so I did some tests to investigate its behaviour:

For all the tests I ran, the issue stopped only when I disabled the plugin. Therefore I reason it is in fact the plugin RolePlayName that is using NameTagChanger v1.1-SNAPSHOT and ProtocolLib 4.4.0-SNAPSHOT-b399 that causes the issue.

Is this fixable?

Alvin-LB commented 6 years ago

Right, and this never happened before the most recent change that I made?

AxeVillager commented 6 years ago

Correct, this never happened before the most recent change that you made.

Alvin-LB commented 6 years ago

Turns out this is actually an issue with ProtocolLib. A method which says it never returns null returns null for ItemStacks with Material.AIR converted to CraftItemStacks.

I will report this in the ProtocolLib repository. In the mean time, I have pushed an update which will work around this error.

If there are no more problems, then we can fingers crossed close this issue.

AxeVillager commented 6 years ago

Wonderful! The problem is fixed and I haven't encountered any other issues as of now. It seems you can possibly close this once and for all. Thank you!

Alvin-LB commented 6 years ago

Great! I will now close this issue.

I have also reported the ProtocolLib issue in the ProtocolLib repo.