Solved No Such Method Error for Command Handler

Discussion in 'Plugin Development' started by alex123099, Feb 11, 2014.

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

    alex123099

    Hi guys,
    I've exported the first beta release of a plugin I'm working on, and there are no errors during compilation. However, when I try to start my testing server with the plugin, I get an NoSuchMethodError when calling the constructor of my CommandHandler class.

    This is the line it says the error occurs at:
    getCommand("qb").setExecutor(new CommandHandler(this));

    This is the CommandHandler constructor:
    Code:java
    1. public CommandHandler(QuestBoard questBoard) {
    2. this.questBoard = questBoard;
    3. }


    I've tried first creating an object of the class and then moving it on to bukkit as a command executor, and the error showed to be on the line where I call the constructor.
     
  2. Offline

    McKiller5252

    Have you tried to remove
    Code:java
    1. getCommand("qb").setExecutor(new CommandHandler(this));

    this from new CommandHandler()?
     
  3. Offline

    alex123099

    McKiller5252
    The CommandHandler constructor requires the QuestBoard class though.
     
  4. Offline

    McKiller5252

    try doing this:

    Code:java
    1. this.getCommand("qb").setExecutor(new CommandHandler());
     
  5. Offline

    alex123099

    McKiller5252
    If you look at the constructor of CommandHandler, it requires the QuestBuilder object, I cannot call a constructor with no parameters as no such constructor exists.
     
  6. Offline

    McKiller5252

    then i am sorry, I can't help you :(
     
  7. Offline

    alex123099

    McKiller5252
    Don't worry.
    Weird thing is that in my other plugin I'm using the exact same code, it works there yet not for this new plugin.

    Solved the issue. Apparently the compiler just didn't like my class name, so once I changed it, everything worked perfectly.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 6, 2016
Thread Status:
Not open for further replies.

Share This Page