Can't initialize plugin

Discussion in 'Spigot Plugin Development' started by Rixterz, Jun 5, 2016.

  1. Hi

    I have 2 plugins, Anticheat and Pumpkin_Forest.

    They run fine separately, but when they're both running at the same time, I get a console error saying "plugin already initialized".

    Anticheat:

    * Main (extends JavaPlugin, implements Listener)
    Code (Text):

    public AntiFly antiFly;
     
        @Override
        public void onEnable()
        {
         
            antiFly = new AntiFly(this);
         
            s.getPluginManager().registerEvents(this, this);
            s.getPluginManager().registerEvents(antiFly, this);
        }
    Antifly class (implements Listener)

    Code (Text):

    Main main;
     
        public AntiFly(Main main)
        {
            this.main = main;
        }
    ------

    Pumpkin Forest:

    * Main (extends JavaPlugin, implements Listener)

    Code (Text):

    Server s = null;
    @Override
        public void onEnable()
        {
         
            s = getServer();
         
            s.getPluginManager().registerEvents(this, this);
                 
        }
    I know there are 2 classes called Main, but they're in different plugins. Shouldn't affect anything.

    Plugin.ymls:

    Code (Text):
    name: Anticheat
    main: me.rixterzisawesome.Main
    version: 1.0
    Code (Text):
    name: Pumpkin_Forest
    main: me.rixterzisawesome.Main
    version: 1.0
     
  2. Hello, to my you me the same thing happened, but solve it in the following way:
    Is that the two plugins are in the same package example plugin1: org.myplugins.Main plugin2: org.myplugins.Main, then brother-in-law console will read the second thinks that already started it, so you have to put the package in each so plugins for example: org.myplugins.pluginname.Main and ready :)
     
  3. That might be because you have twice the same main package and class. Instead, rename your packages to something like me.rixterzisawesome.anticheat.Main
     
  4. @Rixterz this is why packages must be unique per project. Before it tries to load the second plugin, it checks if there's a class named me.rixterisawesome.Main loaded. As it already is loaded, it will reuse the Main class of the first plugin and instantiate it (which doesn't work, as Bukkit has blocked that).