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-31 17:25:52 +01:00
index 2edf9a3c4ce5d2feaac624c969c2711dfc2dc4f7..e653dc4ac16fd22674a6c1ba402f8913e0fbb336 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 19:29:35 +02:00
@@ -305,6 +305,7 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
2024-10-24 00:32:21 +02:00
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 19:29:35 +02:00
@@ -401,6 +402,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-31 17:25:52 +01:00
@@ -3485,6 +3493,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);