feat: invalid chat session handle

This commit is contained in:
aro 2023-01-28 11:57:57 +01:00
parent fb05305d8d
commit 88f32ff954

View file

@ -95,17 +95,16 @@ public class v1_19_R2 implements Internals {
Collections.singletonList(serverPlayer)); Collections.singletonList(serverPlayer));
final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId())); final ClientboundPlayerInfoRemovePacket remove = new ClientboundPlayerInfoRemovePacket(List.of(player.getUniqueId()));
if (serverPlayer.getChatSession() == null) { RemoteChatSession chatSession;
NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is undefined.\n" +
"Nicko might fail at changing skins and even throw an error.\n" +
"Worse however, the player might get kicked when chatting.\n" +
"This is pretty rare however and this\n" +
"warning can be safely ignored in most cases.");
}
final UUID uuid = serverPlayer.getChatSession().sessionId(); if (serverPlayer.getChatSession() == null) {
final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey(); NickoBukkit.getInstance().getLogger().warning("Chat Session of " + serverPlayer.displayName + " is null!");
final RemoteChatSession newChatSession = new RemoteChatSession(uuid, ppk); chatSession = null;
} else {
final UUID uuid = serverPlayer.getChatSession().sessionId();
final ProfilePublicKey ppk = serverPlayer.getChatSession().profilePublicKey();
chatSession = new RemoteChatSession(uuid, ppk);
}
spoofPlayerInfoPacket(init, List.of(new ClientboundPlayerInfoUpdatePacket.Entry( spoofPlayerInfoPacket(init, List.of(new ClientboundPlayerInfoUpdatePacket.Entry(
player.getUniqueId(), player.getUniqueId(),
@ -114,7 +113,7 @@ public class v1_19_R2 implements Internals {
serverPlayer.latency, serverPlayer.latency,
serverPlayer.gameMode.getGameModeForPlayer(), serverPlayer.gameMode.getGameModeForPlayer(),
Component.literal(profileName), Component.literal(profileName),
newChatSession.asData() chatSession == null ? null : chatSession.asData()
))); )));
Bukkit.getOnlinePlayers().forEach(online -> { Bukkit.getOnlinePlayers().forEach(online -> {