Help?

Discussion in 'Spigot Plugin Development' started by SwagiWagi, Jun 4, 2016.

  1. Hey there,
    My plugin wont load, it says that the main class does not extands JavaPlugin, but it does...

    Thats my code:
    Code (Text):
    public class Core extends JavaPlugin {
    Thats the error:
    Code (Text):
    Could not load 'plugins/Hello.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: main class `me.rom.com.Core' does not extend JavaPlugin
    Any suggestions?
     
  2. 1. Try to import the right JavaPlugin
    2. Show imports
    3. Show package name IN THE CLASS
    4. Re-export
    5. Try to decompile exported jar with jd-gui and see if it extends JavaPlugin.
     
  3. Inkzzz

    Resource Staff

    Or how about putting the right DIR to the main class in the plugin.yml.
     
  4.  
  5. Inkzzz

    Resource Staff

    Show the package name in the class? That makes no sense in solving this issue.
     
  6. My main class:
    Code (Text):
    package me.rom.com;

    import org.bukkit.plugin.java.JavaPlugin;

    public class Core extends JavaPlugin {

        public void onEnable() {
            getLogger().info("Hello there!");
           
        }

        public void onDisable() {
            getLogger().info("Bye there!");
        }
        public void registerCommands(){
            getCommand("Hello").setExecutor(new Commands());
        }
    }
     
    My Commands class:
    Code (Text):
    package me.rom.com;

    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;

    public class Commands implements CommandExecutor {
       
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] arg3) {
            if((label.equalsIgnoreCase("Hello"))) {
                if (!(sender instanceof Player)){
                    sender.sendMessage("Hey! You must be a player to use this command!");
                    return false;
                }
            }
            Player player = (Player) sender;
            PlayerInventory inv = player.getInventory();
           
            inv.clear();
           
            ItemStack ds = new ItemStack(Material.DIAMOND_SWORD);
           
            ds.addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1000000000);
           
            inv.addItem(ds);
            sender.sendMessage(ChatColor.GREEN + "There ya' go!");
            return false;
        }
    }
     
    My plugin.yml:
    Code (Text):
    main: me.rom.com.Core
    version: 1.0
    name: Hello
     
  7. Open the exported jar in jd-gui. Check if it's extending JavaPlugin.
    Open the exported jar in 7Zip or such. Check if Core is under the folders "me" > "rom" > "com"
     
  8. The decompiler having errors:
    Core:
    Code (Text):
    package me.rom.com;

    public class Core
    {
      public void onEnable()
      {
        throw new Error("Unresolved compilation problem: \n\tThe method getLogger() is undefined for the type Core\n");
      }
     
      public void onDisable()
      {
        throw new Error("Unresolved compilation problem: \n\tThe method getLogger() is undefined for the type Core\n");
      }
    }
     
    Commands:

    Code (Text):
    package me.rom.com;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;

    public class Commands
      implements CommandExecutor
    {
      public boolean onCommand(CommandSender paramCommandSender, Command paramCommand, String paramString, String[] paramArrayOfString)
      {
        throw new Error("Unresolved compilation problems: \n\tsender cannot be resolved to a variable\n\tsender cannot be resolved\n");
      }
    }
     
     
  9. Inkzzz

    Resource Staff

    How are you compiling the plug-in?
     
  10. Drag & Drop
     
  11. Inkzzz

    Resource Staff

    No, you have to compile the plug-in out of your IDE.
     
  12. What IDE?
    Maven clean install/Artifact in IntelliJ/Export in Eclipse/Export in Netbeans?
     
  13. Check if package is correct
     
  14. It is.
    IDE? if you mean eclipse I am doing that our of eclipse.
    ?
     
  15. Show us the export settings for Eclipse.
    And buildpath/pom.xml
     
  16. Show me a image of ur workspace dude.. meaby u forgot the pacage completed name
     
  17. Couple things:

    1.
    Bit surprised seeing @stoneminer02 on this thread without quoting me :(.
    2.
    IDE means Integrated Development Environment A.K.A what you do the typy typy in ;).

    Ex.
    Eclipse, IntelliJ, Netbeans.

    3.
    If you took the time to look at any Spigot wiki that shows you how to start a plugin with Spigot, like this one, you wouldn't have needed to post this thread.

    4.
    Don't judge my overuse of the smilies I like them and they are funny.

    5.
    Please don't take any of this personally I'm just a bit fed up with these threads and would like to see them diminished.