Solved Multiple class error?!

Discussion in 'Plugin Help/Development/Requests' started by Maxx_Qc, Apr 26, 2015.

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

    Maxx_Qc

    Hi, today I tried for the first time to make a multiple class plugin but it failed.
    I followed a tuto but noting does it, it gives me erros on startup.
    Code:
    java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at com.commands.maxx.MySQL.<init>(MySQL.java:23) ~[?:?]
        at com.commands.maxx.Main.onEnable(Main.java:63) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:335) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugin(CraftServer.java:355) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.enablePlugins(CraftServer.java:315) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.q(MinecraftServer.java:402) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.k(MinecraftServer.java:370) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.a(MinecraftServer.java:325) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:211) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:494) [spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at java.lang.Thread.run(Unknown Source) [?:1.7.0_75]
    Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at com.commands.maxx.Main.<init>(Main.java:38) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_75]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_75]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_75]
        at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_75]
        at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_75]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at org.bukkit.craftbukkit.v1_8_R1.CraftServer.loadPlugins(CraftServer.java:290) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        at net.minecraft.server.v1_8_R1.DedicatedServer.init(DedicatedServer.java:152) ~[spigot-1.8.jar:git-Spigot-c46583f-0643caa]
        ... 2 more
    
    Thank you
     
  2. Offline

    1Rogue Retired Staff

    Don't make multiple (in this case, any new) instances of your main class.
     
  3. Offline

    Maxx_Qc

    @1Rogue what does this mean? (I'm not that good in english)
     
  4. Offline

    mine-care

    @Maxx_Qc, @1Rogue is right, either pass the main class instance via constructors or use java simpleton
     
  5. Offline

    Maxx_Qc

    @mine-care If I give you my code, could you help me?
     
  6. Offline

    timtower Moderator Moderator

    Moved to Bukkit alternatives
    @Maxx_Qc Just post it
     
  7. Offline

    Maxx_Qc

  8. Offline

    1Rogue Retired Staff

    [​IMG]
     
    Goblom and Maxx_Qc like this.
  9. Offline

    timtower Moderator Moderator

    @Maxx_Qc Only your main class should extend JavaPlugin.
     
    Maxx_Qc likes this.
  10. Offline

    Maxx_Qc

    @timtower Got it, thank you.
    But how can I getConfig() from the second class?
    private String user = getConfig().getString("username");
    Main.getConfig() doesn't work!
     
  11. Offline

    timtower Moderator Moderator

    @Maxx_Qc Please don't use static anyways.
    And constructors can fix that, then you can call mainPlugin.getConfig
     
  12. Offline

    Maxx_Qc

    I got off every Static except private static Plugin plugin;
    mainPlugin.getConfig() doesn't work and Main.getConfig() reports an error : Cannot make a static reference to the non-static methog getConfig() from the type JavaPlugin
    @timtower
     
  13. Offline

    timtower Moderator Moderator

    @Maxx_Qc Don't use static at all, you don't need it here.
    You need to use constructors.
     
  14. Offline

    Maxx_Qc

    @timtower Ok fine, could you send me the constructor for getConfig then?
     
  15. Offline

    timtower Moderator Moderator

    @Maxx_Qc Do you know how constructors work? If so: why not write it your self?
     
  16. Offline

    Maxx_Qc

    @timtower I will just read a tutorial then!
    Solved!
     
  17. Offline

    mine-care

Thread Status:
Not open for further replies.

Share This Page