Solved Plugin allready intialised

Discussion in 'Spigot Plugin Development' started by mrdado243, May 6, 2017.

  1. While i'm trying to test my plugin it throws an error plugin allready intialised the funny part is plugin works but the event "AdventureMode" does not here is the code:

    Code (Text):
    package net.battleheroes.spigot.spacepvp;

    import org.bukkit.Bukkit;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.battleheroes.spigot.spacepvp.cmd.Feed;
    import net.battleheroes.spigot.spacepvp.cmd.Fly;
    import net.battleheroes.spigot.spacepvp.cmd.Heal;
    import net.battleheroes.spigot.spacepvp.cmd.Kits;
    import net.battleheroes.spigot.spacepvp.cmd.Spacepvp;
    import net.battleheroes.spigot.spacepvp.cmd.gamemode;
    import net.battleheroes.spigot.spacepvp.util.AdventureMode;
    import net.battleheroes.spigot.spacepvp.util.ChatFormatting;
    import net.battleheroes.spigot.spacepvp.util.Messages;

    public class MainClass extends JavaPlugin implements ChatFormatting, Messages{


        public void onEnable() {
            Bukkit.getServer().getLogger().info(tag + green + enabled + orange + brand);

            registerCommands();
            registerEvents();

        }

        public void onDisable() {
            Bukkit.getServer().getLogger().info(tag + red + disabled + orange + brand);
        }

        public void registerCommands() {

            getCommand("spacepvp").setExecutor(new Spacepvp());
            getCommand("kit").setExecutor(new Kits());
            getCommand("heal").setExecutor(new Heal());
            getCommand("feed").setExecutor(new Feed());
            getCommand("fly").setExecutor(new Fly());
            getCommand("gamemode").setExecutor(new gamemode());

        }

        public void registerEvents() {
            PluginManager pm = getServer().getPluginManager();

             pm.registerEvents(new AdventureMode(), this);
        }


    }
    i do not have any other plugins with exact same class i always check for that and also the test server directory is empty as well.

    the error:

    Code (Text):
    [07:41:11 ERROR]: Error occurred while enabling SpacePVP v0.4 (Is it up to date?)
    java.lang.IllegalArgumentException: Plugin already initialized!
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.battleheroes.spigot.spacepvp.cmd.Fly.<init>(Fly.java:10) ~[?:?]
            at net.battleheroes.spigot.spacepvp.MainClass.registerCommands(MainClass.java:40) ~[?:?]
            at net.battleheroes.spigot.spacepvp.MainClass.onEnable(MainClass.java:24) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:271) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugin(CraftServer.java:376) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.craftbukkit.v1_11_R1.CraftServer.enablePlugins(CraftServer.java:326) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.MinecraftServer.t(MinecraftServer.java:421) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.MinecraftServer.l(MinecraftServer.java:382) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.MinecraftServer.a(MinecraftServer.java:337) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:544) [spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_121]
    Caused by: java.lang.IllegalStateException: Initial initialization
            at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.battleheroes.spigot.spacepvp.MainClass.<init>(MainClass.java:18) ~[?:?]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_121]
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_121]
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.8.0_121]
            at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.8.0_121]
            at java.lang.Class.newInstance(Unknown Source) ~[?:1.8.0_121]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:301) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:204) ~[spigot.jar:git-Spigot-3fb9445-2b6c9f4]
            ... 2 more
    thanks for help.
     
    • Like Like x 1
  2. I presume your SpacePvP class extends JavaPlugin, it can't do that. Only your main class should extend JavaPlugin


    Sent from my iPhone using Tapatalk
     
  3. oh yes! the fly class does extend it will try thanks!
     
    • Funny Funny x 1