|
| 1 | +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Pascalpex < [email protected]> |
| 3 | +Date: Tue, 27 May 2025 16:04:17 +0200 |
| 4 | +Subject: [PATCH] Dont show spectator players in tablist |
| 5 | + |
| 6 | + |
| 7 | +diff --git a/net/minecraft/server/level/ServerPlayerGameMode.java b/net/minecraft/server/level/ServerPlayerGameMode.java |
| 8 | +index 7e4cfe12312e0e36a6a19210cd76858a6eaf8abd..3d265212bc47250254f279b0f51e18a76c473eb7 100644 |
| 9 | +--- a/net/minecraft/server/level/ServerPlayerGameMode.java |
| 10 | ++++ b/net/minecraft/server/level/ServerPlayerGameMode.java |
| 11 | +@@ -74,10 +74,16 @@ public class ServerPlayerGameMode { |
| 12 | + // CraftBukkit end |
| 13 | + this.setGameModeForPlayer(gameModeForPlayer, this.gameModeForPlayer); // Paper - Fix MC-259571 |
| 14 | + this.player.onUpdateAbilities(); |
| 15 | +- this.player |
| 16 | +- .server |
| 17 | +- .getPlayerList() |
| 18 | +- .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit |
| 19 | ++ // Deepslate start - Don't send spectator mode packets to other players |
| 20 | ++ if(de.pascalpex.deepslatemc.files.Config.getSendSpectatorModePackets() || gameModeForPlayer != GameType.SPECTATOR) { |
| 21 | ++ this.player |
| 22 | ++ .server |
| 23 | ++ .getPlayerList() |
| 24 | ++ .broadcastAll(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player), this.player); // CraftBukkit |
| 25 | ++ } else { |
| 26 | ++ this.player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_GAME_MODE, this.player)); |
| 27 | ++ } |
| 28 | ++ // Deepslate end - Don't send spectator mode packets to other players |
| 29 | + this.level.updateSleepingPlayerList(); |
| 30 | + if (gameModeForPlayer == GameType.CREATIVE) { |
| 31 | + this.player.resetCurrentImpulseContext(); |
| 32 | +diff --git a/net/minecraft/server/players/PlayerList.java b/net/minecraft/server/players/PlayerList.java |
| 33 | +index 5edc92163eb13a21ba056a898a228df676afe942..8c1f72d6bd9a3aac88de5a4a650d3e04291b28a0 100644 |
| 34 | +--- a/net/minecraft/server/players/PlayerList.java |
| 35 | ++++ b/net/minecraft/server/players/PlayerList.java |
| 36 | +@@ -99,6 +99,7 @@ import net.minecraft.world.scores.DisplaySlot; |
| 37 | + import net.minecraft.world.scores.Objective; |
| 38 | + import net.minecraft.world.scores.PlayerTeam; |
| 39 | + import net.minecraft.world.scores.Team; |
| 40 | ++import org.bukkit.Bukkit; |
| 41 | + import org.slf4j.Logger; |
| 42 | + |
| 43 | + public abstract class PlayerList { |
| 44 | +@@ -485,6 +486,25 @@ public abstract class PlayerList { |
| 45 | + // CraftBukkit start - sendAll above replaced with this loop |
| 46 | + ClientboundPlayerInfoUpdatePacket packet = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(List.of(player)); // Paper - Add Listing API for Player |
| 47 | + |
| 48 | ++ // Deepslate start - Don't send spectator mode packets to other players |
| 49 | ++ ClientboundPlayerInfoUpdatePacket modifiedPacket = null; |
| 50 | ++ if (!de.pascalpex.deepslatemc.files.Config.getSendSpectatorModePackets()) { |
| 51 | ++ ClientboundPlayerInfoUpdatePacket.Entry entry = packet.entries().getFirst(); |
| 52 | ++ ClientboundPlayerInfoUpdatePacket.Entry entryWithoutSpectator = new ClientboundPlayerInfoUpdatePacket.Entry( |
| 53 | ++ entry.profileId(), |
| 54 | ++ entry.profile(), |
| 55 | ++ entry.listed(), |
| 56 | ++ entry.latency(), |
| 57 | ++ entry.gameMode() == net.minecraft.world.level.GameType.SPECTATOR ? net.minecraft.world.level.GameType.SURVIVAL : entry.gameMode(), |
| 58 | ++ entry.displayName(), |
| 59 | ++ entry.showHat(), |
| 60 | ++ entry.listOrder(), |
| 61 | ++ entry.chatSession()); |
| 62 | ++ |
| 63 | ++ modifiedPacket = new ClientboundPlayerInfoUpdatePacket(packet.actions(), List.of(entryWithoutSpectator)); |
| 64 | ++ } |
| 65 | ++ // Deepslate end - Don't send spectator mode packets to other players |
| 66 | ++ |
| 67 | + final List<ServerPlayer> onlinePlayers = Lists.newArrayListWithExpectedSize(this.players.size() - 1); // Paper - Use single player info update packet on join |
| 68 | + for (int i = 0; i < this.players.size(); ++i) { |
| 69 | + ServerPlayer entityplayer1 = (ServerPlayer) this.players.get(i); |
| 70 | +@@ -493,7 +513,13 @@ public abstract class PlayerList { |
| 71 | + // Paper start - Add Listing API for Player |
| 72 | + if (entityplayer1.getBukkitEntity().isListed(bukkitPlayer)) { |
| 73 | + // Paper end - Add Listing API for Player |
| 74 | +- entityplayer1.connection.send(packet); |
| 75 | ++ // Deepslate start - Don't send spectator mode packets to other players |
| 76 | ++ if (de.pascalpex.deepslatemc.files.Config.getSendSpectatorModePackets() || entityplayer1 == player) { |
| 77 | ++ entityplayer1.connection.send(packet); |
| 78 | ++ } else { |
| 79 | ++ entityplayer1.connection.send(modifiedPacket); |
| 80 | ++ } |
| 81 | ++ // Deepslate end - Don't send spectator mode packets to other players |
| 82 | + // Paper start - Add Listing API for Player |
| 83 | + } else { |
| 84 | + entityplayer1.connection.send(ClientboundPlayerInfoUpdatePacket.createSinglePlayerInitializing(player, false)); |
| 85 | +@@ -515,7 +541,27 @@ public abstract class PlayerList { |
| 86 | + } |
| 87 | + // Paper start - Use single player info update packet on join |
| 88 | + if (!onlinePlayers.isEmpty()) { |
| 89 | +- player.connection.send(ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers, player)); // Paper - Add Listing API for Player |
| 90 | ++ // Deepslate start - Don't send spectator mode packets to other players |
| 91 | ++ ClientboundPlayerInfoUpdatePacket updatePacket = ClientboundPlayerInfoUpdatePacket.createPlayerInitializing(onlinePlayers, player); |
| 92 | ++ if (!de.pascalpex.deepslatemc.files.Config.getSendSpectatorModePackets()) { |
| 93 | ++ List<ClientboundPlayerInfoUpdatePacket.Entry> newEntries = new java.util.ArrayList<>(); |
| 94 | ++ for (ClientboundPlayerInfoUpdatePacket.Entry entry : updatePacket.entries()) { |
| 95 | ++ ClientboundPlayerInfoUpdatePacket.Entry newEntry = new ClientboundPlayerInfoUpdatePacket.Entry( |
| 96 | ++ entry.profileId(), |
| 97 | ++ entry.profile(), |
| 98 | ++ entry.listed(), |
| 99 | ++ entry.latency(), |
| 100 | ++ entry.gameMode() == net.minecraft.world.level.GameType.SPECTATOR ? net.minecraft.world.level.GameType.SURVIVAL : entry.gameMode(), |
| 101 | ++ entry.displayName(), |
| 102 | ++ entry.showHat(), |
| 103 | ++ entry.listOrder(), |
| 104 | ++ entry.chatSession()); |
| 105 | ++ newEntries.add(newEntry); |
| 106 | ++ } |
| 107 | ++ updatePacket = new ClientboundPlayerInfoUpdatePacket(updatePacket.actions(), newEntries); |
| 108 | ++ } |
| 109 | ++ player.connection.send(updatePacket); // Paper - Add Listing API for Player |
| 110 | ++ // Deepslate end - Don't send spectator mode packets to other players |
| 111 | + } |
| 112 | + // Paper end - Use single player info update packet on join |
| 113 | + player.sentListPacket = true; |
0 commit comments