Skip to content

Commit

Permalink
Do not resolve pm target in pm suggestions when player can't see it
Browse files Browse the repository at this point in the history
  • Loading branch information
Brikster committed Jun 30, 2024
1 parent 73baee5 commit 1684acd
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ public final class PrivateMessageSuggestionsProvider implements CommandSuggestio

@Override
public @NotNull List<@NotNull String> provideSuggestions(@NotNull CommandContext<@NotNull CommandSender> commandContext, @NotNull String arg) {
Player senderPlayer = commandContext.getSender() instanceof Player
? (Player) commandContext.getSender()
: null;

Set<String> suggestions = new HashSet<>();
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
if (onlinePlayer.getName().toLowerCase().startsWith(arg.toLowerCase())) {
if (senderPlayer != null && !senderPlayer.canSee(onlinePlayer)) {
continue;
}
suggestions.add(onlinePlayer.getName());
}
}
Expand Down

0 comments on commit 1684acd

Please sign in to comment.