aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/ListPlayersCommand.java.patch
blob: 6bf629b9b68b444336fa82ba51d19a46deb61e5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
--- a/net/minecraft/server/commands/ListPlayersCommand.java
+++ b/net/minecraft/server/commands/ListPlayersCommand.java
@@ -32,10 +34,20 @@
     }
 
     private static int format(CommandSourceStack source, Function<ServerPlayer, Component> nameExtractor) {
-        PlayerList playerList = source.getServer().getPlayerList();
-        List<ServerPlayer> players = playerList.getPlayers();
-        Component component = ComponentUtils.formatList(players, nameExtractor);
-        source.sendSuccess(() -> Component.translatable("commands.list.players", players.size(), playerList.getMaxPlayers(), component), false);
-        return players.size();
+        PlayerList playerlist = source.getServer().getPlayerList();
+        // CraftBukkit start
+        List<ServerPlayer> players = playerlist.getPlayers();
+        if (source.getBukkitSender() instanceof org.bukkit.entity.Player) {
+            org.bukkit.entity.Player sender = (org.bukkit.entity.Player) source.getBukkitSender();
+            players = players.stream().filter((ep) -> sender.canSee(ep.getBukkitEntity())).collect(java.util.stream.Collectors.toList());
+        }
+        List<ServerPlayer> list = players;
+        // CraftBukkit end
+        Component ichatbasecomponent = ComponentUtils.formatList(list, nameExtractor);
+
+        source.sendSuccess(() -> {
+            return Component.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent);
+        }, false);
+        return list.size();
     }
 }