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-25 00:36:49 +02:00
index 68c062cbaa030d62d97c9c003651f8fc17a00a6b..6247a21c9c391abf1f6db3482c659593e4f29355 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-25 00:36:49 +02:00
@@ -113,7 +113,15 @@ public class ClientboundPlayerInfoUpdatePacket implements Packet<ClientGamePacke
2024-04-12 21:14:06 +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
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-08-19 11:33:17 +02:00
index 6eee43f2005f4bc937f7411c17d431a3b95093c1..a5d7a1769ca0fd32427a98b2029b787b549831e5 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-04-25 23:21:18 +02:00
@@ -295,6 +295,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-04-25 23:21:18 +02:00
@@ -402,6 +403,13 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2024-06-14 10:17:11 +02:00
this.disconnect((Component) Component.translatable("multiplayer.disconnect.idling"), org.bukkit.event.player.PlayerKickEvent.Cause.IDLING); // Paper - kick event cause
2023-04-03 11:45:02 +02:00
}
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
+
}
2024-04-25 00:36:49 +02:00
private int getMaximumFlyingTicks(Entity vehicle) {
2024-08-19 11:33:17 +02:00
@@ -3434,6 +3442,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);