Update player chat session sync (#12382)

This commit is contained in:
Gero
2025-04-26 23:26:20 +02:00
committed by GitHub
parent f86b435228
commit 3e3b42cdf5
4 changed files with 17 additions and 15 deletions

View File

@@ -2566,7 +2566,7 @@
);
}
}
@@ -1997,6 +_,7 @@
@@ -1997,27 +_,32 @@
private void resetPlayerChatState(RemoteChatSession chatSession) {
this.chatSession = chatSession;
@@ -2574,16 +2574,19 @@
this.signedMessageDecoder = chatSession.createMessageDecoder(this.player.getUUID());
this.chatMessageChain
.append(
@@ -2005,7 +_,7 @@
() -> {
+ server.executeBlocking(() -> { // Paper - Broadcast chat session update sync
this.player.setChatSession(chatSession);
this.server
.getPlayerList()
.broadcastAll(
- new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player))
+ new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)), this.player // Paper - Use single player info update packet on join
);
+ });
}
);
@@ -2013,11 +_,13 @@
}
@Override
public void handleCustomPayload(ServerboundCustomPayloadPacket packet) {

View File

@@ -756,7 +756,7 @@
return serverPlayer;
}
@@ -488,24 +_,60 @@
@@ -488,24 +_,59 @@
}
public void sendActiveEffects(LivingEntity entity, ServerGamePacketListenerImpl connection) {
@@ -800,12 +800,11 @@
+ // CraftBukkit start - add a world/entity limited version
+ public void broadcastAll(Packet packet, net.minecraft.world.entity.player.Player entityhuman) {
+ for (int i = 0; i < this.players.size(); ++i) {
+ ServerPlayer entityplayer = this.players.get(i);
+ for (ServerPlayer entityplayer : this.players) { // Paper - replace for i with for each for thread safety
+ if (entityhuman != null && !entityplayer.getBukkitEntity().canSee(entityhuman.getBukkitEntity())) {
+ continue;
+ }
+ ((ServerPlayer) this.players.get(i)).connection.send(packet);
+ ((ServerPlayer) entityplayer).connection.send(packet); // Paper - replace for i with for each for thread safety
+ }
+ }
+