JitseB / NPCLib

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

TinyProtocol crash when player logs in quickly #86

Closed hugovdev closed 4 years ago

hugovdev commented 4 years ago

Describe the bug I keep getting an error if someone joins just when the server started up. That player cant interact with NPCs, needs to log off and back in.

NPCLib usage option 1 (shaded into my plugin)

NPCLib JAR name E.g. npclib-plugin-2.7.1-SNAPSHOT.jar

Server version E.g. 1.8.8.R.02, custom tacospigot version

Expected behavior No crash

Screenshots No screenshot, but crash log

[17:10:59 ERROR]: Could not pass event PlayerLoginEvent to QuarkLobby v1.7.3
org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[Spigot.jar:git-TacoSpigot-"95870a93"]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[Spigot.jar:git-TacoSpigot-"95870a93"]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Spigot.jar:git-TacoSpigot-"95870a93"]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:486) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.PlayerList.attemptLogin(PlayerList.java:472) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:118) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:877) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:378) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:715) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:618) [Spigot.jar:git-TacoSpigot-"95870a93"]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_251]
Caused by: java.lang.NullPointerException
        at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(Unknown Source) ~[?:1.8.0_251]
        at sun.reflect.UnsafeQualifiedObjectFieldAccessorImpl.get(Unknown Source) ~[?:1.8.0_251]
        at java.lang.reflect.Field.get(Unknown Source) ~[?:1.8.0_251]
        at com.comphenix.tinyprotocol.Reflection$1.get(Reflection.java:153) ~[?:?]
        at com.comphenix.tinyprotocol.TinyProtocol.getChannel(TinyProtocol.java:264) ~[?:?]
        at com.comphenix.tinyprotocol.TinyProtocol.access$800(TinyProtocol.java:29) ~[?:?]
        at com.comphenix.tinyprotocol.TinyProtocol$5.onPlayerLogin(TinyProtocol.java:158) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_251]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_251]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_251]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300) ~[Spigot.jar:git-TacoSpigot-"95870a93"]
        ... 14 more
JitseB commented 4 years ago

This is something typical of TinyProtocol. It doesn't block players from joining the server before successfully injecting the channel handler. (Unlike ProtocolLib if I recall correctly).

I'll implement a check for this.

JitseB commented 4 years ago

I'll post an update with the included code in a bit.

If this issue does occur again, please don't hesitate to reopen this issue.