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
2023-12-06 17:21:56 +01:00
index 0e54e8faa48751a651b953bec72543a94edf74bc..aa1c6de4d6cb7bbca33d25895c54707d220ab62a 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);
+ // 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
2023-12-06 18:47:45 +01:00
index d7312956b1d8620ac3c86684061010ca195f5a02..4da0e937c18b0113d4f798233395dd7ea04d077c 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
2023-12-06 17:21:56 +01:00
@@ -287,6 +287,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private int knownMovePacketCount;
2023-04-03 11:45:02 +02:00
@Nullable
private RemoteChatSession chatSession;
+ private boolean hasLoggedExpiry = false; // Paper
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();
@@ -396,6 +397,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
}
+ // 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() {
2023-12-06 17:21:56 +01:00
@@ -3422,6 +3430,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2023-04-03 11:45:02 +02:00
private void resetPlayerChatState(RemoteChatSession session) {
this.chatSession = session;
+ this.hasLoggedExpiry = false; // Paper
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);