InvalidPluginException problem with getting class

Discussion in 'Plugin Development' started by Gawdzahh, Jun 6, 2014.

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

    Gawdzahh

    I'm having problem where I need to access a method inside of a class called HashMaps from the main class but the method cannot be static, so I'm using HashMaps hm = new Hashmaps(); then I can use hm.loadHashMaps(); which is the method but when the HashMaps hm = new Hashmaps(); is read it gives a huge error in my console not allowing the plugin to start.

    This is my main class
    Code:java
    1. public class MCU extends JavaPlugin {
    2.  
    3. public static Logger log = Logger.getLogger("Minecraft");
    4. public static MadCityUnderground plugin;
    5. public static Random random = new Random();
    6. HashMaps hm = new HashMaps();
    7.  
    8. @SuppressWarnings("unused")
    9. public void onEnable(){
    10. log.info("MCU Enabled");
    11.  
    12. hm.loadHashMaps();
    13. BukkitTask AutoSaveTask = new Autosave().runTaskTimer(this, 0, 12000);
    14.  
    15. for(String cmd : CMDExecutor.cmdArray){
    16. getCommand(cmd).setExecutor(new CMDExecutor(this));
    17. }
    18.  
    19. PluginManager pm = getServer().getPluginManager();
    20. pm.registerEvents(new Events(this), (this));
    21. }


    I'd post the HashMaps class but it is fairly big, It only contains other methods and it extends JavaPlugin thats it.
     
  2. That's your problem. Only the main class can extend JavaPlugin.
     
    Gawdzahh likes this.
  3. Offline

    Gawdzahh

    So how would I use something that requires JavaPlugin from another class?

    I think I figured it out.
     
  4. Gawdzahh Pass it an instance of your main class.
     
    Gawdzahh likes this.
  5. Offline

    Gawdzahh

    Yep thats exactly what I justs did, Cheers AdamQpzm.
    Thanks for your help.
     
    AdamQpzm likes this.
Thread Status:
Not open for further replies.

Share This Page