Initialize new classes

Discussion in 'Plugin Development' started by Welite, May 12, 2014.

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

    Welite

    Hi I have maybe a simple question...
    How can I init more classes ?

    I cant use Shop s = new Shop(); this and than call some methods from Shop class ? It always throw error "Plugin is already initialized"
     
  2. Offline

    rfsantos1996

    Keep the same plugin variable, on the constructor for example:

    Code:java
    1. private final Shop plugin;
    2.  
    3. public Listener(Shop instance) {
    4. this.plugin = instance;
    5. }
    6.  
    7. // now you can use plugin.<method> on this class.


    And on constructor of listener, for example, to register events:

    Code:java
    1. getServer().getPluginManager().registerEvents(new Listener(this), this);
     
  3. Offline

    Shevchik

Thread Status:
Not open for further replies.

Share This Page