Exceptionflug / protocolize

A lightweight BungeeCord / Velocity protocol framework supporting items
MIT License
298 stars 38 forks source link

OpenWindow packet fail when handling Inventory for Minecarts and Boats #251

Closed miszastp closed 3 months ago

miszastp commented 3 months ago

Describe the bug When the plugin listens for packet OpenWindow. Is unable to parse packet when Player trying to open a inventory of Minecart (chest/hopper) or any Boat (chest) Then kicking him from serwer.

To Reproduce Steps to reproduce the behavior:

  1. Setup a Velocity proxy, and create simple packet listener for OpenWindow
Protocolize.listenerProvider().registerListener(new OpenWindowListener(OpenWindow.class, Direction.UPSTREAM, 0));

And declare even empty

    @Override
    public void packetSend(PacketSendEvent<OpenWindow> packetSendEvent) {
    }
  1. When on conected serwer, try open to inventory of Minecart (chest/hopper) or any Boat (chest) in game
  2. You will be kicked from a server.
  3. Error when you have enabled -Dvelocity.packet-decode-logging=true
[10:06:58] [Netty epoll Worker #0/ERROR] [com.velocitypowered.proxy.connection.MinecraftConnection]: [server connection] misza -> mapper: exception encountered in com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler@7bd25544
io.netty.handler.codec.CorruptedFrameException: Error decoding class dev.simplix.protocolize.velocity.packets.GeneratedOpenWindowWrapper Direction CLIENTBOUND Protocol 1.20.5 State PLAY ID 33
at com.velocitypowered.proxy.protocol.netty.MinecraftDecoder.handleDecodeFailure(MinecraftDecoder.java:130) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at com.velocitypowered.proxy.protocol.netty.MinecraftDecoder.tryDecode(MinecraftDecoder.java:85) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at com.velocitypowered.proxy.protocol.netty.MinecraftDecoder.channelRead(MinecraftDecoder.java:60) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:509) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
at java.base/java.lang.Thread.run(Thread.java:1583) [?:?]
Caused by: io.netty.handler.codec.CorruptedFrameException: Protocolize is unable to read packet dev.simplix.protocolize.data.packets.OpenWindow at protocol version 1.20.5 in direction CLIENTBOUND
at dev.simplix.protocolize.velocity.packet.VelocityProtocolizePacket.decode(VelocityProtocolizePacket.java:65) ~[?:?]
at com.velocitypowered.proxy.protocol.netty.MinecraftDecoder.tryDecode(MinecraftDecoder.java:83) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
... 28 more
Caused by: java.lang.RuntimeException: Unexpected NBT tag type while converting: net.querz.nbt.tag.IntArrayTag
at dev.simplix.protocolize.velocity.util.AdventureNbtToQuerzNbtMapper.querzToAdventure(AdventureNbtToQuerzNbtMapper.java:136) ~[?:?]
at dev.simplix.protocolize.velocity.util.AdventureNbtToQuerzNbtMapper.querzToAdventure(AdventureNbtToQuerzNbtMapper.java:104) ~[?:?]
at dev.simplix.protocolize.velocity.util.AdventureNbtToQuerzNbtMapper.querzToAdventure(AdventureNbtToQuerzNbtMapper.java:104) ~[?:?]
at dev.simplix.protocolize.velocity.util.AdventureNbtToQuerzNbtMapper.querzToAdventure(AdventureNbtToQuerzNbtMapper.java:104) ~[?:?]
at dev.simplix.protocolize.velocity.providers.VelocityComponentConverterProvider$AdventureComponentConverter.fromNbt(VelocityComponentConverterProvider.java:67) ~[?:?]
at dev.simplix.protocolize.velocity.providers.VelocityComponentConverterProvider$AdventureComponentConverter.fromNbt(VelocityComponentConverterProvider.java:27) ~[?:?]
at dev.simplix.protocolize.api.chat.ChatElementImpl.ofNbt(ChatElementImpl.java:30) ~[?:?]
at dev.simplix.protocolize.api.chat.ChatElement.ofNbt(ChatElement.java:24) ~[?:?]
at dev.simplix.protocolize.data.packets.OpenWindow.read(OpenWindow.java:102) ~[?:?]
at dev.simplix.protocolize.velocity.packet.VelocityProtocolizePacket.decode(VelocityProtocolizePacket.java:56) ~[?:?]
at com.velocitypowered.proxy.protocol.netty.MinecraftDecoder.tryDecode(MinecraftDecoder.java:83) ~[velocity-3.3.0-SNAPSHOT-411.jar:3.3.0-SNAPSHOT (git-a4476253-b411)]
... 28 more
[10:06:58] [Netty epoll Worker #0/INFO] [com.velocitypowered.proxy.connection.MinecraftConnection]: [server connection] misza -> mapper has disconnected

Expected behavior That protocolise will handle inventory Packets for Minecarts and Boats. And don't kick a player.

Proxy environment Velocity 3.3.0 Protocolize 2.4.0

Minecraft versions used Client: Java 1.20.6, 1.21 Server: Java 1.20.6, 1.21

miszastp commented 3 months ago

issue no longer exist on Protocolize 2.4.1:1130