Closed rokrieger closed 5 months ago
An example usage for the /shop
command. Code is written in JDK 17.
@Completer(name = "shop", permission = "shop.open.others")
public List<String> categoriesCompletions() {
return Collections.singletonList("open <category> <player>");
}
@Completer(name = "shop.open", permission = "shop.open.others")
public List<String> openCompletions(CommandArguments args) {
if (args.getLength() == 1) {
return ShopManager.INSTANCE.getCategories().stream().map(ShopCategory::getId).toList();
}
if (args.getLength() == 2) {
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList();
}
return List.of();
}
You can do the same for /kingdom
command. Let me know if that is what you want.
It worked fine! Thank you!
Description of the new feature
I don't know if it's already possible as I couldn't find any examples of this in the docs, but it would be nice if there was a way to create an enhanced autocomplete for subcommands.
There would be an autocomplete of the list for the player and an autocomplete for the list of kingdoms. Ex: /kingdom set
Because I'm having to do it this way:
In this other example, I even manage to get the list of categories, but I can't get the list of players in the auto completer afterwards.
![image](https://github.com/Despical/CommandFramework/assets/59859653/3d8dbed8-fb9d-4705-a0b0-a59028203914)
What I thought would be something like:
My code: