Skip to content

Commit e1ccda3

Browse files
authored
Prevent vanished players from being in plot kick autocompletion (#4485)
1 parent a69cd60 commit e1ccda3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Core/src/main/java/com/plotsquared/core/command/Kick.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public Collection<Command> tab(final PlotPlayer<?> player, final String[] args,
153153
if (plot == null) {
154154
return Collections.emptyList();
155155
}
156-
return TabCompletions.completePlayersInPlot(plot, String.join(",", args).trim(),
156+
return TabCompletions.completePlayersInPlot(player, plot, String.join(",", args).trim(),
157157
Collections.singletonList(player.getName())
158158
);
159159
}

Core/src/main/java/com/plotsquared/core/util/TabCompletions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private TabCompletions() {
107107
}
108108

109109
public static @NonNull List<Command> completePlayersInPlot(
110+
final @NonNull PlotPlayer<?> issuer,
110111
final @NonNull Plot plot,
111112
final @NonNull String input, final @NonNull List<String> existing
112113
) {
@@ -115,7 +116,9 @@ private TabCompletions() {
115116
final List<PlotPlayer<?>> inPlot = plot.getPlayersInPlot();
116117
players = new ArrayList<>(inPlot.size());
117118
for (PlotPlayer<?> player : inPlot) {
118-
players.add(player.getName());
119+
if (issuer.canSee(player)) {
120+
players.add(player.getName());
121+
}
119122
}
120123
cachedCompletionValues.put("inPlot" + plot, players);
121124
}

0 commit comments

Comments
 (0)