In the plugin.yml you can say for usage command: /<command> Now I was wondering, if I say for example /<command> <faction> Is it possible if I can autocomplete everywhere where <faction> for usage is assigned, autocomplete with this arraylist?
@MieskeB You can make your class implement TabCompleter as well as CommandExecutor, then override the 'onTabComplete' method. Remember to register it as well, with the 'PluginCommand#setTabCompleter(TabCompleter)' method.
@KarimAKL Thank you very much. But I was wondering if I could override a usage tag. So for example if you have to following command in plugin.yml: Code: commands: join: description: Join a faction usage: /<command> <faction> leave: description: Leave a faction usage: /<command> <faction> teleport: description: Teleport to a location usage: /<command> <location> Is it possible to make it autocomplete as soon as it sees that I used <faction> and make it autocomplete with the list of factions and when it seed <location> that it autocompletes with the list of locations, with only hardcoding the tags and not the commands?
@MieskeB I'm not sure i understand you but if you want it to display the factions when you use '/join faction <tab>', then you can do something like this: Code:Java @Overridepublic List<String> onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { List<String> list = new ArrayList<>(); if (args.length == 2) { if (args[0].equalsIgnoreCase("faction")) { List<String> factions = /*A list of all your faction names*/; for (String faction : factions) { if (!faction.toLowerCase().startsWith(args[1].toLowerCase())) continue; list.add(faction); } } } return list;} That code seems pretty nested, but it's just an example.
@KarimAKL Hmm still not what I meant but I don't think it is possible... I will do it this way! Thank you so much for your time!
@MieskeB I just reread your previous post, and thought i might understand. (let me know if i still don't understand what you mean) You can do 'JavaPlugin#getCommand(String)' to get the command in your plugin.yml file, then use 'PluginCommand#getUsage()' to get the usage from your command; then just make some checks for the '<faction>' and add them to the list. I'm not sure if it returns the same but you could probably also use the 'Command' argument from the 'onTabComplete' method, instead of getting the command from the 'JavaPlugin#getCommand(String)'.