Solved InvalidPluginException: Cannot find main class

Discussion in 'Plugin Development' started by DibDibs, Apr 23, 2015.

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

    DibDibs

    I can't run my plugin on my server because of this error. The plugin.yml file has passed all syntax tests and so has my code, Please Help!

    plugin.yml (open)

    name: SafeChest
    main: com.SpinballWhizzer.SafeChest
    #SafeChest is a copyright of HungryCraft
    version: '1.0'
    author: SpinballWhizzer
    load: startup
    description: >
    SafeChest Intergration Plugin
    commands:
    sc addnew:
    description: Adds Players


    Java Plugin Code (open)

    Code:
    package com.SpinballWhizzer.SafeChest;
    
    import java.util.ArrayList;
    import java.util.logging.Logger;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.configuration.file.YamlConfiguration;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    
    import java.awt.List;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    
    public class SafeChest extends JavaPlugin implements CommandExecutor{
       
        public final Logger logger = Logger.getLogger("Minecraft");
        public static SafeChest plugin;
       
        @Override
        public void onDisable(){
           
            PluginDescriptionFile pdfFile = this .getDescription();
            this.logger.info(pdfFile.getName() + (" Disabled"));
           
        }
       
        @Override
        public void onEnable(){
           
            PluginDescriptionFile pdfFile = this .getDescription();
            this.logger.info(pdfFile.getName() + " Version: " + pdfFile.getVersion() + (" Disabled"));
       
        }
           
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
           
            YamlConfiguration yaml = new YamlConfiguration();
           
            if (cmd.getName().equalsIgnoreCase("sc addnew")) {
    
                if (args.length > 0) {
    
                    yaml.createSection(args[1]);
                    ArrayList values = new ArrayList();
                    values.add(args[2]);
                    yaml.set(args[1], values);
                   
    
                } else {
    
                    sender.sendMessage("Not enough arguments!");
    
                }
               
    
               
            }
            return false;
           
        }
    
    }
    


    Screenshots (open)
    [​IMG]


    Thanks for ANY help :)
     
  2. Offline

    benzimmer123

    @DibDibs
    Your package is
    Code:
    com.SpinballWhizzer.SafeChest
    so try adding the mainclass as well (named SafeChest)
    Code:
    com.SpinballWhizzer.SafeChest.SafeChest

    EDIT:
    Also in your code you use
    Code:
     if (cmd.getName().equalsIgnoreCase("sc addnew")) 
    I don't think this would ever work in bukkit. You need to add arguments so you would remove addnew and that would be args[0]. You can research this more on google, they're a lot of posts on it. This is only a quick post as I have to get off now.
     
    Last edited: Apr 23, 2015
  3. Offline

    DibDibs

    Thanks, this worked and helped :)
    Thanks again so much :D
     
  4. Offline

    Zombie_Striker

    Mark as [Solved] if solved.
     
  5. Offline

    DibDibs

    I was just about to do that but forgot, sorry ;)
     
Thread Status:
Not open for further replies.

Share This Page