Plugin will not load to server!

Discussion in 'Spigot Plugin Development' started by xUbalubex, May 28, 2018.

  1. Hi, so I have been taking a break from coding for a while and I have come back. I had this error a long time ago but school got in the way so I couldn't fix it. Anyway, the problem is that the plugin isn't actually loading. I looked in the console and the error was

    Code (Text):
    [02:37:15] [Server thread/INFO]: Set PluginClassLoader as parallel capable
    [02:37:15] [Server thread/ERROR]: Could not load 'plugins/MCArcade.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: No public constructor
    I do not know if the public constructor or parallel capable is part of this problem but I could really use some help!

    Code (Text):
    name: MinecraftArcade
    main: me.uba.main
    version: 1.0
    commands:
       mcahelp:
          description: none
          usage: /mcahelp
       mcacreate:
          description: none
          usage: /mcacreate
       mcaedit:
          description: none
          usage: /mcaedit
       mcasetspawn:
          description: none
          usage: /mcasetspawn
       mcadelete:
          description: none
          usage: /mcadelete
       mcasetup:
          description: none
          usage: /mcasetup
       mcainfo:
          description: none
          usage: /mcainfo
       mcajoin:
          description: none
          usage: /mcajoin
       mcasetmission:
          description: none
          usage: /mcasetmission
       mcasetmainspawn:
          description: none
          usage: /mcasetmainspawn
       mcaleave:
          description: none
          usage: /mcaleave
       mcawarn:
          description: none
          usage: /mcaleave
       mcapunish:
          description: none
          usage: /mcaleave
       mcaloadout:
          description: none
          usage: /mcaleave
       mcagui:
          description: none
          usage: /mcaleave
       
    permissions:
        example:
          description: example
          default: op


    https://pastebin.com/t2HBkRN9 - Inventory Save Class
    https://pastebin.com/hf6asCBY - Loadout GUI Class
    https://pastebin.com/GEJxBv0e - Loadouts Class
    https://pastebin.com/6teqZWB2 - Mcamenu Class
    https://pastebin.com/2QmKY1yj - Mcasettings Class
    https://pastebin.com/CGCDKSr1 - WorldManager Class

    The problem is most likely in the main class but I put the other classes just in case. I am sorry if I am wasting your time. I have been trying to figure out this problem for a while now with no luck.
     
  2. MiniDigger

    Supporter

    the error message is pretty clear: you need a public constructor so that bukkit can construct your main class. don't make it private.
     
    • Agree Agree x 3
  3. static main instance = new main();

    Don't do this.

    put 'instance = this' in your onenable instead
     
  4. As first, don't use new main();
    But as second, your error is simple. Change the
    Code (Text):
    private main() { }
     
    to:
    Code (Text):
    public main() { }
     
     
  5. You needn't use a constructor in the Main Class. Do this for getting an instance of the Main
    Code (Java):
    public class Main extends JavaPlugin {

        //declare Instance
        public static Main plugin;

        @Override
        public void onEnable() {
            //Initialize Instance
            plugin = this;
        }
    }
     
  6. That's considered bad practice, I suggest using Dependency Injections
     
  7. JanTuck

    Supporter

    The public field Might, but else it’s fine for bukkit plugins. Some prefer DI some don’t