Plugin Won't Load

Discussion in 'Spigot Plugin Development' started by VastEmpires, Jan 14, 2019.

  1. Hey. So I am making a Custom Core for a server, and I am getting this error. I already checked the plugin.yml main class and that's not the issue. I've rewritten it twice now and still no change.

    Code (Text):
    Could not load 'plugins\Core.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.riley.Core'
            at<init>( ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin( ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A( [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at Source) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: me.riley.Core
            at Source) ~[?:1.8.0_191]
            at ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_191]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_191]
            at<init>( ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            ... 15 more
  2. Can you show us the plugin's yml file, along with the package structure for your main, and your main class?
  3. Have you setup your source folder correctly?
  4. Code (Text):
    package me.riley;

    import java.util.ArrayList;

    import org.bukkit.entity.Player;

    import me.riley.commands.BanCommands;
    import me.riley.commands.MessageCommand;
    import me.riley.commands.MuteCommands;
    import me.riley.commands.SocialSpyCommand;
    import net.md_5.bungee.api.ChatColor;

    public class Core extends JavaPlugin {

        public static Core get;
        public static ArrayList<Player> socialSpy;

        public void onEnable() {
            get = getPlugin(Core.class);
            socialSpy = new ArrayList<Player>();

        public void onDisable() {


        public void registerConfigs() {

        public void registerCommands() {
            getCommand("msg").setExecutor(new MessageCommand());
            getCommand("tell").setExecutor(new MessageCommand());
            getCommand("message").setExecutor(new MessageCommand());
            getCommand("whisper").setExecutor(new MessageCommand());
            getCommand("w").setExecutor(new MessageCommand());
            getCommand("socialspy").setExecutor(new SocialSpyCommand());
            getCommand("mute").setExecutor(new MuteCommands());
            getCommand("ban").setExecutor(new BanCommands());
            getCommand("tempban").setExecutor(new BanCommands());
            getCommand("unmute").setExecutor(new MuteCommands());
            getCommand("unban").setExecutor(new BanCommands());

        public void registerListeners() {
            getServer().getPluginManager().registerEvents(new JoinLeaveEvent(), this);
            getServer().getPluginManager().registerEvents(new ChatEvent(), this);

        public String cc(String message) {
            return ChatColor.translateAlternateColorCodes('&', message);


    Code (Text):
    name: CosmicCore
    main: me.riley.Core
    author: Riley
    version: 1.0
    description: This is a server core for Cosmic Borders
        description: Message other players!
        description: Alias of message.
        description: Alias of message
        description: Alias of message.
        description: Alias of message.
        description: See what people are saying in their private messages!
        description: Mute a player!
        description: Ban a player from your server!
        description: Tempban a player from your server!
        description: Unmute a player
        description: Unban a player
  5. Why are you calling "core = get plugin(Core.class)" to get itself as an instance? You can just do "core = this"
  6. I'm used to doing getPlugin(Core.class)
  7. Are the classes saved to the output jar?
  8. I would suggest doing something like this for a main class name:
    Example: me.fallenspring.crates.Main
    Sometimes it doesn't read correctly or the ymls arent even being pulled.
  9. Strahan


    I hate using generic crap like "Main". It's personal preference I suppose, but just feels wrong. There is nothing wrong with his name selection.

    OP, show us your JAR file specification screen when you do an export.
    • Agree Agree x 2
  10. you shouldn't use "Core" as a main class. for several reasons:

    1. Professionalism, you want to look like an advanced coder
    2. It may interfere with futher API
    3. It's easier for other dev to access your class if they want to expand your plugin.

    Recommanded name(s):

    • Agree Agree x 1
    • Friendly Friendly x 1
  11. Change
    Code (Text):
    get = getPlugin(Core.class);
    Code (Text):
     get = this

Share This Page