diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java b/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java index 67b8a9a0..f57268ae 100644 --- a/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java +++ b/src/main/java/org/mvplugins/multiverse/core/utils/result/AsyncAttempt.java @@ -3,6 +3,7 @@ package org.mvplugins.multiverse.core.utils.result; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.function.BiFunction; +import java.util.function.Consumer; import java.util.function.Function; import org.mvplugins.multiverse.core.utils.message.MessageReplacement; @@ -67,6 +68,19 @@ public final class AsyncAttempt { return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onSuccess(runnable))); } + public AsyncAttempt onFailure(Runnable runnable) { + // TODO Not sure why we creating a new instance instead of using `this` + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailure(runnable))); + } + + public AsyncAttempt onFailure(Consumer> consumer) { + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailure(consumer))); + } + + public AsyncAttempt onFailureReason(Consumer consumer) { + return new AsyncAttempt<>(future.thenApply(attempt -> attempt.onFailureReason(consumer))); + } + public Attempt toAttempt() { return future.join(); }