Solved Plugin not loading, Plugin already initalized!

Discussion in 'Plugin Development' started by PumpMelon, Sep 16, 2016.

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



    I'm getting the plugin already initalized error, though when I check only my main class extends JavaPlugin and my packages are all align. (I can read stack traces, though theres more than just one error so I don't know if that changes anything. )

    Here is my plugin yml
    name: Honour
    author: PumpMelon
    version: 1.0
    main: me.PumpMelon.Honour.Honour
    I've been trying to solve this for a while to no avail (I used google as well)

    Last edited: Sep 17, 2016
  2. Offline


    @PumpMelon, I can't read that stack trace like that. Please post it with the lines intact.
  3. Offline


    1. You have two copies of the same plugin in the /server/plugins/ directory.
    2. You have multiple plugins with the same "main"
  4. Offline


  5. Offline


    @PumpMelon 2 things that can cause this.

    1. 2 jars of the same plugin
    2. 2 jars that have the same main class and classpath

    There is nothing else that can cause this.
  6. Offline

    timtower Administrator Administrator Moderator

  7. Offline


    This can also happen if

    You are making a new instance of main somewhere.

    Sent from Tapatalk
    Last edited: Sep 17, 2016
  8. Offline


    This happens when you have two plugins with the exact same plugin.yml files, from the name to where the main class is located. Most commonly happens when you have two copies of the same plugin, or in rare instances, you just happened to create a plugin.yml that has the same info as another plugin.

    Second common way, you have 2 classes extending JavaPlugin.

    The third way is another plugin trying to enable a plugin that was already enabled but didn't implement a check to see if it was, not a common thing, but usually can result from plugin manager plugins that are poorly written.

    Where ever the error is occurring at its at line 13 and 22 of
    also notice in the stacktrace that you do have a plugin manager as well, so try it without that plugin manager.
  9. that happens if you have the same directory
    me.PumpMelon.Honour.Honour <--- that part
    in another plugin and both plugins are running in your server
  10. Offline


    Well, not sure if this counts but I do use this a lot.


    Would using HonourMain.myInstance. count as that?

    As for everyone else, my main class is the only thing that extends JavaPlugin. So it isn't that. I deleted all the other plugins on the server, and it still isn't loading. I renamed the source, so now its me.PumpMelon.Honour.HonourMain

    The lines its getting errors on are 16 and 25 (I know its hard to see in this next photo, but that is the loadConfig reference and 16 is my "public class HonourMain extends JavaPlugin"
  11. Offline


    I think I'm going to vomit because of that violation of DRY (*don't repeat yourself). Add just one "if(killer instanceof Player){" above all those if statements, use "Else" statements for each if, and put together all the entities that have the same "Honor" value.

    And yes, you cannot use "new HonourMain()" anywhere. Delete the end bit for line the "public static HonourMain..." line, and only set the instance inside the onEnable(). (BTW, myInstance should be equal to "this", since you are referencing this class)
    bwfcwalshy likes this.
  12. @PumpMelon
    Aha! The problem is that when you make the "myInstance" variable, you make a new instance of the main class! Bukkit does not allow this, the only instance it allows is the one already created by itself. What you should do is make a constructor and inside that define the "myInstance" field. Here's a bit of code to show what I mean
    1. static Object myObject;
    2. public myObject() {
    3. myObject = this;
    4. }

    EDIT: Damnit.. ninja'd by @Zombie_Striker
  13. Offline


  14. Offline


    If your problem has been solved, mark this thread as solved.
  15. Offline

    I Al Istannen

    @PumpMelon @Zombie_Striker
    Just wanted to mention you could switch on Entity#getEntityType() and the use the nifty fallthrough to make these if else statements even more readable and compact.

    Like this:
    1. switch(EntityType) {
    2. case RABBIT:
    3. case CHICKEN:
    4. honour += 2;
    5. break;
    6. case SQUID:
    7. case ZOMBIE:
    8. honour += 1;
    9. break;
    10. }
Thread Status:
Not open for further replies.

Share This Page