Essentials icon indicating copy to clipboard operation
Essentials copied to clipboard

Introduce command trees; improve Commandessentials

Open mdcfe opened this issue 2 years ago • 2 comments

Information

This PR closes an internal goal.

Details

Proposed feature:

This implements two separate features (may be split into separate PRs later down the line):

  • [x] Introduce command trees, which allow for nested subcommands to be declared and parsed effectively.
    • Goals: lightweight, incrementally adoptable across new and existing commands as necessary
    • Trees consist of a root node, literal nodes and execute nodes
    • No parsing of argument types is implemented at present
    • Possibly worth exploring cloud/another tree command lib instead of rolling our own
    • [ ] Provide helper methods on command exec context to replicate EssentialsCommand
    • [ ] Think about command node impl in more depth
  • [ ] Rewrite /essentials, splitting complex subcommands into separate classes
    • [x] Replace run and tabComplete impls with tree
    • [ ] Refactor existing subcommand functions
    • [ ] Split out dump into own class (possibly a separate refactor on its own?)

Environments tested:

OS: Windows 11 22H2

Java version: Eclipse Temurin 17.0.6

  • [x] Most recent Paper version (1.19.4, git-Paper-547)
  • [ ] CraftBukkit/Spigot/Paper 1.12.2
  • [ ] CraftBukkit 1.8.8

Demonstration:

This PR should preserve all existing functionality of /essentials.

mdcfe avatar Jun 07 '23 00:06 mdcfe

Dumb question maybe, but wouldn't it be possible to use Mojang's brigadier library for this purpose?

YanisBft avatar Jun 09 '23 20:06 YanisBft

Dumb question maybe, but wouldn't it be possible to use Mojang's brigadier library for this purpose?

Using that severely limits the flexibility we have and reduces the code quality.

JRoy avatar Jun 10 '23 15:06 JRoy