Skip to content

Commit

Permalink
- ItemStackCapInitTask 边界情况异常修复 x2。
Browse files Browse the repository at this point in the history
  • Loading branch information
KasumiNova committed Oct 23, 2024
1 parent e0e9440 commit 8fcb4d4
Showing 1 changed file with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,27 @@ public ItemStackCapInitTask(final ItemStack target) {
}

@Override
public synchronized void run() {
if (done.get()) {
public void run() {
if (done.get() || working != null) {
return;
}
working = Thread.currentThread();

try {
target.stellar_core$initCap();
} catch (Throwable e) {
StellarLog.LOG.warn("[StellarCore-ItemStackCapInitTask] Failed to execute capability init task!", e);
}
synchronized (this) {
if (working != null) {
return;
}

working = Thread.currentThread();

working = null;
done.set(true);
try {
target.stellar_core$initCap();
} catch (Throwable e) {
StellarLog.LOG.warn("[StellarCore-ItemStackCapInitTask] Failed to execute capability init task!", e);
}

working = null;
done.set(true);
}
}

public boolean isDone() {
Expand Down

0 comments on commit 8fcb4d4

Please # to comment.