use of com.mojang.brigadier.Message in project SpongeCommon by SpongePowered.
the class CommandUtil method buildSuggestionsFromCompletions.
public static CompletableFuture<Suggestions> buildSuggestionsFromCompletions(final List<CommandCompletion> commandCompletions, final SuggestionsBuilder builder) {
for (final CommandCompletion completion : commandCompletions) {
final String s = completion.completion();
final Message m = completion.tooltip().map(SpongeAdventure::asVanilla).orElse(null);
if (CommandUtil.INTEGER_PATTERN.matcher(s).matches()) {
try {
builder.suggest(Integer.parseInt(s), m);
} catch (final NumberFormatException ex) {
builder.suggest(s, m);
}
} else {
builder.suggest(s, m);
}
}
return builder.buildFuture();
}
Aggregations