JitseB / NPCLib

(Minecraft) NPCLib – Basic non-player character library.
MIT License
197 stars 49 forks source link

Unexpected Packet Problem After Implementing NPCLib. #147

Closed TheJavaHacker closed 3 years ago

TheJavaHacker commented 3 years ago

Describe the bug

Players are unable to connect to the Spigot-Side server after implementing NPCLib in my Survival Core.

NPCLib usage option NPCLib can be used in multiple ways, please provide the number corresponding to your usage option.

Didn't follow any of the examples.

NPCLib JAR name npclib-plugin-2.12-SNAPSHOT.jar

Server version E.g. CraftBukkit version git-Spigot-a1f2566-97b0057 (MC: 1.13.2) (Implementing API version 1.13.2-R0.1-SNAPSHOT) (use command /version)

CraftBukkit version git-Spigot-37d799b-3eb7236 (MC: 1.16.4) (Implementing API version 1.16.4-R0.1-SNAPSHOT)

To Reproduce Steps to reproduce the behavior: Snippet of the code: https://paste.md-5.net/abizufanoy.cs Error on BungeeCord side:

[TheJavaHacker] <-> ServerConnector [Survival] has connected
02:05:49 [SEVERE] [TheJavaHacker] <-> ServerConnector [Survival] - encountered exception: net.md_5.bungee.util.QuietException: Unexpected packet received during server login process!
19667b227472616e736c617465223a22
02:05:49 [INFO] [TheJavaHacker] <-> ServerConnector [Survival] has disconnected

No known error on Spigot console.

Expected behavior A clear and concise description of what you expected to happen.

NPCs should be created in their dedicated location & should be shown to players upon joining the server.

Screenshots If applicable, add screenshots to help explain your problem. Unable to provide. Didn't get very far.

Additional context Add any other context about the problem here.

JasperJH commented 3 years ago

I ran into the same issue last night and after playing around with the library a bit and putting the server into debug mode, I noticed that there is a NPE on this line.

This happens because the GameProfile that is present in the PacketLoginInStart does not actually contain an id and merely contains the name of the player that is trying to join (source). This was a recent change which was made with this commit. Using the latest release, which does not contain that commit, or changing the UUIDs to names again in the TinyProtocol class will fix your issue.

If I have the time I will create a PR to undo that change.

JitseB commented 3 years ago

So, the user joins and there is a name but no UUID. After all this time, they still managed to do that.

Ugh...

I will make sure to put the TinyProtocol on the right event, because I'm not planning on changing it back to names.

JitseB commented 3 years ago

I don't see why Minecraft made it that the username is the first info they send to the server. I will change it to where it uses the username for initial channel handling and then change it to the UUID when the user is 'fully' joined.

JitseB commented 3 years ago

Actually, I will keep it the way it was (with the names), it's only for when the player is online and not for permanent storage. Assuming there won't be developers changing the GameProfiles to have similar names, I don't expend any problems.

I'll be posting an update shortly. Closing issue.

JitseB commented 3 years ago

You may download the new pre-release here: https://github.com/MinecraftLibraries/NPCLib/releases/tag/2.12.1-SNAPSHOT I am currently deploying it to the Maven repo. Good day!