Need help with my Plugin "Error could not load ... could not find main class

Discussion in 'Plugin Development' started by micdah, Apr 19, 2014.

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

    micdah

    Hello I wantet to make my own plugin but after I added the command x (kill)
    the console always says : ERROR could not load 'plugins\MinelessInfo.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `to.de.mineless.Info.Infomineless'
    Here is the code from the class Infomineless:
    ---------------------------------------------------------------------------------------------------------------------
    Code:
    package to.de.mineless.Info;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Infomineless extends JavaPlugin {
     
        @Override
        public void onEnable() {
            new MinelessEventListener(this);
        }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            // Umwandlung Sender -> Player------------------------------------------------------------------
            Player p =null;
            if(sender instanceof Player){
                p = (Player)sender;
             
                }
            //Kommando "Skype"----------------------------------------------------------------------------
         
            if(cmd.getName().equalsIgnoreCase("skype")){
             
                if(p !=null){
                 
                    p.sendMessage(ChatColor.GREEN + "[Mineless]" + ChatColor.BLUE + "[Skype]" + ChatColor.WHITE + "Bei Fragen adde mich auf Skype:Michaeld.20131");
                    return true;
                }
         
                 
                 
                 
            }
            //Kommando "Info"----------------------------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("Info")){
             
                if(p !=null){
                 
                    p.sendMessage(ChatColor.RED + "Servername: " + ChatColor.GREEN + "Mineless" );
                    p.sendMessage(ChatColor.BLUE + "Owner: " + ChatColor.RED + "Michael" );
                    p.sendMessage(ChatColor.BLUE + "CoOwner: " + ChatColor.GREEN + "KewarLP" );
                 
                }
             
             
            }
         
         
            //Kommando "Hilfe"------------------------------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("hilfe")){
             
                if(p !=null){
                    p.sendMessage("Mit /warps kannst du alle warps sehen und mit /warp (warpname) kannst du dich warpen ");
                 
                 
                 
                }
             
             
            }
             
            //Kommando "x (kill)---------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("x"))    {
                if(p != null){
                    if(p.hasPermission("mineless.x")){
                     
                        if(args.length != 1){
                            return false;
                        }
                        Player targetPlayer = this.getServer().getPlayer(args[0]);
                        targetPlayer.setHealth(0);
                     
                        targetPlayer.sendMessage(ChatColor.GREEN + p.getDisplayName() + ChatColor.RED + " hat dich über ein Komando gekillt!");
                        p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + " wurde erfolgreich gekillt!");
                        return true;
                     
                    }
                }
            }
         
            return false;
     
     
         
            }
    }
     
      
    --------------------------------------------------------------------------------------------

    now it would be really nice if you could explain to me why it wont work.

    Sry for my bad english im from Germany and only 13 years old!
     
  2. Do you set up the plugin.yml properly?
    Does the class have the exact name as it says in the error?
     
  3. Offline

    micdah

    yes , the plugin.yml is okay and its exact the same name
     
  4. Offline

    ItsLeandro

    Change to.de.mineless.Info to to.de.mineless.info (without a capital I). And in the plugin.yml you type: to.de.mineless.info.Infomineless
     
  5. Offline

    micdah

    Okay it works thanks :D

    okay after I changed a little bit the ERROR is there again.
    Code:
    package to.de.mineless.info;
     
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Infomineless extends JavaPlugin {
       
        @Override
        public void onEnable() {
            new MinelessEventListener(this);
           
            initConfig();
           
           
     
           
           
           
        }
       
        private void initConfig(){
            this.reloadConfig();
            this.getConfig().options().header("Hier kannst du Sachen in dem Plugin Mineless einstellen");
            this.getConfig().addDefault("Infomineless.commands.SKYPE.messages.skypename", "Michaeld.20131");
            this.getConfig().options().copyDefaults(true);
            this.saveConfig();
            System.out.println("[MINELESS] Succesfully (re)loaded config.yml");       
           
        }
       
       
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            // Umwandlung Sender -> Player------------------------------------------------------------------
            Player p =null;
            if(sender instanceof Player){
                p = (Player)sender;
               
                }
            //Kommando "Skype"----------------------------------------------------------------------------
           
            if(cmd.getName().equalsIgnoreCase("skype")){
               
                if(p !=null){
                   
                    p.sendMessage(ChatColor.GREEN + "[Mineless]" + ChatColor.BLUE + "[Skype]" + ChatColor.WHITE + "Bei Fragen adde mich auf Skype: " + this.getConfig().getString("Infomineless.commands.SKYPE.messages.skypename"));
                    return true;
                }
           
                   
                   
                   
            }
            //Kommando "Info"----------------------------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("Info")){
               
                if(p !=null){
                   
                    p.sendMessage(ChatColor.RED + "Servername: " + ChatColor.GREEN + "Mineless" );
                    p.sendMessage(ChatColor.BLUE + "Owner: " + ChatColor.RED + "Michael" );
                    p.sendMessage(ChatColor.BLUE + "CoOwner: " + ChatColor.GREEN + "KewarLP" );
                   
                }
               
               
            }
           
           
            //Kommando "Hilfe"------------------------------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("hilfe")){
               
                if(p !=null){
                    p.sendMessage("Mit /warps kannst du alle warps sehen und mit /warp (warpname) kannst du dich warpen ");
                   
                   
                   
                }
               
               
            }
               
            //Kommando "x (kill)----------------------------------------------------------------
            if(cmd.getName().equalsIgnoreCase("x"))    {
                if(p != null){
                    if(p.hasPermission("mineless.x")){
                       
                        if(args.length != 1){
                            return false;
                        }
                        Player targetPlayer = this.getServer().getPlayer(args[0]);
                        targetPlayer.setHealth(0);
                       
                        targetPlayer.sendMessage(ChatColor.GREEN + p.getDisplayName() + ChatColor.RED + " hat dich über ein Komando gekillt!");
                        p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + " wurde erfolgreich gekillt!");
                        return true;
                       
                    }
                }
            }
           
            return false;
       
     
           
            }
    }
     
       
     
     
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  6. Offline

    ItsLeandro

    Show me your plugin.yml please.
     
Thread Status:
Not open for further replies.

Share This Page