From e1ccda3e6d7893bfab5e4dd72c94abe93a7ab722 Mon Sep 17 00:00:00 2001 From: PapiCapi <49530141+PapiCapi@users.noreply.github.com> Date: Fri, 30 Aug 2024 17:50:23 +0200 Subject: [PATCH] Prevent vanished players from being in plot kick autocompletion (#4485) --- Core/src/main/java/com/plotsquared/core/command/Kick.java | 2 +- .../main/java/com/plotsquared/core/util/TabCompletions.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Core/src/main/java/com/plotsquared/core/command/Kick.java b/Core/src/main/java/com/plotsquared/core/command/Kick.java index cf91f9ad2..5c9d07fc1 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Kick.java +++ b/Core/src/main/java/com/plotsquared/core/command/Kick.java @@ -153,7 +153,7 @@ public class Kick extends SubCommand { if (plot == null) { return Collections.emptyList(); } - return TabCompletions.completePlayersInPlot(plot, String.join(",", args).trim(), + return TabCompletions.completePlayersInPlot(player, plot, String.join(",", args).trim(), Collections.singletonList(player.getName()) ); } diff --git a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java index c9d1b3037..d5a341c5b 100644 --- a/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java +++ b/Core/src/main/java/com/plotsquared/core/util/TabCompletions.java @@ -107,6 +107,7 @@ public final class TabCompletions { } public static @NonNull List completePlayersInPlot( + final @NonNull PlotPlayer issuer, final @NonNull Plot plot, final @NonNull String input, final @NonNull List existing ) { @@ -115,7 +116,9 @@ public final class TabCompletions { final List> inPlot = plot.getPlayersInPlot(); players = new ArrayList<>(inPlot.size()); for (PlotPlayer player : inPlot) { - players.add(player.getName()); + if (issuer.canSee(player)) { + players.add(player.getName()); + } } cachedCompletionValues.put("inPlot" + plot, players); }