[LIB] Annotation based command system

Discussion in 'Resources' started by Minnymin3, Nov 16, 2013.

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

    xTrollxDudex

    mba2012
    It's not a valid Plugin value. Show init code.
     
  2. Offline

    mba2012

    xTrollxDudex
    Code:java
    1. public class QuartzCore extends JavaPlugin {
    2.  
    3. public CommandFramework commandFramework;
    4.  
    5. @Override
    6. public void onEnable() {
    7.  
    8. //Commands
    9. log.info("[QC][STARTUP]Registering commands...");
    10. commandFramework = new CommandFramework(this.plugin);
    11.  
    12. //Other things below
    13. }

    I've removed stuff that has nothing to do with the commands
     
  3. Offline

    xTrollxDudex

    mba2012
    Do new CommandFramework(this)

    Your plugin var is null obviously.
     
  4. Offline

    mba2012

    xTrollxDudex
    Well, that's what I had in the first place, the this.plugin was me messing around to test things. And it didn't appear to work.

    But I do appear to have fixed the issue.
     
  5. Offline

    Minnymin3

    mba2012
    Message me if you have any more issues
     
  6. Offline

    MiniDigger

    Does this override bukkit default commands? I want to create my own plugins command but always bukkits one gets called. Any ideas?
     
  7. Offline

    Minnymin3

    What do you mean? Make your commands unique if you want Bukkit's commands to get called...
     
  8. Offline

    MiniDigger

    Minnymin3 I don't want bukkit's command to get called, mine should get called. For example I want to override bukkit's help command and show one the looks nicer and fits better in the style of my server. Does the lib override the command or do I have to do it manual via an asyncplayerchatevent?
     
  9. Offline

    Minnymin3

    I should override it but I'm not 100% sure. When you make commands the normal way they override bukkit's commands
     
  10. Offline

    xTrollxDudex

    MiniDigger
    You cannot simply override commands like that. You must remove it from SimpleCommandMap listing first, then register your command.
     
  11. Offline

    MiniDigger

    Last edited by a moderator: Jun 5, 2016
  12. Offline

    xTrollxDudex

    MiniDigger
    Show code. Depending on the command, you may have to remove it from 2 or 3 different command maps.
     
  13. Offline

    MiniDigger

    xTrollxDudex I modifyed the private void registerCommand in the framework to unregister existing commands.
    I replaced:
    Code:
    if (map.getCommand(cmdLabel) == null) {
                org.bukkit.command.Command cmd = new BukkitCommand(cmdLabel, plugin);
                map.register(plugin.getName(), cmd);
            }
    with:
    Code:
    if (map.getCommand(cmdLabel) != null) {
        map.unregister(cmdLabel); // something like this
    }
    org.bukkit.command.Command cmd = new BukkitCommand(cmdLabel, plugin);
    map.register(plugin.getName(), cmd);
    I am not shure about the code, i'll update it when I am at home.
    I also tryed to remove all existing commands with map.clearCommands();.

    And what do you mean with removing it from multiple command maps? Are there mulitiple? Never realy looked into that.
     
  14. Offline

    xTrollxDudex

    MiniDigger
    Um. That's not how you do it.... You need to use reflection to access knownCommands or fallbackCommands field in SimpleCommandMap...
     
  15. Offline

    MiniDigger

  16. Offline

    Sir Savary

    Started using this yesterday as a replacement for CommandMethod and I'm loving it. Forked the Github repo and will be submitting a pull request shortly that contains some improvements and fixes :)
     
  17. Offline

    Pizza371

    Minnymin3 is it possible to do commands with arguments as playyer or something?
    Or do will we have to do that seperately

    Btw love this, makes everything so much easier and less headaches :D
     
  18. Offline

    Minnymin3

    It only works for static arguments. You need to do it the way you would have with the old command executors.
     
  19. Offline

    Pizza371

  20. Offline

    Johnn

    Been messing around with your one class CommandFramework and added something that could make registering them easier. The method is from Not2EXceL dynamic command api and I thought is would be cool if all you had to to was call one method in your main class to register all the command annotations in your project. Didn't do much but I thought it was worth sharing. Hope I didn't do anything wrong :)
    Gist: https://gist.github.com/xXJarJarXx/a758c9cfa08de7b36655
     
    Minnymin3 likes this.
  21. Offline

    Minnymin3

    I like that! Might have to add that to my own usages of it ;)
     
  22. Offline

    Not2EXceL

    Johnn you forgot the credits for the ClassEnumerator inner class that I wrote. lol
     
  23. Offline

    Johnn

    Oh ya! Sry bout that. Added the credits. :)
     
  24. Offline

    2016mfransen

    Hey I'm making a plugin full of utilities, am I allowed to embed this with my plugin, it would be awesome!
     
  25. Offline

    Minnymin3

    As long as you provide credit to me sure.
     
  26. Offline

    IDragonfire

  27. Offline

    Minnymin3

Thread Status:
Not open for further replies.

Share This Page