Fix Selector Arguments not working with permission (#11286)

This commit is contained in:
Isaac - The456 2024-08-17 22:20:21 +01:00
parent 6da54bd440
commit 659f0f2fd0
2 changed files with 18 additions and 5 deletions

View file

@ -1,8 +1,8 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com> From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
Date: Wed, 26 Oct 2022 13:13:12 -0700 Date: Wed, 26 Oct 2022 13:13:12 -0700
Subject: [PATCH] Fix EntityArgument suggestion permissions to align with Subject: [PATCH] Fix EntityArgument and EntitySelectorParser permissions to
EntitySelector#checkPermissions align with EntitySelector#checkPermissions
Fixes where the user has permission for selectors but not their Fixes where the user has permission for selectors but not their
suggestions, which especially matters when we force suggestions to suggestions, which especially matters when we force suggestions to
@ -17,12 +17,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
stringreader.setCursor(suggestionsbuilder.getStart()); stringreader.setCursor(suggestionsbuilder.getStart());
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider)); - 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 + final boolean permission = object instanceof CommandSourceStack stack
+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") + ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector")
+ : icompletionprovider.hasPermission(2); + : icompletionprovider.hasPermission(2);
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission); + EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
+ // Paper end - Fix EntityArgument suggestion permissions + // Paper end - Fix EntityArgument permissions
try { try {
argumentparserselector.parse(); 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;
}

View file

@ -69,7 +69,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
: icompletionprovider.hasPermission(2); : icompletionprovider.hasPermission(2);
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission); - EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission, true); // Paper - tell clients to ask server for suggestions for EntityArguments + 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 { try {
@@ -0,0 +0,0 @@ public class EntityArgument implements ArgumentType<EntitySelector> { @@ -0,0 +0,0 @@ public class EntityArgument implements ArgumentType<EntitySelector> {