ProtocolLib

3M Downloads

v5-SNAPSHOT | Could not find packet for type PLAYER_INFO

DasShorty opened this issue ยท 1 comments

commented
  • This issue is not solved in a development build

Describe the bug
The bug is thrown when i try to create a custom player info using the api

To Reproduce
Steps to reproduce the behavior:

  1. use the latest v5 dependecy from repo host
  2. send a PLAYER_INFO packet using ProtocolLib

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
image

Version Info
Provide your ProtocolLib install info with /protocol dump through pastebin.

Additional context
nothing

commented

Could you please share the whole stack trace of the error? Also, I do not think this is an issue of ProtocolLib and your code is outdated.
As of 1.19.4, the PLAYER_INFO packet only has two field:

  • A set of PlayerInfoActions (Index: 0)
  • A list of PlayerInfoData (Index: 1)

The correct code should be something like this:

PacketContainer container = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
container.getPlayerInfoActions().write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER, EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE, EnumWrappers.PlayerInfoAction.UPDATE_LATENCY, EnumWrappers.PlayerInfoAction.UPDATE_LISTED));
container.getPlayerInfoDataLists().write(1, List.of(
        new PlayerInfoData(WrappedGameProfile.fromPlayer(player), 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText("TestNPC"))
));
ProtocolLibrary.getProtocolManager().sendServerPacket(player, container);