correctly hide players from entity argument suggestions (#9245)

This commit is contained in:
Jake Potrebic 2023-06-10 18:15:43 -07:00
parent 8ee3c344d4
commit 4e7f46f6c3

View File

@ -72,6 +72,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
try {
argumentparserselector.parse();
@@ -0,0 +0,0 @@ public class EntityArgument implements ArgumentType<EntitySelector> {
}
return argumentparserselector.fillSuggestions(suggestionsbuilder, (suggestionsbuilder1) -> {
- Collection<String> collection = icompletionprovider.getOnlinePlayerNames();
+ // Paper start
+ final Collection<String> collection;
+ if (icompletionprovider instanceof CommandSourceStack commandSourceStack && commandSourceStack.getEntity() instanceof ServerPlayer sourcePlayer) {
+ collection = new java.util.ArrayList<>();
+ for (final ServerPlayer player : commandSourceStack.getServer().getPlayerList().getPlayers()) {
+ if (sourcePlayer.getBukkitEntity().canSee(player.getBukkitEntity())) {
+ collection.add(player.getGameProfile().getName());
+ }
+ }
+ } else {
+ collection = icompletionprovider.getOnlinePlayerNames();
+ }
+ // Paper end
Iterable<String> iterable = this.playersOnly ? collection : Iterables.concat(collection, icompletionprovider.getSelectedEntities());
SharedSuggestionProvider.suggest((Iterable) iterable, suggestionsbuilder1);
diff --git a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java