aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch71
1 files changed, 71 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch b/patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
new file mode 100644
index 0000000000..f1123c53ed
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/server/commands/ListPlayersCommand.java.patch
@@ -0,0 +1,71 @@
+--- a/net/minecraft/server/commands/ListPlayersCommand.java
++++ b/net/minecraft/server/commands/ListPlayersCommand.java
+@@ -1,11 +1,10 @@
+ package net.minecraft.server.commands;
+
+ import com.mojang.brigadier.CommandDispatcher;
+-import com.mojang.brigadier.context.CommandContext;
++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;
+@@ -13,12 +12,15 @@
+ 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 listPlayers((CommandSourceStack) commandcontext.getSource());
++ })).then(net.minecraft.commands.Commands.literal("uuids").executes((commandcontext) -> {
++ return listPlayersWithUuids((CommandSourceStack) commandcontext.getSource());
++ })));
+ }
+
+ private static int listPlayers(CommandSourceStack source) {
+@@ -26,16 +28,26 @@
+ }
+
+ private static int listPlayersWithUuids(CommandSourceStack source) {
+- return format(
+- source, player -> Component.translatable("commands.list.nameAndId", player.getName(), Component.translationArg(player.getGameProfile().getId()))
+- );
++ return 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> 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();
+ }
+ }