Apply suggested future-related changes
Co-authored-by: A248 <theanandbeh@gmail.com>
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user