From 97ed3762cf69125d225e7f5cf9b5f9c7ee177c5d Mon Sep 17 00:00:00 2001
From: Bjarne Koll <LynxPlay101@gmail.com>
Date: Sat, 1 Jun 2024 16:26:11 +0200
Subject: [PATCH] Fix CommandSourceStack#bypassSelectorPermissions (#10837)

The previous implementation would throw a command exception if the
CommandSourceStack had its bypassSelectorPermissions flag set to true,
which is the incorrect behaviour.

Instead, it should only throw an exception if the flag is set to false
and all its other checks "fail" too.
---
 patches/server/Adventure.patch | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch
index 4bd6545b8d..710fec585a 100644
--- a/patches/server/Adventure.patch
+++ b/patches/server/Adventure.patch
@@ -2213,7 +2213,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
  
      private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException {
 -        if (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
-+        if (source.bypassSelectorPermissions || (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms
++        if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms
              throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create();
          }
      }