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

    FirecatHD

    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 :)

    -Firecat
     
  2. Offline

    L33m4n123

    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

    FirecatHD

    L33m4n123

    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

    xTrollxDudex

    FirecatHD
    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

    FirecatHD

    xTrollxDudex

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

    xTrollxDudex

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

    Monkey_Swag

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

    calebbfmv

    Or you could use Reflection :D
     
  9. Offline

    FirecatHD

    xTrollxDudex

    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

    xTrollxDudex

  11. Offline

    FirecatHD

  12. Heres an example:

    //stuff

    Code:java
    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