Apply suggested future-related changes

Co-authored-by: A248 <theanandbeh@gmail.com>
This commit is contained in:
Hugo Manrique
2021-06-11 14:03:38 +02:00
parent f6e6f02a84
commit 61480544f5
7 changed files with 59 additions and 17 deletions

View File

@@ -29,6 +29,7 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import com.mojang.brigadier.tree.CommandNode;
import com.mojang.brigadier.tree.LiteralCommandNode;
import com.spotify.futures.CompletableFutures;
import com.velocitypowered.api.command.Command;
import com.velocitypowered.api.command.CommandMeta;
import com.velocitypowered.api.command.CommandSource;
@@ -357,7 +358,10 @@ final class SuggestionsProvider<S> {
return CompletableFuture.allOf(futures).handle((unused, throwable) -> {
final List<Suggestions> suggestions = new ArrayList<>(futures.length);
for (final CompletableFuture<Suggestions> future : futures) {
if (!future.isCompletedExceptionally()) {
if (future.isCompletedExceptionally()) {
final Throwable exception = CompletableFutures.getException(future);
LOGGER.error("Node cannot provide suggestions", exception);
} else {
suggestions.add(future.join());
}
}

View File

@@ -224,7 +224,7 @@ public class VelocityCommandManager implements CommandManager {
Lists.transform(suggestions.getList(), Suggestion::getText));
} catch (final Throwable e) {
// Again, plugins are naughty
return CompletableFutures.exceptionallyCompletedFuture(
return CompletableFuture.failedFuture(
new RuntimeException("Unable to provide suggestions for " + cmdLine + " for " + source, e));
}
}