feat(multiplayer): auto rejection.

This commit is contained in:
huanghongxun
2021-10-10 02:02:44 +08:00
parent 32d557ee07
commit 6221f4b616
5 changed files with 23 additions and 17 deletions

View File

@@ -26,8 +26,7 @@ import java.util.Collections;
import java.util.concurrent.*;
import java.util.logging.Level;
import static org.jackhuang.hmcl.util.Lang.rethrow;
import static org.jackhuang.hmcl.util.Lang.wrap;
import static org.jackhuang.hmcl.util.Lang.*;
/**
*
@@ -320,13 +319,6 @@ public final class AsyncTaskExecutor extends TaskExecutor {
}
}
private static Throwable resolveException(Throwable e) {
if (e instanceof ExecutionException || e instanceof CompletionException)
return resolveException(e.getCause());
else
return e;
}
private void checkCancellation() {
if (isCancelled()) {
throw new CancellationException("Cancelled by user");

View File

@@ -377,6 +377,13 @@ public final class Lang {
return task;
}
public static Throwable resolveException(Throwable e) {
if (e instanceof ExecutionException || e instanceof CompletionException)
return resolveException(e.getCause());
else
return e;
}
/**
* This is a useful function to prevent exceptions being eaten when using CompletableFuture.
* You can write: