2023-04-03 11:45:02 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Mon, 3 Apr 2023 08:55:52 +0100
Subject: [PATCH] Prevent causing expired keys from impacting new joins
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
2024-01-15 12:38:39 +01:00
index 0e54e8faa48751a651b953bec72543a94edf74bc..d43106eb89b14667e85cd6e8fa047d64f2e8ec87 100644
2023-04-03 11:45:02 +02:00
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
2023-09-22 18:11:35 +02:00
@@ -96,7 +96,13 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke
2023-04-03 11:45:02 +02:00
INITIALIZE_CHAT((serialized, buf) -> {
serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read);
}, (buf, entry) -> {
- buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write);
2024-01-15 12:38:39 +01:00
+ // Paper start - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
+ RemoteChatSession.Data chatSession = entry.chatSession;
+ if (chatSession != null && chatSession.profilePublicKey().hasExpired()) {
+ chatSession = null;
+ }
+ buf.writeNullable(chatSession, RemoteChatSession.Data::write);
2024-01-15 12:38:39 +01:00
+ // Paper end - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
}),
UPDATE_GAME_MODE((serialized, buf) -> {
serialized.gameMode = GameType.byId(buf.readVarInt());
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-02-05 12:31:51 +01:00
index 10c17dacef22caa4616e0f93e4004ca4e63b9af0..0bc974ff4124ff6bfc355a6dac362574a649c476 100644
2023-04-03 11:45:02 +02:00
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-02-01 10:15:57 +01:00
@@ -286,6 +286,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-12-06 17:21:56 +01:00
private int knownMovePacketCount;
2023-04-03 11:45:02 +02:00
@Nullable
private RemoteChatSession chatSession;
2024-01-15 12:38:39 +01:00
+ private boolean hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
private SignedMessageChain.Decoder signedMessageDecoder;
2023-12-06 17:21:56 +01:00
private final LastSeenMessagesValidator lastSeenMessages = new LastSeenMessagesValidator(20);
private final MessageSignatureCache messageSignatureCache = MessageSignatureCache.createDefault();
2024-02-01 10:15:57 +01:00
@@ -394,6 +395,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-04-03 11:45:02 +02:00
this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
}
2024-01-15 12:38:39 +01:00
+ // Paper start - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
+ if (!hasLoggedExpiry && this.chatSession != null && this.chatSession.profilePublicKey().data().hasExpired()) {
+ LOGGER.info("Player profile key for {} has expired!", this.player.getName().getString());
+ hasLoggedExpiry = true;
+ }
2024-01-15 12:38:39 +01:00
+ // Paper end - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
+
}
public void resetPosition() {
2024-02-05 12:31:51 +01:00
@@ -3333,6 +3341,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-04-03 11:45:02 +02:00
private void resetPlayerChatState(RemoteChatSession session) {
this.chatSession = session;
2024-01-15 12:38:39 +01:00
+ this.hasLoggedExpiry = false; // Paper - Prevent causing expired keys from impacting new joins
2023-04-03 11:45:02 +02:00
this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID());
2023-12-06 17:21:56 +01:00
this.chatMessageChain.append(() -> {
2023-04-03 11:45:02 +02:00
this.player.setChatSession(session);