mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-22 15:53:49 -07:00
Improve command permission lookups
This allows us to append to the vanilla permission check object to avoid having to look into a map. This also fixes non vanilla commands from technically being able to be skipped through permissions.
This commit is contained in:
@@ -9,11 +9,10 @@
|
||||
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(Component.translatable("permissions.requires.player"));
|
||||
public static final SimpleCommandExceptionType ERROR_NOT_ENTITY = new SimpleCommandExceptionType(Component.translatable("permissions.requires.entity"));
|
||||
public final CommandSource source;
|
||||
@@ -65,6 +_,8 @@
|
||||
@@ -65,6 +_,7 @@
|
||||
private final Vec2 rotation;
|
||||
private final CommandSigningContext signingContext;
|
||||
private final TaskChainer chatMessageChainer;
|
||||
+ public java.util.Map<Thread, com.mojang.brigadier.tree.CommandNode> currentCommand = new java.util.concurrent.ConcurrentHashMap<>(); // CraftBukkit // Paper - Thread Safe Vanilla Command permission checking
|
||||
+ public boolean bypassSelectorPermissions = false; // Paper - add bypass for selector permissions
|
||||
|
||||
public CommandSourceStack(
|
||||
@@ -49,19 +48,7 @@
|
||||
public CommandSourceStack withRotation(Vec2 rotation) {
|
||||
return this.rotation.equals(rotation)
|
||||
? this
|
||||
@@ -393,9 +_,44 @@
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(int level) {
|
||||
+ // CraftBukkit start
|
||||
+ // Paper start - Thread Safe Vanilla Command permission checking
|
||||
+ com.mojang.brigadier.tree.CommandNode currentCommand = this.currentCommand.get(Thread.currentThread());
|
||||
+ if (currentCommand != null) {
|
||||
+ return this.hasPermission(level, org.bukkit.craftbukkit.command.VanillaCommandWrapper.getPermission(currentCommand));
|
||||
+ // Paper end - Thread Safe Vanilla Command permission checking
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@@ -396,6 +_,32 @@
|
||||
return this.permissionLevel >= level;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user