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-10-24 00:32:21 +02:00
index d0b2a8b5ded71a9a41753f4addea1c49826b34a3..29b465fc1dc50e0e84ddb889c5303e80fe662874 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-10-24 00:32:21 +02:00
@@ -114,7 +114,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-10-24 00:32:21 +02:00
index 74054e0acd2ecdc6d7ccdf035c9ec120872f6ef4..5d261106b0cd12e9ed737833b1f6d2572d15ab4e 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-10-24 00:32:21 +02:00
@@ -303,6 +303,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
private boolean receivedMovementThisTick;
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-10-24 00:32:21 +02:00
@@ -399,6 +400,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-10-24 00:32:21 +02:00
@@ -3479,6 +3487,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);