Incendo / cloud

Command framework & dispatcher for the JVM
https://cloud.incendo.org
MIT License
433 stars 54 forks source link

Issue with String Suggestions in CommandComponent.Builder#suggestionProvider #706

Closed Syrent closed 7 months ago

Syrent commented 7 months ago

When trying to show suggestions for text inputs using SuggestionProvider.suggestingStrings, the suggestions don't appear as expected. The provided code snippet illustrates this issue, where the suggestions for arguments aren't displayed correctly. However, switching to a different method, SuggestionProvider#suggestionsFuture, solves this problem, as shown in the subsequent code snippet. Code Snippet (1):

            optional("leader", StringParser.stringParser()) {
                suggestionProvider(SuggestionProvider.suggestingStrings(Bukkit.getOnlinePlayers().map { it.name }))
            }

Result (1): image Code Snippet (2):

            optional("leader", StringParser.stringParser()) {
                suggestionProvider { _, _ ->
                    CompletableFuture.completedFuture(Bukkit.getOnlinePlayers().map { Suggestion.suggestion(it.name) })
                }
            }

Result (2): image

Syrent commented 7 months ago

After testing this with both required and optional arguments, it appears that the issue only occurs with optional arguments.

jpenilla commented 7 months ago

The server will have no players at command registration time.