aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch63
1 files changed, 63 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
new file mode 100644
index 0000000000..685919c97a
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
@@ -0,0 +1,63 @@
+--- a/net/minecraft/server/commands/ListPlayersCommand.java
++++ b/net/minecraft/server/commands/ListPlayersCommand.java
+@@ -5,7 +5,6 @@
+ 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;
+@@ -16,31 +15,38 @@
+
+ public ListPlayersCommand() {}
+
+- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) {
+- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("list").executes((commandcontext) -> {
++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("list").executes((commandcontext) -> {
+ return listPlayers((CommandSourceStack) commandcontext.getSource());
+- })).then(Commands.literal("uuids").executes((commandcontext) -> {
++ })).then(net.minecraft.commands.Commands.literal("uuids").executes((commandcontext) -> {
+ return listPlayersWithUuids((CommandSourceStack) commandcontext.getSource());
+ })));
+ }
+
+- private static int listPlayers(CommandSourceStack commandsourcestack) {
+- return format(commandsourcestack, Player::getDisplayName);
++ private static int listPlayers(CommandSourceStack source) {
++ return format(source, Player::getDisplayName);
+ }
+
+- private static int listPlayersWithUuids(CommandSourceStack commandsourcestack) {
+- return format(commandsourcestack, (serverplayer) -> {
+- return Component.translatable("commands.list.nameAndId", serverplayer.getName(), Component.translationArg(serverplayer.getGameProfile().getId()));
++ private static int listPlayersWithUuids(CommandSourceStack source) {
++ return format(source, (entityplayer) -> {
++ return Component.translatable("commands.list.nameAndId", entityplayer.getName(), Component.translationArg(entityplayer.getGameProfile().getId()));
+ });
+ }
+
+- private static int format(CommandSourceStack commandsourcestack, Function<ServerPlayer, Component> function) {
+- PlayerList playerlist = commandsourcestack.getServer().getPlayerList();
+- List<ServerPlayer> list = playerlist.getPlayers();
+- Component component = ComponentUtils.formatList(list, function);
++ private static int format(CommandSourceStack source, Function<ServerPlayer, Component> nameExtractor) {
++ 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);
+
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), component);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.list.players", list.size(), playerlist.getMaxPlayers(), ichatbasecomponent);
+ }, false);
+ return list.size();
+ }