Solved Main class

Discussion in 'Plugin Development' started by bodhistrontg, Dec 20, 2013.

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

    bodhistrontg

    So how would i get the main class (The one that extends Java plugin) from a other class in an event without doing Main m = new Main() because that cause an error. Sorry I know noob question.
     
  2. Offline

    Wolfey

    bodhistrontg You can do Bukkit.getPluginManager().getPlugin("pluginName"); and it will return the plugin.
     
  3. Offline

    Aqgorn

    bodhistrontg Import the class, unless I misunderstood you.
     
  4. Offline

    The_Doctor_123

    Wolfey
    That's not exactly the best way to do it. You should just create constructors and pass references.
     
  5. Offline

    Wolfey

    The_Doctor_123, it's can be done that way, but then you'd have to initialize the main class and everything, it's just a big mess. I use getPlugin() all the time and it works fine for me.
     
  6. Offline

    The_Doctor_123

    Wolfey
    You're trying to say that this is a mess?
    Code:java
    1. private Main plugin;
    2.  
    3. public SomeClass(Main instance)
    4. {
    5. plugin = instance;
    6. }
     
  7. Offline

    Wolfey

Thread Status:
Not open for further replies.

Share This Page