All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.minestom.server.utils.async.AsyncUtils Maven / Gradle / Ivy

There is a newer version: 7320437640
Show newest version
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);
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy