mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-03 05:32:18 -07:00
Thread Safe Vanilla Command permission checking
Datapacks check this on load and are built concurrently. This was breaking them badly due to race conditions. Plus, .canUse we want to be safe for async anyways.
This commit is contained in:
@@ -40,10 +40,10 @@
|
||||
+ public synchronized boolean canUse(final S source) {
|
||||
+ if (source instanceof CommandSourceStack) {
|
||||
+ try {
|
||||
+ ((CommandSourceStack) source).currentCommand = this;
|
||||
+ ((CommandSourceStack) source).currentCommand.put(Thread.currentThread(), this); // Paper - Thread Safe Vanilla Command permission checking
|
||||
+ return this.requirement.test(source);
|
||||
+ } finally {
|
||||
+ ((CommandSourceStack) source).currentCommand = null;
|
||||
+ ((CommandSourceStack) source).currentCommand.remove(Thread.currentThread()); // Paper - Thread Safe Vanilla Command permission checking
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
Reference in New Issue
Block a user