aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0948-Improve-command-function-perm-level-checks.patch
blob: 3413470663d7778deb00c871e941223b6abb734d (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
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Tue, 27 Jun 2023 16:32:39 -0700
Subject: [PATCH] Improve command function perm level checks


diff --git a/src/main/java/net/minecraft/commands/CommandSourceStack.java b/src/main/java/net/minecraft/commands/CommandSourceStack.java
index 20b2cbbc73f6420b6ace9746016527b90d9f01b9..14f4c0a93372a58cf36dc95265b5e210ea1605e5 100644
--- a/src/main/java/net/minecraft/commands/CommandSourceStack.java
+++ b/src/main/java/net/minecraft/commands/CommandSourceStack.java
@@ -206,8 +206,14 @@ public class CommandSourceStack implements ExecutionCommandSource<CommandSourceS
 
     // CraftBukkit start
     public boolean hasPermission(int i, String bukkitPermission) {
-        // World is null when loading functions
-        return ((this.getLevel() == null || !this.getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || this.getBukkitSender().hasPermission(bukkitPermission);
+        // Paper start
+        boolean hasPermissionLevel = this.permissionLevel >= i;
+        if (this.source == CommandSource.NULL) {
+            return hasPermissionLevel;
+        } else {
+            return (!this.getLevel().getCraftServer().ignoreVanillaPermissions && hasPermissionLevel) || this.getBukkitSender().hasPermission(bukkitPermission);
+        }
+        // Paper end
     }
     // CraftBukkit end