Solved Error at loading?

Discussion in 'Plugin Help/Development/Requests' started by Sarcry, Aug 15, 2016.

Thread Status:
Not open for further replies.
  1. Offline

    Sarcry

    So I was making another plugin that bans or kicks players.
    When I started the server trying to make it work this is what happend:
    Code:
    [16:12:00] [Server thread/ERROR]: Could not load 'plugins\Punisher.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `me.punisher'
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:42) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.loadPlugins(CraftServer.java:294) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.craftbukkit.v1_10_R1.CraftServer.<init>(CraftServer.java:256) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.PlayerList.<init>(PlayerList.java:70) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.DedicatedServer.init(DedicatedServer.java:184) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:514) [craftbukkit.jar:git-Bukkit-5e5cf84]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.lang.ClassNotFoundException: me.punisher
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:77) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:62) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_101]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_101]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_101]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:40) ~[craftbukkit.jar:git-Bukkit-5e5cf84]
        ... 10 more
    Here's the main class too:
    Code:
    public class KickBan extends JavaPlugin {
     
        public final Logger  logger = Logger.getLogger("Minecraft");
     
        @Override
        public void onEnable() {
            getLogger().info(ChatColor.BOLD.toString() + ChatColor.GREEN + "KickBan has been enabled!");
            getServer().getPluginManager();
        }
        @Override
        public void onDisable() {
         
        }
    
         
     
        @SuppressWarnings("deprecation")
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
            Player player = (Player) sender;
            if(cmd.getName().equalsIgnoreCase("ban")) {
                if(player.hasPermission("kickban.ban")) {
                if (args.length == 0) {
                    player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "WARNING: You must specify a player!");
                }
                if(args.length == 1) {
                    if(Bukkit.getPlayer(args[0]).isOnline()) {
                        Player tpplayer = getServer().getPlayer(args[0]);
                        tpplayer.setBanned(true);
                        tpplayer.kickPlayer(ChatColor.BOLD.toString() + ChatColor.DARK_RED + "You were banned from the server by " + ChatColor.GOLD + player.getName() + "!");
                        Bukkit.broadcastMessage(ChatColor.BOLD.toString() + ChatColor.YELLOW + "The player " + ChatColor.GOLD + tpplayer.getName() + " was banned from the server by " + ChatColor.DARK_PURPLE + sender.getName() );
                    } else {
                        OfflinePlayer oplayer = getServer().getOfflinePlayer(args[0]);
                        oplayer.setBanned(true);
                        Bukkit.broadcastMessage(ChatColor.BOLD.toString() + ChatColor.YELLOW + "The player " + ChatColor.GOLD + oplayer.getName() + " was banned from the server by " + ChatColor.DARK_PURPLE + sender.getName() );
                    }
                }
            }
            }
            if(cmd.getName().equalsIgnoreCase("kick")) {
                if (player.hasPermission("kickban.kick")) {
                    if (args.length == 0) {
                        player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "WARNING: You must specify a player!");
                    }
                    if(args.length == 1) {
                        if(Bukkit.getPlayer(args[0]).isOnline()) {
                            Player tpplayer = getServer().getPlayer(args[0]);
                            tpplayer.kickPlayer(ChatColor.BOLD.toString() + ChatColor.DARK_RED + "You were kicked from the server by " + ChatColor.GOLD + player.getName() + "!");
                            Bukkit.broadcastMessage(ChatColor.BOLD.toString() + ChatColor.YELLOW + "The player " + ChatColor.GOLD + tpplayer.getName() + " was kicked from the server by " + ChatColor.DARK_PURPLE + sender.getName() );
                         
                } else {
                    player.sendMessage(ChatColor.BOLD.toString() + ChatColor.DARK_RED + "The player " + ChatColor.GOLD + args[0] + ChatColor.DARK_RED + "is offline");
                }
            }
        }
            }
            if(cmd.getName().equalsIgnoreCase("unban")) {
                if(player.hasPermission("kickban.unban")) {
                    if (args.length == 0) {
                        player.sendMessage(ChatColor.BOLD + "" + ChatColor.RED + "WARNING: You must specify a player!");
                    }
                    if(args.length == 1) {
                        OfflinePlayer oplayer = getServer().getOfflinePlayer(args[0]);
                        oplayer.setBanned(false);
                        Bukkit.broadcastMessage(ChatColor.BOLD.toString() + ChatColor.YELLOW + "The player " + ChatColor.GOLD + oplayer.getName() + " was unbanned from the server by " + ChatColor.DARK_PURPLE + sender.getName() );
                         
                        }
                    else {
                        player.sendMessage(ChatColor.BOLD.toString() + ChatColor.DARK_RED + "The player " + ChatColor.GOLD + args[0] + ChatColor.DARK_RED + "isn't banned!");
                    }
                }
            }
     
                 
             
         
    
            return false;
        }
    }
    
    Plugin.yml:
    Code:
    name: KickBan
    author: Sarcry
    main: me.punisher.KickBan
    version: 1.0
    commands:
       ban:
          description: Punish players forever.
          usage: /<command> <player>
       kick:
          description: Kick players.
          usage: /<command> <player>
    
     
    Last edited: Aug 15, 2016
  2. Online

    timtower Moderator Moderator

    @Sarcry Please post the entire class file and your plugin.yml
     
  3. Offline

    OTF Catastrophe

    What timtower said ^^

    But the stacktrace is throwing an error with the 'main' string in your plugin.yml. When putting the main class into the string it would be me.punisher.KickBan. It would be the main package name (me.punisher) then the main class that extends JavaPlugin (KickBan -- Hence me.punisher.KickBan).
     
  4. Offline

    Sarcry

    Thanks for the help! I editted the plugin.yml and worked! The thing was on the me.punisher.KickBan
     
  5. Offline

    OTF Catastrophe

    Glad I could help! Make sure you set your thread to 'Solved' so people know it's already been resolved :D
     
Thread Status:
Not open for further replies.

Share This Page