[Lib] Dynamic CommandAPI

Discussion in 'Resources' started by Not2EXceL, Dec 21, 2013.

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

    ZodiacTheories

  2. Offline

    Flyverse

    Really nice API. I have one question though: What is the best way to handle multiple arguments?
    I did something like the following code to avoid all those annoying if(args.length > something) and if(args[something] equals something) checks, but I ended up with an error everytime I tried to run a command with arguments. Even the method in your example where the "command" is "test.test2.test3" gave me the same error!
    Code:
    @CommandHandler(command = "something")
    public static void something(CommandInfo info){
        do something. works perfectly.
    }
     
    @CommandHandler(command = "something.arg_test", aliases = {"arg_test"})
    public static void something2(CommandInfo info){
        do something. gives out an error.
    }
    
    I wanted to do something like this, so i could have an own method for every argument passed.
    /something arg_test and /arg_test both gave the same error.
    Unfortunately I can't post the error right now since I'm on my mobile phone, but I remember the error being QueuedCommand#getMethod being null.
     
  3. Offline

    Not2EXceL

    Flyverse
    Having the error would be helpful. I can't test/double check anything till later tonight, but it should be working fine. Last I had used it, it was working as appropriate.
     
  4. Offline

    Flyverse

    Okay, I'm home now, here's the testing-code:
    Code:
    @CommandHandler(command = "something")
    public static void something(CommandInfo info){
    System.out.println("Command 'something' executed successfully.");
    }
     
    @CommandHandler(command = "something.arg_test", aliases = {"arg_test"})
    public static void something2(CommandInfo info){
    System.out.println("Command 'something' with argument 'arg_test' executed successfully.");
    }
    Commands executed on the server by me:
    1. /something
    2. /something arg_test
    3. /arg_test

    Log of those three commands:
    The last command, /arg_test, which is a test for the aliases, just gave me back an "unknown command".
    I hope it helps :)


    Edit: I'm pretty sure the error I got this morning was not the same...
     
  5. Offline

    Not2EXceL

    Flyverse
    /arg_test won't work as aliases are for the subcommand
    /something arg_test
    if it had an alias of test
    /something test
    would run the same as the previous

    I made a commit with a fix, but I'm not at my computer to test it. It should be valid code however. I can test later tonight.
     
  6. Offline

    Flyverse

    Oh, ok! Thought the aliases would work on the "whole thing" (Sorry for my bad english. A bit tired right now and stuff). Gonna test the fix and edit the result in this post! And thanks for the really fast answer & fix :).
     
  7. Offline

    Not2EXceL

    Flyverse
    Yeah I realized I was still subList()'ing even when the list was size of 1. Which is just retarded XD. so I put a check to push an empty list if the strings list size was 1

    edit: I need to spend some time and rewrite parts of this api. It was done in 2 nights and hence some parts of code being bad. Just don't have that much time to do it.
     
  8. Offline

    Flyverse

    Yay, it works now! Thank you very much! Really awesome API.
     
  9. Offline

    Not2EXceL

    Flyverse
    I'm glad you like it. Maybe when I do get time to recode it, I'll add support for topLevel aliases e.g. aliases for subcommands that won't require the higher level commands to be typed as well
     
  10. Offline

    samus1221

    Not2EXceL How would I go about checking for an argument that the player essentially types in? Like a message.
     
  11. Offline

    Not2EXceL

    samus1221
    i just realized that my DefaultHandler has that issue. lemme fix it

    --this is what I get for doing this as quickly as I did

    edit: try it now. It was done in github's editor, but there shouldn't be syntax errors. I was sending errors instead of the parent command for processing
     
  12. Offline

    Flyverse

    Not2EXceL
    Hey!
    I experimented a bit today and managed to modify your code a bit to allow TopLevel-Aliases. It is more of a hack than pretty code, but it works - If you want I can send you a pull request on github :)

    Greetings
     
  13. Offline

    Not2EXceL

    Flyverse send a PR and ill take a look at it.
     
  14. Offline

    wreed12345

    Not2EXceL could you possibly generate javadocs to use for this project? I love being able to hover over methods in eclipse and have it tell me what the documentation is

    [EDIT] It seems some methods don't have documentation so I suppose actually documenting them too would be helpful lol
     
  15. Offline

    Not2EXceL

    wreed12345 I'll probably get around to it, after school starts, as then I won't be working anymore
     
  16. Offline

    wreed12345

    Not2EXceL i feel silly asking this but what should I be adding to my server to prevent NoClassDefFoundError's since I am using maven for my project the server would also need a jar but I could not find one anywhere.
    The error: http://pastebin.com/ypsKqYbU
     
  17. Offline

    Not2EXceL

    wreed12345
    The maven provided causes it not to be compiled into your built jar. Check my github there's a repo call commandapi_builds or something. I can't remember if its in the readme or not. You could either DL the build from that Travis repo on my profile. Or you could also get the repo from your local maven repo too. I can provide links or pics when I'm home if you do need them
     
  18. Offline

    wreed12345

    Not2EXceL I know that causes it not to be compiled, so plugin creators usually create a Bukkit plugin that can be loaded on the server to prevent errors like that. But since you don't have one what is the normal way of going about getting the code on the server when using maven? Also I did not see any readmes in that repo
     
  19. Offline

    Not2EXceL

    wreed12345

    I pushed a commit that adds a JavaPlugin extension and the plugin.yml.
     
  20. Offline

    wreed12345

    Just created a little addition to the plugin hopefully it conforms with your standards or if theres anything you want changed comment on the thread: https://github.com/Not2EXceL/CommandAPI/pull/7 hopefully it helps others like me
     
  21. Offline

    Not2EXceL

    The PR looked good, so I accepted. Thanks.
     
  22. Offline

    wreed12345

    @not2excel do you have a to do list of some sort that I could look at and see what I could do? Also do you think it would be a good idea to allow for customizable messages for when someone in command line tries to execute a player only code the default is "This command can only be executed in game." and I am not sure anyone would really want to change it.
     
  23. Offline

    Not2EXceL

    wreed12345
    Customizable messages for those are a bit trivial, as one would have to write a custom handler to change the help etc. anyways.
    As for a todo list: not really, since I have to recode it in general. Been busy with work and paid jobs atm.
     
Thread Status:
Not open for further replies.

Share This Page