Plugin already initialized error

Discussion in 'Spigot Plugin Development' started by BillyBob9876, Jun 14, 2016.

  1. What the heck is this error that happens when I load my plugin? I have never seen this before. I asked someone else with a pretty good amount of experience to look at my code and he couldn't see where it was causing this.

    [15:57:07 ERROR]: Could not load 'plugins\ChestDrop.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:297) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.craftbukkit.v1_10_R1.CraftServer.reload(CraftServer.java:744) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.Bukkit.reload(Bukkit.java:539) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.craftbukkit.v1_10_R1.CraftServer.dispatchCommand(CraftServer.java:646) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.PlayerConnection.handleCommand(PlayerConnection.java:1348) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:1183) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_91]
    at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_91]
    at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:733) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:672) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:571) [spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
    at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at com.billybob9876.plugin.Plugin1.<init>(Plugin1.java:11) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_91]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_91]
    at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_91]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    ... 21 more
    Caused by: java.lang.IllegalStateException: Initial initialization
    at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at com.billybob9876.plugin.Plugin1.<init>(Plugin1.java:11) ~[?:?]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_91]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91]
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_91]
    at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_91]
    at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_91]
    at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.10.jar:git-Spigot-6016ac7-7964365]
    ... 21 more
     
    #1 BillyBob9876, Jun 14, 2016
    Last edited: Jun 16, 2016
  2. Did you extend JavaPlugin in more than one class? If so, I think that is your issue.
     
  3. You probably extended JavaPlugin more than once, if that's not the issue, try updating your Spigot build
     
  4. Make sure you've initialized the plugin in the main class: getServer().getPluginManager().registerEvents(this this);
    Also double check that only one of your classes extends JavaPlugin

    Edit: wow you guys 2 fast 4 me :( ^^
     
  5. Yeah, you did one of two things:
    - Extends the main class with extends Javaplugin - can't do that.
    - Or you used Plugman and tried to load your plugin again - can't do that.
     
  6. There are a lot of really smart people here on Spigot, I'm not surprised
    that people have solutions to problems that this is blinding speeds ^_^
     
  7. Experience :)

    We've all had these issues
     
  8. I don't think he is having a problem registering an event. I'm 99% sure he is extending JavaPlugin more than once.
     
  9. Yus!
     
  10. Only one of my classes extends JavaPlugin, its my main though so maybe that's the problem?
     
  11. Your main classes has to extend JavaPlugin, that's not the issue. Are any of your other classes extending your main class?
     
  12. My main extends JavaPlugin, a command I made implements CommandExecutor and an event implements Listener. That's all I have.
     
  13. Maybe you have the plugin in your plugins directory twice?
     
  14. Make sure you don't have another plugin that uses the same package and class to extend JavaPlugin
     
  15. It is in my plugins folder once and I only have one class extending JavaPlugin
     
  16. Now this is happening to literally all my plugins
     
  17. Even plugins you didn't make?
     
  18. No just ones I made :p
     
  19. When you are making multiple plugins, I assume you are copy/pasting the plugin.yml from each plugin. Are you making sure to change the name of plugin and the location of the Main class in each one.
     
  20. Are you creating another instance of your main class anywhere? If your main class is named "Main", are you calling "new Main()"?