Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
willkroboth opened this issue Aug 21, 2022 · 0 comments
Labels
Awaiting release Issue will be resolved by the next release Base Related to the ConfigCommand plugin enhancement New feature or request

Comments

@willkroboth
Copy link
Owner

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.

@willkroboth willkroboth added enhancement New feature or request Base Related to the ConfigCommand plugin labels Aug 21, 2022
willkroboth added a commit that referenced this issue Aug 23, 2022
Change ConfigCommandsBuilder to CommandTreeBuilder
Add ArgumentTreeBuilder for handling arguments
Replace ConfigCommandExecutor with ExecutesBuilder for handling command execution
Add FunctionLines package for handling executes parsing and running
Moved InvalidExpressionCommand and its subclasses to package Exceptions.FunctionSyntax
Add classes CompilerState and InterpreterState to hold parsing and execution information
Change method InternalArgument#addArgument to InternalArgument#createArgument
Temporarily disabled ReloadCommandHandler and BuildCommandHandler
@willkroboth willkroboth added the Awaiting release Issue will be resolved by the next release label Nov 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting release Issue will be resolved by the next release Base Related to the ConfigCommand plugin enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant