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:
parent
3ceb5297a3
commit
def8b96d4b
2 changed files with 9 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue