JorelAli / CommandAPI

A Bukkit/Spigot API for the command UI introduced in Minecraft 1.13

Home Page:https://commandapi.jorel.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Updating Suggestions

ImNotStable opened this issue · comments

Description

I'm unsure if this is possible, but I'm curious if this is something that could be added.

I'd like CommandAPI to allow its users to call a method once the suggestions are needed.
Basically, once a user needs suggestions from a command, it calls the method and receives the suggestions.

.includeSuggestions() just calls the method as the command is registered so it's static.

Expected code

No response

Extra details

No response

I believe what you are looking for is already implemented. includeSuggestions takes an ArgumentSuggestions object. The static method ArgumentSuggestions#strings has an overload with the signature strings(Function<SuggestionInfo, String[]> suggestions). This method creates an ArgumentSuggestions object that calls the given function when the suggestions are requested by the client. See https://commandapi.jorel.dev/9.2.0/argumentsuggestions.html for more details. https://commandapi.jorel.dev/9.2.0/stringargumentsuggestions.html#suggestions-depending-on-a-command-sender also has a good example showing this in action.

Is that what you are looking for, or did you mean something else?

Yes, it is. I didn't realize it allowed functions. Thank you.