Java class for easy command management

Discussion in 'Resources' started by Twisol, Jan 23, 2011.

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

    Twisol

    I just got started with Bukkit today, and I have to say, it's really nice so far. Very clean. :) It took me a bit longer than I expected to learn how to set up commands though, and I felt like streamlining the process, so I devised a way to write a command's implementation in its own class, and reflectively load that class from the plugin.yml file when the server is started.

    https://gist.github.com/b7e40e5a07611738e467

    The gist includes ICommandable (which command implementations must, er, implement), CommandManager (which manages these implementations), and a "Tester" test plugin. What I like about this is that the only place that needs to explicitly know about the commands are the plugin.yml file and the commands themselves.

    I thought I'd share it in case someone else found it useful. Let me know what you think! :D

    EDIT: Probably should have put this in Plugin Development, if that's the case could someone move it there for me? Thanks >_>
     
    hoffm59 likes this.
  2. Offline

    Silentspy

    Moved to appropriate forum :)
     
  3. Offline

    Mixcoatl

    It appears I arrived at the same conclusion you did on command handling. Reflective dispatch of command handlers is much cleaner. I've posted a question related to the long-term usage of YML nodes for command-specific configuration but it doesn't seem to have garnered much interest.
     
  4. Offline

    Twisol

    Based on what I've heard, I think they're going to be overhauling how commands work, so there's always a chance of breaking changes. I actually wrote a patch to pull this into the core (though without the extra redundant manager/command classes from above), but it hasn't had much attention either.
     
  5. Offline

    hoffm59

    Very nice... I'm using it currently and its usefull for hiding references between the classes ;)
     
  6. Offline

    hoffm59

    I have one question: How do the CommandManager handle with aliases??
     
Thread Status:
Not open for further replies.

Share This Page