Solved Plugin already initialized!

Discussion in 'Plugin Development' started by OLEGSHA, Nov 16, 2014.

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

    OLEGSHA

    Hi everybody,

    I've been making a plugin for a quite long time but I didn't want to test it for some reason, so now, when it's done, I launch it and server throws:
    Code:
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
    I just wonder what that means and what should my mistake look like.
    Thank you

    Here's the whole error:
    Code:
    [13:29:11 ERROR]: Could not load 'plugins\PonyPlugin0.3.jar' in folder 'plugins'
     
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Pl
    ugin already initialized!
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:137) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:313) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:236) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.ja
    va:350) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:31
    2) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [c
    raftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14
    ) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.jav
    a:126) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java
    :424) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:6
    17) [craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader
    .java:98) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftb
    ukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at iwcs.pony.Main.<init>(Main.java:32) ~[?:?]
            at iwcs.pony.Database.<init>(Database.java:18) ~[?:?]
            at iwcs.pony.Main.<init>(Main.java:34) ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ~[?:1.8.0_25]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    ~[?:1.8.0_25]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce) ~[?:1.8.0_25]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_2
    5]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_25]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:52) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:133) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 9 more
    Caused by: java.lang.IllegalStateException: Initial initialization
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader
    .java:101) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:59) ~[craftb
    ukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at iwcs.pony.Main.<init>(Main.java:32) ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    ~[?:1.8.0_25]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    ~[?:1.8.0_25]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Sou
    rce) ~[?:1.8.0_25]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_2
    5]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_25]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.jav
    a:52) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:133) ~[craftbukkit.jar:git-Bukkit-1.7.2-R0.3-b3020jnks]
            ... 9 more
     
  2. Online

    timtower Administrator Administrator Moderator

    OLEGSHA Installed plugins? Plugin.yml? Code?
     
  3. Offline

    Hawktasard

    OLEGSHA
    You most likely have two instances of the same plugin on your server
    (e.g, Plugin 1-0.jar && Plugin 2-0.jar)
     
  4. Offline

    AKZOBIE74

    OLEGSHA if you have something like this in your listener(s) class Main mc = new Main(); thats whats causing your problem. All you need to do is take the code in your listener class except for Main mc = new Main(); and put into your main class just remember to to put "implements Listener" in your main class after "extends JavaPlugin".
     
  5. Offline

    OLEGSHA

    Well, here are the plugins:
    - Essentials
    - PcColoredSigns
    - PonyPlugin0.3 (the one that doesn't launch)
    - WorldEdit
    - WorldGuard

    YML:
    Code:
    name: PonyPlugin
    main: iwcs.pony.Main
    author: OLEGSHA
    description: PonyPlugin adds pony classes from MLP:FiM cartoon
    version: 0.3
    commands:
      pony:
          description: Pony management command
          usage: /<command> <ponyType|current|default|help>
      ponyplgn:
          description: Admin version of /pony command
          usage: /<command> <get|set|reset|gerror|getraw|setraw|totalreset|savedata|reload> [extra args...]
      cast:
          description: Command to cast unicorn spells
          usage: /<command> <hjump|regen|haste|nregen|clear>
    Code (zipped Eclipse project) is attached
     

    Attached Files:

  6. Offline

    Skionz

    OLEGSHA This could also be caused by having two of the same plugin on your server.
     
  7. Online

    timtower Administrator Administrator Moderator

    OLEGSHA nothing attached found. Please use pastebin or github for the code.
    And do you have more plugins with the same main path in your plugin.yml
     
  8. Offline

    OLEGSHA

  9. Offline

    ColonelHedgehog

    Yep, in the last two:

    private Main Main = new Main();

    Remove those, or it'll cause problems.
     
  10. Offline

    AKZOBIE74

    OLEGSHA Yep like i said you can do the "new" thing to the listeners but not the main class it will just create another same class file of your main class and the duplicate has "extends JavaPlugin" and now the console is getting confused on which one is the main class file.
     
  11. Offline

    mythbusterma

    AKZOBIE74

    Perhaps, but the solution to this is certainly not just putting everything in the main class.
     
  12. Offline

    AKZOBIE74

    mythbusterma but thats what i had to do in one of my plugins.
     
  13. Offline

    OLEGSHA

    So, does that mean that I should make only one class per package? I need to get the database FileConfiguration from the main class, so how do I do it if I mustn't use Main class in any other classes?
     
  14. Offline

    mythbusterma

    OLEGSHA

    Please, don't listen to him. He doesn't know what he's talking about.

    You'd be best off learning Java before you try to write plugins, but if you absolutely must know:

    Simply create a constructor in the dependant class that takes an instance of your main class as an argument, then initialize your dependant class from the main class with the main class as the argument. Then you can access any public methods of JavaPlugin from that class.
     
Thread Status:
Not open for further replies.

Share This Page