Prevent vanished players from being in plot kick autocompletion (#4485)

This commit is contained in:
PapiCapi 2024-08-30 17:50:23 +02:00 committed by GitHub
parent a69cd609b9
commit e1ccda3e6d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 2 deletions

View File

@ -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())
);
}

View File

@ -107,6 +107,7 @@ public final class TabCompletions {
}
public static @NonNull List<Command> completePlayersInPlot(
final @NonNull PlotPlayer<?> issuer,
final @NonNull Plot plot,
final @NonNull String input, final @NonNull List<String> existing
) {
@ -115,8 +116,10 @@ public final class TabCompletions {
final List<PlotPlayer<?>> inPlot = plot.getPlayersInPlot();
players = new ArrayList<>(inPlot.size());
for (PlotPlayer<?> player : inPlot) {
if (issuer.canSee(player)) {
players.add(player.getName());
}
}
cachedCompletionValues.put("inPlot" + plot, players);
}
return filterCached(players, input, existing);