Interface FutureResult<T>
- All Known Implementing Classes:
BukkitFutureResult
public interface FutureResult<T>
-
Method Summary
Modifier and TypeMethodDescriptionasFuture()Encapsulates thisFutureResultas aCompletableFuture.join()Blocks the current thread until the action has completed.voidwhenComplete(@NotNull Consumer<? super T> callback) Attaches a completion callback to thisFutureResult.voidvoidwhenComplete(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<? super T> callback) Attaches a completion callback to thisFutureResult.voidwhenComplete(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull Consumer<? super T> callback, Consumer<Throwable> throwable)
-
Method Details
-
whenComplete
Attaches a completion callback to thisFutureResult.If the action is already complete, the runnable will be called immediately.
If it is not complete, the consumer will be called synchronously using the Bukkit scheduler when the action is completed.
- Parameters:
callback- the callback
-
whenComplete
-
whenComplete
-
whenComplete
void whenComplete(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull Consumer<? super T> callback) Attaches a completion callback to thisFutureResult.If the action is already complete, the runnable will be called immediately.
If it is not complete, the consumer will be called synchronously using the Bukkit scheduler when the action is completed.
- Parameters:
plugin- used for callback.callback- the callback
-
join
Blocks the current thread until the action has completed.This method should only be called from an async task!
- Returns:
- the result
-
asFuture
Encapsulates thisFutureResultas aCompletableFuture.- Returns:
- a future
-