Accessing a method from a different class.

Discussion in 'Plugin Development' started by HeadGam3z, May 31, 2014.

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

    HeadGam3z

    I made this public void named startConfig, where it basically just creates the config.yml file and adds in defaults and such. The startConfig is in a different package with the class name of StartConfiguration.

    Now, what I'm trying to do is use startConfig in my onEnable in my Main class, but it doesn't know what/where startConfig is. I tried importing it, but it still couldn't find it, or it just doesn't know what it is.

    Any suggestions?
     
  2. Offline

    Kobting


    Make it a static method and the accesses it by doing <ClassName>.<method>
     
    HeadGam3z likes this.
  3. Offline

    Dealyise

    Exactly! I was about to write the same, but you were faster :p
    Make your method public static and you can access it with <ClassName>.<Method>
     
    HeadGam3z likes this.
  4. Offline

    es359

    Or use a Constructor?
     
    HeadGam3z likes this.
  5. Offline

    Konkz

    I suggest learning Java before jumping into Bukkit API ;)
     
  6. Offline

    fireblast709

    Kobting Don't simply suggest static without explaining what it all is.
     
Thread Status:
Not open for further replies.

Share This Page