I’m creating a shops plugin and I want to be able to have the items autocomplete-able when pressing tab. I know this is doable when using commands like "give ". Where you can complete online players as well as items. I could type in “dir” press tab, and it autocompletes to “minecraft:dirt”. This may have already been addressed at some point, but I haven’t been active in this forum since
This is what I have. The way that the SpongeAPI is very different to how I’ve been coding in my career. But I’m slowly getting used to it. This is what my command spec looks like
private static CommandSpec sell = CommandSpec.builder()
.description(Text.of("Sell an item to a shop"))
.arguments(
GenericArguments.catalogedElement(Text.of("item"), CatalogTypes.ITEM_TYPE),
GenericArguments.integer(Text.of("quantity"))
)
.executor(new SellCommand()).build();
I’m probably doing this all wrong anyway because it is pretty new to me. If I could get any feedback on this or answers to my question. That would be very appreciated.
If i remeber the default GenericArguments.catalogElement does not have tab completion. If you create your own CommandElement and enable the tab comletion in that CommandElement
With Sponge.getRegistry() and something like getAllOf(ItemTypes.class) you can iterate over every item and associate it with it’s ID. Then you can use that for choices.
But yeah, it’s a pity tab completion isn’t supported.
But I did notice that when using any built in commands you can just start with something like “dir” and it will auto fill to “minecraft:dirt”. Is there anyway I would be able to achieve this?