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 org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:739) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload(Bukkit.java:535) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [Spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: me.riley.Core
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_191]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[Spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[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 org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[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 org.bukkit.plugin.java.JavaPlugin;

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

    public class Core extends JavaPlugin {

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

        @Override
        public void onEnable() {
            get = getPlugin(Core.class);
            socialSpy = new ArrayList<Player>();
            registerConfigs();
            registerCommands();
            registerListeners();
        }

        @Override
        public void onDisable() {

        }

        public void registerConfigs() {
            ConfigManager.cm.createMessages();
            ConfigManager.cm.getMessageConfig().options().copyDefaults(true);
            ConfigManager.cm.createPlayers();
            ConfigManager.cm.getPlayersConfig().options().copyDefaults(true);
            ConfigManager.cm.savePlayersConfig();
            ConfigManager.cm.saveMessagesConfig();
        }

        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);
        }

    }
     
    [​IMG]

    Code (Text):
    name: CosmicCore
    main: me.riley.Core
    author: Riley
    version: 1.0
    description: This is a server core for Cosmic Borders
    commands:
      message:
        description: Message other players!
      tell:
        description: Alias of message.
      msg:
        description: Alias of message
      whisper:
        description: Alias of message.
      w:
        description: Alias of message.
      socialspy:
        description: See what people are saying in their private messages!
      mute:
        description: Mute a player!
      ban:
        description: Ban a player from your server!
      tempban:
        description: Tempban a player from your server!
      unmute:
        description: Unmute a player
      unban:
        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

    Benefactor

    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):

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

Share This Page