Problem with command arguments in separate classes!

Discussion in 'Plugin Development' started by FirecatHD, Mar 2, 2014.

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


    So i am having two classes that have the same command, but with different arguments.
    The problem is that one of the commands overwrites the other, so i think i have to get the command from mainclass, but i have no idea how to do that .-.

    I hope someone understand what i mean, and can help me :)

  2. Offline


    why not make it both in one class?

    Because AFAIK when you "re-register" the command, you, as you said, probably overwrite it since you tell first that

    getCommand("MyCommand").setExecutor(new CommandClass());
    getCommand("MyCommand").setExecutor(new SecondCommandClass());

    with that you basicly overwrite the old Executor.. So put both in one class and done
  3. Offline



    I can do that, but the two classes are way to long ._. I have to have them separated.

    bump .-. Really? Anyone?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 7, 2016
  4. Offline


    Less than 24 hours -_-

    Again, if you register them in two classes, it will only do the function in the second class registered.
  5. Offline



    Ohh sorry .-. But there have to be a workaround .-. The classes are just to big and everything will get messy.
  6. Offline


    Nope. Put seperate parts of it in seperate classes and seperate methods and call them.
  7. Offline


    It wont. I have a plugin with 1 class and over 1000 lines of code.
  8. Offline


    Or you could use Reflection :D
  9. Offline



    Yes that is what a need :) Can you tell me an example on how to do this?
    Btw, thx every1 else that answered :3
  10. Offline


  11. Offline


  12. Heres an example:


    1. if(cmd.getName().equalsIgnoresCase("hi"))
    2. {
    3. if( args[0].equalsIgnoresCase("me"))
    4. {
    5. Argumentcmd argcmd;
    6. argcmd.useArgMe
    7. }
    8. }

    Then put the argument code in a method public void and do the rest
    calebbfmv likes this.
Thread Status:
Not open for further replies.

Share This Page