--- a/net/minecraft/server/commands/ListPlayersCommand.java
+++ b/net/minecraft/server/commands/ListPlayersCommand.java
@@ -1,10 +1,10 @@
 package net.minecraft.server.commands;
 
 import com.mojang.brigadier.CommandDispatcher;
+import com.mojang.brigadier.builder.LiteralArgumentBuilder;
 import java.util.List;
 import java.util.function.Function;
 import net.minecraft.commands.CommandSourceStack;
-import net.minecraft.commands.Commands;
 import net.minecraft.network.chat.Component;
 import net.minecraft.network.chat.ComponentUtils;
 import net.minecraft.server.level.ServerPlayer;
@@ -12,29 +12,42 @@
 import net.minecraft.world.entity.player.Player;
 
 public class ListPlayersCommand {
+
+    public ListPlayersCommand() {}
+
     public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
-        dispatcher.register(
-            Commands.literal("list")
-                .executes(context -> listPlayers(context.getSource()))
-                .then(Commands.literal("uuids").executes(context -> listPlayersWithUuids(context.getSource())))
-        );
+        dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("list").executes((commandcontext) -> {
+            return ListPlayersCommand.listPlayers((CommandSourceStack) commandcontext.getSource());
+        })).then(net.minecraft.commands.Commands.literal("uuids").executes((commandcontext) -> {
+            return ListPlayersCommand.listPlayersWithUuids((CommandSourceStack) commandcontext.getSource());
+        })));
     }
 
     private static int listPlayers(CommandSourceStack source) {
-        return format(source, Player::getDisplayName);
+        return ListPlayersCommand.format(source, Player::getDisplayName);
     }
 
     private static int listPlayersWithUuids(CommandSourceStack source) {
-        return format(
-            source, player -> Component.translatable("commands.list.nameAndId", player.getName(), Component.translationArg(player.getGameProfile().getId()))
-        );
+        return ListPlayersCommand.format(source, (entityplayer) -> {
+            return Component.translatable("commands.list.nameAndId", entityplayer.getName(), Component.translationArg(entityplayer.getGameProfile().getId()));
+        });
     }
 
     private static int format(CommandSourceStack source, Function<ServerPlayer, Component> nameProvider) {
-        PlayerList playerList = source.getServer().getPlayerList();
-        List<ServerPlayer> list = playerList.getPlayers();
-        Component component = ComponentUtils.formatList(list, nameProvider);
-        source.sendSuccess(() -> Component.translatable("commands.list.players", list.size(), playerList.getMaxPlayers(), component), false);
+        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, nameProvider);
+
+        source.sendSuccess(() -> {
+            return Component.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent);
+        }, false);
         return list.size();
     }
 }
