v5-SNAPSHOT | Could not find packet for type PLAYER_INFO
DasShorty opened this issue ยท 1 comments
- 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:
- use the latest v5 dependecy from repo host
- send a PLAYER_INFO packet using ProtocolLib
Expected behavior
A clear and concise description of what you expected to happen.
Version Info
Provide your ProtocolLib install info with /protocol dump
through pastebin.
Additional context
nothing
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);