ProtocolLib

3M Downloads

ProblemWithTabList

kopolinka32 opened this issue ยท 1 comments

commented

[18:00:17] [Server thread/WARN]: [ProtocolLib] Loaded class net.kyori.adventure.text.Component from CHGuilds v1.0 which is not a depend or softdepend of this plugin.
[18:00:17] [Netty Server IO #1/ERROR]: Error receiving packet 48
java.lang.NullPointerException: Cannot invoke "java.util.Optional.isPresent()" because "optional" is null
at net.minecraft.network.PacketDataSerializer.a(PacketDataSerializer.java:240) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.network.protocol.game.ClientboundPlayerChatPacket.a(SourceFile:35) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.network.PacketEncoder.a(SourceFile:45) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.network.PacketEncoder.encode(SourceFile:14) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107) ~[netty-codec-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:709) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:792) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:702) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:120) ~[netty-codec-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWrite0(AbstractChannelHandlerContext.java:717) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeWriteAndFlush(AbstractChannelHandlerContext.java:764) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:790) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:758) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:1020) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:311) ~[netty-transport-4.1.77.Final.jar:4.1.77.Final]
at com.comphenix.protocol.injector.netty.channel.NettyChannelProxy.writeAndFlush(NettyChannelProxy.java:227) ~[?:?]
at com.comphenix.protocol.injector.netty.channel.NettyChannelProxy.writeAndFlush(NettyChannelProxy.java:233) ~[?:?]
at net.minecraft.network.NetworkManager.a(NetworkManager.java:227) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at net.minecraft.network.NetworkManager.lambda$7(NetworkManager.java:216) ~[spigot-1.19-R0.1-SNAPSHOT.jar:3539-Spigot-56be6a8-82f7574]
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174) [netty-common-4.1.77.Final.jar:4.1.77.Final]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167) [netty-common-4.1.77.Final.jar:4.1.77.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470) [netty-common-4.1.77.Final.jar:4.1.77.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:503) [netty-transport-4.1.77.Final.jar:4.1.77.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:995) [netty-common-4.1.77.Final.jar:4.1.77.Final]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) [netty-common-4.1.77.Final.jar:4.1.77.Final]
at java.lang.Thread.run(Thread.java:833) [?:?]

public List<PlayerInfoData> playerInfoDatas = new ArrayList<>();

@SneakyThrows
public void sendTabList(Player player) {

    MinecraftServer server = ((CraftServer)Bukkit.getServer()).getServer();
    WorldServer world = ((CraftWorld)Bukkit.getWorlds().get(0)).getHandle();
    GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "");

    PlayerInfoData playerInfoData = new PlayerInfoData(WrappedGameProfile.fromPlayer(player),
            0,
            EnumWrappers.NativeGameMode.SPECTATOR,
            WrappedChatComponent.fromText(""));

    playerInfoDatas.add(playerInfoData);


    ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();

    PacketContainer packetContainer = protocolManager.createPacket(PacketType.Play.Server.PLAYER_INFO);
    packetContainer.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER);
    packetContainer.getPlayerInfoDataLists().write(0, playerInfoDatas);

    protocolManager.sendServerPacket(player, packetContainer);

}
commented

Your code and the exceptions doesn't seem to be related, the exception is thrown while encoding a chat packet...