3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 12:30:06 +01:00
Paper/patches/unapplied/server/0953-Use-single-player-info-update-packet-on-join.patch
2023-03-14 18:11:24 +01:00

61 Zeilen
4.0 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 8 Jan 2023 17:38:28 -0800
Subject: [PATCH] Use single player info update packet on join
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index ac63b21c5f7996d1cc79d6923887f55f2c91dd05..bac6b62419d85b3772ef243aa3d5f73311abdda7 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -3611,7 +3611,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.signedMessageDecoder = session.createMessageDecoder(this.player.getUUID());
this.chatMessageChain.append((executor) -> {
this.player.setChatSession(session);
- this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)));
+ this.server.getPlayerList().broadcastAll(new ClientboundPlayerInfoUpdatePacket(EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.INITIALIZE_CHAT), List.of(this.player)), this.player); // Paper
return CompletableFuture.completedFuture((Object) null);
});
}
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 1b0ca19cd61a55998676b9f8ca17bf79966385db..835e439a1af327c67558653ef79ef7e59692a976 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -297,7 +297,7 @@ public abstract class PlayerList {
playerconnection.teleport(player.getX(), player.getY(), player.getZ(), player.getYRot(), player.getXRot());
player.sendServerStatus(this.server.getStatus());
- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players));
+ // player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(this.players)); // Paper - use single player info update packet
this.players.add(player);
this.playersByName.put(player.getScoreboardName().toLowerCase(java.util.Locale.ROOT), player); // Spigot
this.playersByUUID.put(player.getUUID(), player);
@@ -333,6 +333,7 @@ public abstract class PlayerList {
// CraftBukkit start - sendAll above replaced with this loop
ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player));
+ final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - use single player info update packet
for (int i = 0; i < this.players.size(); ++i) {
ServerPlayer entityplayer1 = (ServerPlayer) this.players.get(i);
@@ -340,12 +341,17 @@ public abstract class PlayerList {
entityplayer1.connection.send(packet);
}
- if (!bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) {
+ if (entityplayer1 == player || !bukkitPlayer.canSee(entityplayer1.getBukkitEntity())) { // Paper - don't include joining player
continue;
}
- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(entityplayer1)));
+ onlinePlayers.add(entityplayer1); // Paper - use single player info update packet
}
+ // Paper start - use single player info update packet
+ if (!onlinePlayers.isEmpty()) {
+ player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers));
+ }
+ // Paper end
player.sentListPacket = true;
player.supressTrackerForLogin = false; // Paper
((ServerLevel)player.level).getChunkSource().chunkMap.addEntity(player); // Paper - track entity now