bergerhealer / TrainCarts

Minecarts redefined
MIT License
205 stars 63 forks source link

All players will be kicked by server when trying editing a SignLink sign #476

Closed BiDuang closed 1 year ago

BiDuang commented 1 year ago

English is not my native language; please excuse typing errors.

Info

Please provide the following information:


Bug

Description

When trying to edit a SignLink sign, the server throws an exception like this:

[18:03:11 ERROR]: Packet encoding of packet ID 8 threw (skippable? false)
io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectArrayList.get(in
t)" because "this.wrapped" is null
        at net.minecraft.network.FriendlyByteBuf.writeNbt(FriendlyByteBuf.java:642) ~[?:?]
        at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.write(ClientboundBlockEntityDataPacket.java:43) ~[?:?]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:41) ~[paper-1.20.1.jar:git-Paper-20]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:14) ~[paper-1.20.1.jar:git-Paper-20]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.87.Final.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.87.Final
.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.87.Final.jar:4.1.87.Fina
l]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.87.Final
.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:115) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at com.bergerkiller.bukkit.common.internal.network.CommonPacketHandler$CommonChannelListener.write(CommonPacketHandler.java:132) ~[B
KCommonLib-1.20.1-v1-SNAPSHOT-1578.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:879) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.
87.Final.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.87.Fin
al.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.87.Fin
al.jar:4.1.87.Final]
        at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.87.Final.jar:4.1.87
.Final]
        at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at net.minecraft.network.Connection.doSendPacket(Connection.java:473) ~[?:?]
        at net.minecraft.network.Connection.lambda$sendPacket$11(Connection.java:447) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.87.Final.jar:4.1.87.Fin
al]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.87.Final.jar:4.1.87
.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.87.Final.ja
r:4.1.87.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.87.Final.jar:4.1.
87.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.87.Final.jar:4.1.87.Final]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectArrayList.get(int)" because "this.wrapped" is
null
        at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$MapIterator.nextEntry(Object2ObjectOpenHashMap.java:631) ~[fastutil-8.5.9.
jar:?]
        at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$KeyIterator.next(Object2ObjectOpenHashMap.java:1034) ~[fastutil-8.5.9.jar:
?]
        at net.minecraft.nbt.CompoundTag.write(CompoundTag.java:138) ~[?:?]
        at net.minecraft.nbt.NbtIo.writeUnnamedTag(NbtIo.java:280) ~[?:?]
        at net.minecraft.nbt.NbtIo.write(NbtIo.java:248) ~[?:?]
        at net.minecraft.network.FriendlyByteBuf.writeNbt(FriendlyByteBuf.java:640) ~[?:?]
        ... 31 more
[18:03:11 ERROR]: Packet encoding of packet ID 8 threw (skippable? false)
io.netty.handler.codec.EncoderException: java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectArrayList.get(in
t)" because "this.wrapped" is null
        at net.minecraft.network.FriendlyByteBuf.writeNbt(FriendlyByteBuf.java:642) ~[?:?]
        at net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket.write(ClientboundBlockEntityDataPacket.java:43) ~[?:?]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:41) ~[paper-1.20.1.jar:git-Paper-20]
        at net.minecraft.network.PacketEncoder.encode(PacketEncoder.java:14) ~[paper-1.20.1.jar:git-Paper-20]
        at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.87.Final.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.87.Final
.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:113) ~[netty-codec-4.1.87.Final.jar:4.1.87.Fina
l]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:881) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:863) ~[netty-transport-4.1.87.Final
.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:968) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:856) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.ChannelDuplexHandler.write(ChannelDuplexHandler.java:115) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at com.bergerkiller.bukkit.common.internal.network.CommonPacketHandler$CommonChannelListener.write(CommonPacketHandler.java:132) ~[B
KCommonLib-1.20.1-v1-SNAPSHOT-1578.jar:?]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:879) ~[netty-transport-4.1.87.Fina
l.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:940) ~[netty-transport-4.1.
87.Final.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:966) ~[netty-transport-4.1.87.Final.jar:4
.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:934) ~[netty-transport-4.1.87.Fin
al.jar:4.1.87.Final]
        at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:984) ~[netty-transport-4.1.87.Fin
al.jar:4.1.87.Final]
        at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1025) ~[netty-transport-4.1.87.Final.jar:4.1.87
.Final]
        at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:306) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at net.minecraft.network.Connection.doSendPacket(Connection.java:473) ~[?:?]
        at net.minecraft.network.Connection.lambda$sendPacket$11(Connection.java:447) ~[?:?]
        at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) ~[netty-common-4.1.87.Final.jar:4.1.87.Fin
al]
        at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) ~[netty-common-4.1.87.Final.jar:4.1.87
.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) ~[netty-common-4.1.87.Final.ja
r:4.1.87.Final]
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:569) ~[netty-transport-4.1.87.Final.jar:4.1.87.Final]
        at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) ~[netty-common-4.1.87.Final.jar:4.1.
87.Final]
        at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.87.Final.jar:4.1.87.Final]
        at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectArrayList.get(int)" because "this.wrapped" is
null
        at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$MapIterator.nextEntry(Object2ObjectOpenHashMap.java:631) ~[fastutil-8.5.9.
jar:?]
        at it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap$KeyIterator.next(Object2ObjectOpenHashMap.java:1034) ~[fastutil-8.5.9.jar:
?]
        at net.minecraft.nbt.CompoundTag.write(CompoundTag.java:138) ~[?:?]
        at net.minecraft.nbt.NbtIo.writeUnnamedTag(NbtIo.java:280) ~[?:?]
        at net.minecraft.nbt.NbtIo.write(NbtIo.java:248) ~[?:?]
        at net.minecraft.network.FriendlyByteBuf.writeNbt(FriendlyByteBuf.java:640) ~[?:?]
        ... 31 more

And then, each online player would be kicked by an exception.

Create a SignLink but not a TrainCarts sign won't be a problem, but if you make a SignLink sign, edit it into a TrainCarts' mode, there will be a big problem.

Steps to reproduce

  1. Create a sign assign with a variable.
  2. Edit the sign, make it becomes a TrainCarts sign.
  3. Save the changes, the server will throw an exception and all the online players will be kicked.

Additional Information

This issue was created using the /train issue command!

bergerkiller commented 1 year ago

And is SignLink the latest 1.20.1 version too?

BiDuang commented 1 year ago

And is SignLink the latest 1.20.1 version too?

I checked DevBuilds, looks like there's no 1.20.1's build. The latest build is SignLink-1.20-v1-SNAPSHOT-82.jar

bergerkiller commented 1 year ago

Yeah that one

BiDuang commented 1 year ago

Yeah that one

Ok, I will try it. Thanks.

bergerkiller commented 1 year ago

The only issue I see is that when editing a signlink sign with variables it shows the signlink-shown text instead of the original variables. Must be due to how the editing thing works client-side. No problems other than that / no errors

BiDuang commented 1 year ago

The only issue I see is that when editing a signlink sign with variables it shows the signlink-shown text instead of the original variables. Must be due to how the editing thing works client-side. No problems other than that / no errors

Yep, no expection shown again. But the varible becomes its text and sign won't save the changes.

For example, I made a normal sign like this: )E%T00DZY5D6$ S (0QTF{6

Save and open the editing dialog again, make it become a TrainCarts sign. 5GL59GKGA64VD(Y~_IA892T

TrainCarts received the change and respond correctly, but sign's text didn't change.

bergerkiller commented 1 year ago

I can maybe send a sign update when handling a player click to fix that. Dunno.

bergerkiller commented 1 year ago

https://ci.mg-dev.eu/job/SignLink/84/ this should fix these problems, it works, but unsure if its 100% reliable

bbayu123 commented 1 year ago

Closing as fixed. Next time file the issue in bergerhealer/SignLink as this is not related to TrainCarts.