net.minestom.server.utils.async.AsyncUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.utils.async;
import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import java.util.concurrent.CompletableFuture;
@ApiStatus.Internal
public final class AsyncUtils {
public static final CompletableFuture VOID_FUTURE = CompletableFuture.completedFuture(null);
public static CompletableFuture empty() {
//noinspection unchecked
return (CompletableFuture) VOID_FUTURE;
}
public static @NotNull CompletableFuture runAsync(@NotNull Runnable runnable) {
return CompletableFuture.runAsync(() -> {
try {
runnable.run();
} catch (Exception e) {
MinecraftServer.getExceptionManager().handleException(e);
}
});
}
}