Skip to content

Overhaul config.yml command definition to look like CommandAPI's CommandTree #22

@willkroboth

Description

@willkroboth

The CommandAPI offers the CommandTree class as an alternative to the CommandAPICommand when registering commands. The syntax for using it to make a command fits the syntax of a yml file, so I think a new command definition system can be built off of the CommandTree.

For example, the following yml file:

commands:
  sayHi:
    permission: greet
    then:
      permission: greet.other
      name: <target>
      type: Player
      executes:
        - do <target>.sendMessage(<sender>.toString().join(" says Hi!"))
    executes:
      - do <sender>.sendMessage("Hi!")

would be roughly equivalent to this CommandTree:

new CommandTree("sayHi")
        .withPermission("greet")
        .then(new PlayerArgument("target")
                .withPermission("greet.other")
                .executes((sender, args) -> {
                    ((Player) args[0]).sendMessage(sender.getName() + " says Hi!");
                })
        )
        .executes((sender, args) -> {
            sender.sendMessage("Hi");
        })
        .register();

This new command-definition system would make it easier for users to create subcommands, and make it easier to develop new features from the CommandAPI.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting releaseIssue will be resolved by the next releaseBaseRelated to the ConfigCommand pluginenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions