aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0952-Prevent-causing-expired-keys-from-impacting-new-join.patch
blob: 85153d77d038b038753669034b6cb36d71e48143 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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
index 23e0e6937e28f09271a4ec7c35e0076a576cf3d3..4aa8b483841028fbcc43f9ed47730881263e5065 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundPlayerInfoUpdatePacket.java
@@ -94,7 +94,13 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke
         INITIALIZE_CHAT((serialized, buf) -> {
             serialized.chatSession = buf.readNullable(RemoteChatSession.Data::read);
         }, (buf, entry) -> {
-            buf.writeNullable(entry.chatSession, RemoteChatSession.Data::write);
+            // Paper start
+            RemoteChatSession.Data chatSession = entry.chatSession;
+            if (chatSession != null && chatSession.profilePublicKey().hasExpired()) {
+                chatSession = null;
+            }
+            buf.writeNullable(chatSession, RemoteChatSession.Data::write);
+            // Paper end
         }),
         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
index d00d003b29d357fbd80304acc50ca13c9f5393f5..d9c2d06ae24dcf80a497e75f4c7f63d401b77f9b 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -296,6 +296,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
     private final AtomicReference<Instant> lastChatTimeStamp;
     @Nullable
     private RemoteChatSession chatSession;
+    private boolean hasLoggedExpiry = false; // Paper
     private SignedMessageChain.Decoder signedMessageDecoder;
     private final LastSeenMessagesValidator lastSeenMessages;
     private final MessageSignatureCache messageSignatureCache;
@@ -436,6 +437,13 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
             this.disconnect(Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
         }
 
+        // Paper start
+        if (!hasLoggedExpiry && this.chatSession != null && this.chatSession.profilePublicKey().data().hasExpired()) {
+            LOGGER.info("Player profile key for {} has expired!", this.player.getName().getString());
+            hasLoggedExpiry = true;
+        }
+        // Paper end
+
     }
 
     public void resetPosition() {
@@ -3601,6 +3609,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
 
     private void resetPlayerChatState(RemoteChatSession session) {
         this.chatSession = session;
+        this.hasLoggedExpiry = false; // Paper
         this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID());
         this.chatMessageChain.append((executor) -> {
             this.player.setChatSession(session);