[Solved]Some questions about commands


I have some questions:

I use CommandSpec, and add arguments with .arguments(GenericArguments.string(KEY)
But what exactly is the key for? Can I use this key later to get what the user typed as this argument?
If yes, how?

In another post, I asked about the testPermission method from CommandCallable.
And the answer was, that I have to call this method by myself.

But now I am wondering how the getSuggestions method works.
Am I right, that I have to call this myself, too?

If yes, how does this work? How can I tell the client what inputs are correct for tab-completion?

  1. It’s posible and in your case id wouls look like this:

2 I don’t think you need to call it and it works like this:

public List<String> getSuggestions(CommandSource source, String arguments) throws CommandException {
        List<String> ret = Lists.newArrayList();
        if(arguments == null || arguments.equals("")) { // argument contains the argument that the user already entered
            ret.add("kill"); // add your suggestions
        } else if(arguments.toLowerCase().equals("kill")) {
        return ret; // return the list

you can also use source to check permissions or cast him to player.

1 Like

Great, it works!
Thank you!

You should try out the new “solved” button! (It looks like a checkbox and it is next to the “like” button)

1 Like

Ah, good to know.

But it is not very good visible if you don’t know it, and I think many new users will oversee it. (like me)

It was a request by the community that we enable it here, instead of adding [SOLVED] to the title manually :smile: