aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0764-Fix-EntityArgument-suggestion-permissions-to-align-w.patch
blob: 6ec183532ef5355edf2e820588c56d79380b4fbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 26 Oct 2022 13:13:12 -0700
Subject: [PATCH] Fix EntityArgument suggestion permissions to align with
 EntitySelector#checkPermissions

Fixes where the user has permission for selectors but not their
suggestions, which especially matters when we force suggestions to
the server for this type

diff --git a/src/main/java/net/minecraft/commands/arguments/EntityArgument.java b/src/main/java/net/minecraft/commands/arguments/EntityArgument.java
index a327939abe2cce22747366051b6b7aaa2db3a8cc..a8487c18d7ef28143a7750bf096d00bcf1e67113 100644
--- a/src/main/java/net/minecraft/commands/arguments/EntityArgument.java
+++ b/src/main/java/net/minecraft/commands/arguments/EntityArgument.java
@@ -135,7 +135,12 @@ public class EntityArgument implements ArgumentType<EntitySelector> {
             StringReader stringreader = new StringReader(suggestionsbuilder.getInput());
 
             stringreader.setCursor(suggestionsbuilder.getStart());
-            EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider));
+            // Paper start - Fix EntityArgument suggestion permissions
+            final boolean permission = object instanceof CommandSourceStack stack
+                    ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector")
+                    : icompletionprovider.hasPermission(2);
+            EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
+            // Paper end - Fix EntityArgument suggestion permissions
 
             try {
                 argumentparserselector.parse();