Solved Can't seem to initialize plugin in command class

Discussion in 'Plugin Development' started by Caedus, Jun 20, 2016.

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

    Caedus

    Hi, so i've got my command class set up from onEnable():

    Code:
    getCommand("paystats").setExecutor(new PayStatsCommand());
    And that was fine. Everything was working in that class until I decided I wanted to access the config. To do that I need to initialize the plugin, right? So I did:

    Code:
    private PayPlay plugin;
        private PayStatsCommand(PayPlay plugin){
            this.plugin = plugin;
        }
    And then I could access the config, as per usual. Only now when I go back to my main class, named PayPlay, I get an error with my
    Code:
    getCommand("paystats").setExecutor(new PayStatsCommand());
    The error says the contructor for PayStatsCommand is undefined, which makes sense, but I don't know what to do such that I can access my config in a command class without this error. Any help?
     
  2. Offline

    I Al Istannen

    @Caedus
    Read up on constructors in Java. Here is the offical Oracle trail.

    You need to pass an instance of "PayPlugin". If "PlayPlugin" is your main class, pass "this".
     
    Caedus likes this.
  3. Offline

    Caedus

    @I Al Istannen

    I had already tried that :) Didn't realize that it needed to be public in the PayCommandClass :p

    So that worked, cheers.
     
  4. Offline

    I Al Istannen

    @Caedus
    Oh, totally skipped the access modifier!

    Nice you figured it out!

    Have a nice day and good luck with your plugin :)
     
Thread Status:
Not open for further replies.

Share This Page