Correctly cancel notify tasks and add notifications to commands

This commit is contained in:
dordsor21
2020-10-09 17:24:59 +01:00
parent a451d2d6f2
commit a7a29eaf97
10 changed files with 76 additions and 33 deletions

View File

@ -137,20 +137,23 @@ public final class BukkitChunkCoordinator extends ChunkCoordinator {
final int expected = this.expectedSize.addAndGet(-processedChunks);
final float progress = ((float) totalSize - (float) expected) / (float) totalSize;
for (final ProgressSubscriber subscriber : this.progressSubscribers) {
subscriber.notifyProgress(this, progress);
}
if (expected <= 0) {
try {
this.whenDone.run();
} catch (final Throwable throwable) {
this.throwableConsumer.accept(throwable);
} finally {
for (final ProgressSubscriber subscriber : this.progressSubscribers) {
subscriber.notifyEnd();
}
this.cancel();
}
this.cancel();
} else {
if (this.availableChunks.size() < processedChunks) {
final double progress = ((double) totalSize - (double) expected) / (double) totalSize;
for (final ProgressSubscriber subscriber : this.progressSubscribers) {
subscriber.notifyProgress(this, progress);
}
this.requestBatch();
}
}