Root - Level - Command adding

Discussion in 'WIP and Development Status' started by I Al Istannen, Aug 17, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    I Al Istannen

    Hey :)

    Well, I decided to make a new command system. I apologize.
    It is on github here. Yes, the readme is NOT updated. Yes, I am lazy :p

    It is a lot nicer than the old one though, I think (Maybe this time nice enough to end up in the resources section when it is finished xD).

    So, after this abomination which is at the place of an introduction, I can go on with the issue.

    The system works quite nicely in the following manner:
    1. You have an AbstractCommandNode. This is what you extend to make a command.
    2. The CommandTree provides a wrapper around a special kind of this node, the CommandRoot.
      This node is "transparent" and will never be found (in theory). It passes all requests to it's children.
    3. You can register children to this node (or any other)
    4. Once a find is requested (command execute or tabcompletion), the user-entered String (/command args args args) will be split into it's arguments ([args, args, args]) and then passed to the find method of the CommandRoot.
    5. The Root passes the request down to all children
    6. The children pop the first argument from the queue and check if it matches their keyword.
      If yes, they check if the sender has permission to execute the command and ask their children to find it
    7. This just goes on recursively, until there are no more children. Then the best fitting command node (the deepest, even with error) will be returned.
    There also is a small DefaultHelpCommand, which displays the commands in (I think) a quite nice manner and has options (depth, page, entriesPerPage and showUsage). It also supports viewing only part of the tree (e.g. showing just one command or one command and it sub commands).

    But enough to that, on to the real issue (this time I mean it! :p)

    It only works for one command.
    If you have two commands, you will have to create a new command tree and assign it to this command.
    It would be cooler to have the direct children of CommandRoot as actual commands (registered commands, just like in the plugin.yml). Like this (no, I didn't just use PowerPoint *whistles*):


    Does anybody have an idea on how to do this without blowing everything up?

    Tl;Dr: Fix this. (Sorry, I am not create enough to make a tfts (yes, this link is totally minecraft related. Is that even allowed?) tl;dr. I would love to though!)
  2. Offline


    Good job on this.
    One thing I dont get is well, all the features and uses of it. I want a TLDR TLDR of the uses. But I want to see it too when there isn't a lot more to fix. :D
  3. Offline

    I Al Istannen

    Thanks ;)

    I think I have found a solution to the problem described above, now I have another small problem :p

    If it handles multiple top level commands (like /commandOne and /commandTwo), where would you place the help?
    The current help is for the whole tree, so for ALL commands registered to it. It would cover commandOne and commandTwo.
    But when should is be displayed? If you type "/commandOne help" or "/commandTwo help" or both? Any idea on this?

    I will make a more in-depth post explaining everything this "library" offers in a seperate thread in the resources section [or in this if get moved later (xD). Don't know what the procedure is here]

    Now for a quick question, would you prefer a system you can depend on (e.g. like ProtocolLib or CsCoreLib or whatever) or something you can embed in the plugin itself?
  4. Offline


    Great command. Could you please make use case of this root level command.
  5. Offline

    I Al Istannen

    Not quite sure what you mean. I have settled with a solution though. You can see it here. "CommandNavigator" is in this package "me.ialistannen.navigator.commands.CommandNavigator" if you want to look at it too.
Thread Status:
Not open for further replies.

Share This Page