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-04-12 21:14:06 +02:00
index e4f0949b6538734ff25daf68a428262481feeb81..754a2a5e958a04b3f8bf216b6022f547aa1cd36f 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
2024-04-12 21:14:06 +02:00
@@ -101,7 +101,15 @@ 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)
2024-01-15 12:38:39 +01:00
+ // Paper start - Prevent causing expired keys from impacting new joins
2024-04-12 21:14:06 +02:00
+ (buf, entry) -> {
+ RemoteChatSession.Data chatSession = entry.chatSession;
+ if (chatSession != null && chatSession.profilePublicKey().hasExpired()) {
+ chatSession = null;
+ }
+ buf.writeNullable(chatSession, RemoteChatSession.Data::write);
2023-04-03 11:45:02 +02:00
+ }
2024-01-15 12:38:39 +01:00
+ // Paper end - Prevent causing expired keys from impacting new joins
2024-04-12 21:14:06 +02:00
),
UPDATE_GAME_MODE((serialized, buf) -> serialized.gameMode = GameType.byId(buf.readVarInt()), (buf, entry) -> buf.writeVarInt(entry.gameMode().getId())),
UPDATE_LISTED((serialized, buf) -> serialized.listed = buf.readBoolean(), (buf, entry) -> buf.writeBoolean(entry.listed())),
2023-04-03 11:45:02 +02:00
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
2024-02-22 17:23:15 +01:00
index c9dab47fe3db73b31b40e071d37f1be63401c19d..69118af2a873f23f6543676db39263bfeb81b4f1 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-22 17:23:15 +01:00
@@ -3337,6 +3345,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);