feat(bukkit): 支持 1.20.6 版本

This commit is contained in:
2024-06-29 01:42:12 +08:00
parent 271328ef6f
commit 738b566a2d
3 changed files with 28 additions and 45 deletions

View File

@@ -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 {