mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-21 23:33:48 -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:
@@ -24,25 +24,6 @@
|
||||
|
||||
protected CommandNode(final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
||||
this.command = command;
|
||||
@@ -61,7 +_,17 @@
|
||||
return modifier;
|
||||
}
|
||||
|
||||
- public boolean canUse(final S source) {
|
||||
+ // CraftBukkit start
|
||||
+ public synchronized boolean canUse(final S source) {
|
||||
+ if (source instanceof final net.minecraft.commands.CommandSourceStack css) {
|
||||
+ try {
|
||||
+ css.currentCommand.put(Thread.currentThread(), this); // Paper - Thread Safe Vanilla Command permission checking
|
||||
+ return this.requirement.test(source);
|
||||
+ } finally {
|
||||
+ css.currentCommand.remove(Thread.currentThread()); // Paper - Thread Safe Vanilla Command permission checking
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return requirement.test(source);
|
||||
}
|
||||
|
||||
@@ -151,6 +_,12 @@
|
||||
protected abstract String getSortedKey();
|
||||
|
||||
|
Reference in New Issue
Block a user