BGHDDevelopment / PlayerBalancer

The repository for the plugin PlayerBalancer
https://www.spigotmc.org/resources/55011/
MIT License
28 stars 24 forks source link

NPE when switching server #38

Closed Koora7334 closed 11 months ago

Koora7334 commented 12 months ago

Hello, I have a bug with the latest version of the plugin, and with the latest Waterfall / Bungeecord version. I got this error everytime a player is switching from servers.

[11:00:48 WARN]: Error dispatching event ServerKickEvent(cancelled=true, player=ExTraZz_, kickedFrom=BungeeServerInfo(name=freebuild, socketAddress=/172.18.0.1:32123, restricted=true), reason=TextComponent{text=Proxy lost connection to server., BaseComponent(color=, font=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, insertion=null, extra=null, clickEvent=null, hoverEvent=null, reset=true)}, cancelServer=BungeeServerInfo(name=lobby1, socketAddress=/172.18.0.1:32456, restricted=false), state=CONNECTED, cause=LOST_CONNECTION) to listener com.jaimemartz.playerbalancer.listeners.ServerKickListener@3fe46690 java.lang.NullPointerException: null at net.md_5.bungee.netty.ChannelWrapper.getEncodeProtocol(ChannelWrapper.java:51) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.UserConnection.sendPacketQueued(UserConnection.java:195) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:565) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:511) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:499) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at com.jaimemartz.playerbalancer.utils.MessageUtils.send(MessageUtils.java:13) ~[?:?] at com.jaimemartz.playerbalancer.utils.MessageUtils.send(MessageUtils.java:22) ~[?:?] at com.jaimemartz.playerbalancer.listeners.ServerKickListener$1.connect(ServerKickListener.java:78) ~[?:?] at com.jaimemartz.playerbalancer.connection.ConnectionIntent.execute(ConnectionIntent.java:54) ~[?:?] at com.jaimemartz.playerbalancer.listeners.ServerKickListener.onKick(ServerKickListener.java:90) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_312] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_312] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_312] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_312] at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.event.EventBus.post(EventBus.java:50) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:467) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.connection.DownstreamBridge.disconnected(DownstreamBridge.java:129) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at net.md_5.bungee.netty.HandlerBoss.channelInactive(HandlerBoss.java:61) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:81) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:411) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[bungeecord.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:13cda1d:unknown] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]

BGHDDevelopment commented 12 months ago

So it seems like Bungeecord pushed a fix for this https://github.com/SpigotMC/BungeeCord/issues/3527

I will see if I can take a look at this soon, though I am a bit overwhelmed at the moment. Is the player still switching servers? Just throwing an error?

BGHDDevelopment commented 11 months ago

Just tested and had some others with the latest BungeeCord build and cannot reproduce. Can you try and re-download the latest version of your bungeecord?

BGHDDevelopment commented 11 months ago

No response. Please re-open if this is still an issue on the latest BC builds.

TheBloom46 commented 11 months ago

I'm a relatively novice programmer, but I wanted to share a fix that resolves this issue.

In MessageUtils Change this (Line 13):

sender.sendMessage(TextComponent.fromLegacyText(text));

to this

` try { sender.sendMessage(TextComponent.fromLegacyText(text)); } catch (Exception ignored) {

        }`

I don't believe I can publish a pull request to this repo, so please excuse the crude formatting above. f you have any concerns, I'd be open to hearing them!

Koora7334 commented 8 months ago

Hello, I have the same problem with the latest version, still not fixed :(

[21:43:30 WARN]: Error dispatching event ServerKickEvent(cancelled=true, player=xXaypirrXx, kickedFrom=BungeeServerInfo(name=freebuild, socketAddress=/172.18.0.1:32123, restricted=true), reason=TextComponent{text=Proxy lost connection to server., BaseComponent(color=, font=null, bold=null, italic=null, underlined=null, strikethrough=null, obfuscated=null, insertion=null, extra=null, clickEvent=null, hoverEvent=null, reset=true)}, cancelServer=BungeeServerInfo(name=lobby1, socketAddress=/172.18.0.1:32456, restricted=false), state=CONNECTED, cause=LOST_CONNECTION) to listener com.jaimemartz.playerbalancer.listeners.ServerKickListener@36224f93 java.lang.NullPointerException: Cannot invoke "net.md_5.bungee.protocol.MinecraftEncoder.getProtocol()" because the return value of "io.netty.channel.ChannelPipeline.get(java.lang.Class)" is null at net.md_5.bungee.netty.ChannelWrapper.getEncodeProtocol(ChannelWrapper.java:51) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.UserConnection.sendPacketQueued(UserConnection.java:195) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:565) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:511) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.UserConnection.sendMessage(UserConnection.java:499) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at com.jaimemartz.playerbalancer.utils.MessageUtils.send(MessageUtils.java:13) ~[?:?] at com.jaimemartz.playerbalancer.utils.MessageUtils.send(MessageUtils.java:22) ~[?:?] at com.jaimemartz.playerbalancer.listeners.ServerKickListener$1.connect(ServerKickListener.java:75) ~[?:?] at com.jaimemartz.playerbalancer.connection.ConnectionIntent.execute(ConnectionIntent.java:54) ~[?:?] at com.jaimemartz.playerbalancer.listeners.ServerKickListener.onKick(ServerKickListener.java:88) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] at net.md_5.bungee.event.EventHandlerMethod.invoke(EventHandlerMethod.java:19) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.event.EventBus.post(EventBus.java:50) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.api.plugin.PluginManager.callEvent(PluginManager.java:467) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.connection.DownstreamBridge.disconnected(DownstreamBridge.java:130) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at net.md_5.bungee.netty.HandlerBoss.channelInactive(HandlerBoss.java:61) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:81) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.handler.timeout.IdleStateHandler.channelInactive(IdleStateHandler.java:277) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:303) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:411) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:376) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:305) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:274) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1405) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:301) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:281) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:901) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.AbstractChannel$AbstractUnsafe$7.run(AbstractChannel.java:813) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:173) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:166) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:413) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[waterfall.jar:git:Waterfall-Bootstrap:1.20-R0.2-SNAPSHOT:7a4b282:unknown] at java.lang.Thread.run(Thread.java:840) [?:?]

BGHDDevelopment commented 8 months ago

Unfortunately I cannot reproduce the error on my end. Are you on the latest waterfall or bungee version?

Koora7334 commented 7 months ago

I was on the latest, but just switched to Velocity, and now I'm no longer using your plugin because Velocity has an auto switching on kick system. Thanks for your plugin, It was used on a 1000+ players network :)