From 659f0f2fd0bd4400db33573f08a366d29cb3c1e8 Mon Sep 17 00:00:00 2001 From: Isaac - The456 Date: Sat, 17 Aug 2024 22:20:21 +0100 Subject: [PATCH] Fix Selector Arguments not working with permission (#11286) --- ...t-and-EntitySelectorParser-permissi.patch} | 21 +++++++++++++++---- ...y-type-tags-suggestions-in-selectors.patch | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) rename patches/server/{Fix-EntityArgument-suggestion-permissions-to-align-w.patch => Fix-EntityArgument-and-EntitySelectorParser-permissi.patch} (55%) diff --git a/patches/server/Fix-EntityArgument-suggestion-permissions-to-align-w.patch b/patches/server/Fix-EntityArgument-and-EntitySelectorParser-permissi.patch similarity index 55% rename from patches/server/Fix-EntityArgument-suggestion-permissions-to-align-w.patch rename to patches/server/Fix-EntityArgument-and-EntitySelectorParser-permissi.patch index 160c897e40..11489cdc62 100644 --- a/patches/server/Fix-EntityArgument-suggestion-permissions-to-align-w.patch +++ b/patches/server/Fix-EntityArgument-and-EntitySelectorParser-permissi.patch @@ -1,8 +1,8 @@ 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 +Subject: [PATCH] Fix EntityArgument and EntitySelectorParser 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 @@ -17,12 +17,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 stringreader.setCursor(suggestionsbuilder.getStart()); - EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider)); -+ // Paper start - Fix EntityArgument suggestion permissions ++ // Paper start - Fix EntityArgument 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 ++ // Paper end - Fix EntityArgument permissions try { argumentparserselector.parse(); +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 ++++ b/src/main/java/net/minecraft/commands/arguments/selector/EntitySelectorParser.java +@@ -0,0 +0,0 @@ public class EntitySelectorParser { + boolean flag; + + if (source instanceof SharedSuggestionProvider icompletionprovider) { +- if (icompletionprovider.hasPermission(2)) { ++ if (source instanceof net.minecraft.commands.CommandSourceStack stack ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") : icompletionprovider.hasPermission(2)) { // Paper - Fix EntityArgument permissions + flag = true; + return flag; + } diff --git a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch index f52fa2936b..7aef0d6c91 100644 --- a/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch +++ b/patches/server/Fix-entity-type-tags-suggestions-in-selectors.patch @@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 : icompletionprovider.hasPermission(2); - EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission); + EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission, true); // Paper - tell clients to ask server for suggestions for EntityArguments - // Paper end - Fix EntityArgument suggestion permissions + // Paper end - Fix EntityArgument permissions try { @@ -0,0 +0,0 @@ public class EntityArgument implements ArgumentType {