feat(bukkit): 支持 1.20.6 版本
This commit is contained in:
@@ -118,42 +118,24 @@ public class CompletableTask<T> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public T get() throws Throwable {
|
||||
public T get() throws InterruptedException {
|
||||
if (state == State.WAITING) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
wait();
|
||||
}
|
||||
}
|
||||
switch (state) {
|
||||
case SUCCESS:
|
||||
return value;
|
||||
case FAILED:
|
||||
throw throwable;
|
||||
if (state == State.SUCCESS) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public T getOrDefault(T defaultValue) {
|
||||
if (state == State.WAITING) {
|
||||
synchronized (this) {
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public T join() {
|
||||
try {
|
||||
return get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
switch (state) {
|
||||
case SUCCESS:
|
||||
return value;
|
||||
case FAILED:
|
||||
return defaultValue;
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
public enum State {
|
||||
|
Reference in New Issue
Block a user