ProtocolLib

3M Downloads

Error creating PlayerInfoData instance. / Usage of PlayerInfoAction.ADD_PLAYER / PLAYER_INFO Packet

Closed this issue ยท 4 comments

commented
  • This issue is not solved in a development build

Describe the bug
If I create an instance of PlayerInfoData, a Runtime exception drops saying: "Cannot find PlayerInfoData constructor", this prevents the usage of ADD_PLAYER. My exact same code works on JAVA 1.21.1 but not on JAVA 1.21.3.

To Reproduce
Steps to reproduce the behavior:

  1. Create a player_info packet
  2. write on field 0 to playerinfoactions ADD_PLAYER and UPDATE_LISTED
  3. write on playerinfodatalists field 1 new PlayerInfoData
    Expected behavior
    A clear and concise description of what you expected to happen.

Screenshots

    public void addPlayerToTablist(Player receiver, String name, UUID uuid, int ping) {
        ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();

        PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
        packet.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_LISTED));

        ArrayList<PlayerInfoData> value = new ArrayList<>();
        value.add(new PlayerInfoData(
                        new WrappedGameProfile(uuid, name),
                        ping,
                        EnumWrappers.NativeGameMode.SURVIVAL,
                        WrappedChatComponent.fromText(name)
                ));
        packet.getPlayerInfoDataLists().write(1, value);

        protocolManager.sendServerPacket(receiver, packet);
    }
[18:02:17 ERROR]: Could not pass event PlayerJoinEvent to IWTabListSyncBukkit v1.0.0-SNAPSHOT#4c1f8d8-dirty
java.lang.RuntimeException: Cannot find PlayerInfoData constructor.
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.PlayerInfoData$1.getGeneric(PlayerInfoData.java:236) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.PlayerInfoData$1.getGeneric(PlayerInfoData.java:205) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.BukkitConverters.getGenericList(BukkitConverters.java:309) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.BukkitConverters.access$100(BukkitConverters.java:97) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.BukkitConverters$3.getGeneric(BukkitConverters.java:376) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.BukkitConverters$3.getGeneric(BukkitConverters.java:368) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.Converters$1.getGeneric(Converters.java:57) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.reflect.StructureModifier.writeInternal(StructureModifier.java:360) ~[ProtocolLib.jar:?]
        at ProtocolLib.jar/com.comphenix.protocol.reflect.StructureModifier.write(StructureModifier.java:324) ~[ProtocolLib.jar:?]
        at IWTabListSyncBukkit-1.0.0-SNAPSHOT-1734627733175.jar/de.iwmedia.iwtablistsync.bukkit.listeners.PlayerJoinListener.addPlayerToTablist(PlayerJoinListener.java:45) ~[IWTabListSyncBukkit-1.0.0-SNAPSHOT-1734627733175.jar:?]
        at IWTabListSyncBukkit-1.0.0-SNAPSHOT-1734627733175.jar/de.iwmedia.iwtablistsync.bukkit.listeners.PlayerJoinListener.onEvent(PlayerJoinListener.java:53) ~[IWTabListSyncBukkit-1.0.0-SNAPSHOT-1734627733175.jar:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor156.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:77) ~[paper-api-1.21.3-R0.1-SNAPSHOT.jar:?]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:80) ~[paper-api-1.21.3-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:70) ~[paper-api-1.21.3-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperEventManager.callEvent(PaperEventManager.java:54) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.callEvent(PaperPluginManagerImpl.java:131) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:628) ~[paper-api-1.21.3-R0.1-SNAPSHOT.jar:?]
        at net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:350) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.network.ServerConfigurationPacketListenerImpl.handleConfigurationFinished(ServerConfigurationPacketListenerImpl.java:173) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:22) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.network.protocol.configuration.ServerboundFinishConfigurationPacket.handle(ServerboundFinishConfigurationPacket.java:13) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.network.protocol.PacketUtils.lambda$ensureRunningOnSameThread$0(PacketUtils.java:55) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.TickTask.run(TickTask.java:18) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.util.thread.BlockableEventLoop.doRunTask(BlockableEventLoop.java:154) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.util.thread.ReentrantBlockableEventLoop.doRunTask(ReentrantBlockableEventLoop.java:24) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:1578) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.doRunTask(MinecraftServer.java:207) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.util.thread.BlockableEventLoop.pollTask(BlockableEventLoop.java:128) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.pollTaskInternal(MinecraftServer.java:1555) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.pollTask(MinecraftServer.java:1548) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.util.thread.BlockableEventLoop.managedBlock(BlockableEventLoop.java:138) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.managedBlock(MinecraftServer.java:1499) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.waitUntilNextTick(MinecraftServer.java:1509) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1345) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:340) ~[paper-1.21.3.jar:1.21.3-81-da71382]
        at java.base/java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.NoSuchMethodException: net.minecraft.network.protocol.game.ClientboundPlayerInfoUpdatePacket$Entry.<init>(java.util.UUID,com.mojang.authlib.GameProfile,boolean,int,net.minecraft.world.level.GameType,net.minecraft.network.chat.Component,net.minecraft.network.chat.RemoteChatSession$Data)
        at java.base/java.lang.Class.getConstructor0(Class.java:3761) ~[?:?]
        at java.base/java.lang.Class.getConstructor(Class.java:2442) ~[?:?]
        at ProtocolLib.jar/com.comphenix.protocol.wrappers.PlayerInfoData$1.getGeneric(PlayerInfoData.java:234) ~[ProtocolLib.jar:?]
        ... 36 more

Version Info
https://pastebin.com/VZXDqG51

commented

Can you show how you imported ProtocolLib in your project ?

I tried your exact code with same ProtocolLib version and the code is working for me in MC version 1.21.4

commented

Hey, I am running it on 1.21.3 not 1.21.4

commented

If I test in version 1.21,4 - fresh Server setup - I get the same error.

<repositories>
    <repository>
        <id>dmulloy2-repo</id>
        <url>https://repo.dmulloy2.net/repository/public/</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.comphenix.protocol</groupId>
        <artifactId>ProtocolLib</artifactId>
        <version>5.3.0</version>
        <scope>provided</scope>
    </dependency>
</dependencies>
depend:
  - "ProtocolLib"

nothing is on compile, so I have no relocations.
I am running a minimal plugins setup containing only the dependents and protocollib.
However also the dependents do not use protocol-lib at all.

commented

Was running on ProtocolLib 5.3.0 updated from your "DEV-BUILDS" to 5.4.0.