[1.19.3/4] Unable to get ProfilePublicKey to create new RemoteChatSessionData
ineanto opened this issue ยท 8 comments
Make sure you're doing the following
- You're using the latest build for your server version
- This isn't an issue caused by another plugin
- You've checked for duplicate issues
- You didn't use
/reload
Describe the question
How do I correctly initialize player's ChatSession data after an INITIALIZE_CHAT?
API method(s) used
WrappedProfilePublicKey#ofPlayer(player)#getKeyData()
Expected behavior
Shouldn't throw an error.
Code
final WrappedGameProfile gameProfile = WrappedGameProfile.fromPlayer(player).withName(displayName);
[...]
final WrapperPlayerServerPlayerInfo update = new WrapperPlayerServerPlayerInfo();
update.setActions(EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.INITIALIZE_CHAT,
EnumWrappers.PlayerInfoAction.UPDATE_LISTED,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY));
update.setData(ImmutableList.of(new PlayerInfoData(
player.getUniqueId(),
player.getPing(),
true,
EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()),
gameProfile,
WrappedChatComponent.fromText(displayName),
new WrappedRemoteChatSessionData(UUID.randomUUID(),
WrappedProfilePublicKey.ofPlayer(player).getKeyData())
)));
What happens
Caused by: java.lang.IllegalArgumentException: Unable to find a field "null" with the type class net.minecraft.world.entity.player.ProfilePublicKey in class net.minecraft.world.entity.player.EntityHuman
Additional context
ProtocolLib v5.1.0-SNAPSHOT-645
My plugin is the only plugin running along with PlaceholderAPI.
Hello, thank you for your kind response and your time.
However, the build you provided doesn't seem to fix the issue.
Here's the updated code:
[...]
update.setData(ImmutableList.of(new PlayerInfoData(
player.getUniqueId(),
player.getPing(),
true,
EnumWrappers.NativeGameMode.fromBukkit(player.getGameMode()),
gameProfile,
WrappedChatComponent.fromText(displayName),
WrappedRemoteChatSessionData.fromPlayer(player)
)));
I tested with and without INITIALIZE_CHAT. Both kick the client with the famous "Chat message validation failure".
Where exactly do you call this? When I tested the code, I found out that the Chat Session is not available yet in the PlayerJoinEvent. In this case, try delaying dverything by a tick
Also I think you can no longer change the name in the GameProfile as of 1.19.3. Maybe try setting the chat session data in the packet to null.
Hi,
I think this method has not been updated for 1.19.3/1.19.4 compatibility yet. Please try this version: https://github.com/lukalt/ProtocolLib/actions/runs/5003003724 and use WrappedRemoteChatSessionData.fromPlayer(player)
instead of new WrappedRemoteChatSessionData(UUID.randomUUID(), WrappedProfilePublicKey.ofPlayer(player).getKeyData())
if possible
Where exactly do you call this? When I tested the code, I found out that the Chat Session is not available yet in the PlayerJoinEvent. In this case, try delaying dverything by a tick
This is called by a command, so long after the player has joined.
Also I think you can no longer change the name in the GameProfile as of 1.19.3. Maybe try setting the chat session data in the packet to null.
Hmm. Setting the Chat Session data to null also causes the client to be kicked upon chatting. This is sooo annoying I might just consider dropping the support for 1.19.3/4 altogether for the time being...
Yeah, I know that this super tricky and I spent lots of time getting this sorted. Try removing the signature from outgoing chat packets:
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(<plugin>, PacketType.Play.Server.CHAT) {
@Override
public void onPacketSending(PacketEvent event) {
event.getPacket().getMessageSignatures().write(0, null);
}
});
Yeah, I know that this super tricky and I spent lots of time getting this sorted. Try removing the signature from outgoing chat packets:
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(<plugin>, PacketType.Play.Server.CHAT) { @Override public void onPacketSending(PacketEvent event) { event.getPacket().getMessageSignatures().write(0, null); } });
Same result. I'm really sorry I'm bothering you with those questions. For the time being, I've found a solution: installing NoEncryption solves the issue by entirely removing message signature.
Install NoEncryption fixes the issue for the time being.