MCTowns

MCTowns

52.4k Downloads

Overhaul CommandExecutor design

jmhertlein opened this issue ยท 3 comments

commented

So, the command executor code is a jungle of switch/case statements. It works, for now. But it's got tons of duplicated logic and it a mess.

I'm replacing it with the help of work I've done on the command framework in my library, EverCoreUtils.

Work is currently being done in the dev-ebcf branch of MCTowns.

commented

What will the change consist of code side?

commented

I've finished a lot of the code changes already. It mainly involved deleting 1.5k lines of switch/case statements and replacing them with some reflection code that takes functions annotated with @CommandMethod and sorts them into a tree structure.

It's really useful because it eliminates a lot of code (as I mentioned, I was able to replace 1500 poorly-structures lines with 100-200 well-structured lines, and it also gives me a lot of helpful things I can do easily at runtime, like:

  • automatic command shortcuts ("/plot add player notch" can just be "/pl a p notch"), and that sort of shortcutting works automatically for all commands
  • if you type /town, it can suggest what things you can type after it (add, remove, list, etc) and can do the same thing as you type out more of the command.

At some point I'll integrate the tab-completion thing Bukkit can do into it, but for now this is mainly a much-needed code cleanup.

commented

Fixed in 171b166