Restore compatibility with older Minecraft versions

This commit is contained in:
games647
2022-07-08 16:28:56 +02:00
parent 0b0a46a18a
commit eb47dd3254
7 changed files with 235 additions and 134 deletions
@@ -58,16 +58,18 @@ public class AsyncScheduler {
}
public CompletableFuture<Void> runAsync(Runnable task) {
return CompletableFuture.runAsync(() -> {
currentlyRunning.incrementAndGet();
try {
task.run();
} finally {
currentlyRunning.getAndDecrement();
}
}, processingPool).exceptionally(error -> {
return CompletableFuture.runAsync(() -> process(task), processingPool).exceptionally(error -> {
logger.warn("Error occurred on thread pool", error);
return null;
});
}
private void process(Runnable task) {
currentlyRunning.incrementAndGet();
try {
task.run();
} finally {
currentlyRunning.getAndDecrement();
}
}
}