I got an error?!

Discussion in 'Plugin Help/Development/Requests' started by Wingas, Jun 17, 2015.

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

    Wingas

  2. Offline

    NathanWolf

    Can you post your source code?

    Something is either weird with your plugin.yml, or your main class.
     
  3. Offline

    poepdrolify

    Your path to the main class in the plugin.yml is wrong, make sure it is correct
     
  4. Offline

    Ruptur

    @Wingas
    You got an InvalidPluginException which by the looks of it means that you didnt do your plugin.yml properly
    To be precise, your main plugin class cant be found in the package 'weed'
     
  5. Offline

    Wingas

    name: WeedPlugin
    main: weed.main.main
    version: 1.0
    description: RealLife



    here it is
     
  6. Offline

    NathanWolf

    And what does your main class look like?

    Is it called "main" (shudder) and in the package weed.main?
     
  7. Offline

    Wingas

  8. Offline

    NathanWolf

    Why is the log complaining about the class "weed.main" if you've got "weed.main.main" in your plugin.yml? That seems weird.

    And then later you've got a "org.bukkit.plugin.InvalidPluginException" from what looks like the right class- do you maybe have two different versions of your plugin in your plugins folder?

    And does your main class have a default constructor, extends JavaPlugin?
     
  9. Offline

    Ruptur

    @Wingas
    If your main.java file is in a package called weed.main then your plugin.yml should look like
    Code:
    name: pluginName
    main: weed.main.main
    
    Notice the main.java file is location INSIDE the package 'weed.main' not 'weed'.

    The 'main' in the plugin.yml is telling the pluginloader where to find your main class.

    So it should be in the format : <package>.<class>
    what you put earlier was just <package> and was missing the <class>

    Hope this clears things up for you!
    Like if i helped :)

    EDIT:
    You also got AbnormalPluginTypeExpection
    Post your main class
     
    Last edited: Jun 17, 2015
  10. Offline

    Wingas

  11. Offline

    Ruptur

    @Wingas
    You cannot initiate your plugin class.
    Bukkit intiates your plugin for you and calls the #onEnable() method so you dont need to initiate it
    You have a constructor taking Plugin as an arugment which is pointless because you already have a plugin instance.

    To fix:
    Remove the constructor because that is unnecessary, you can put code from the constructor to #onEnable()
     
    Wingas likes this.
  12. Offline

    Wingas

  13. Offline

    Drkmaster83

    @Wingas
    The man's instructions are pretty straightforward. Remove the constructor, and put the code that was inside of it in your onEnable() method.
     
    Wingas likes this.
  14. Offline

    Ruptur

    @Drkmaster83
    How do you know im a man :p ~ jk jk

    @Wingas
    Honestly bro if you cannot figure out the problem (also explained in my previous post) it might be time for you to revisit your java books.

    To FIX:
    (Please only look at this if you have tried everything to fix your problem. It is proven that you learn best if you can fix your mistakes yourself)

    Firstly Remove the constructor and move code in there to the #onEnable() method
    Code:
    public void onEnable() {
        this.getServer().getPluginManger().registerEvents(this, this);
            inv = Bukkit.getServer().createInventory(null, 9, "Weed leaf");
           
            c = createItem(Material.PISTON_EXTENSION, ChatColor.GREEN + "Grinder", 0, "testa"," test");
            s = createItem(Material.ENDER_PORTAL_FRAME, ChatColor.YELLOW + "Sell to black market", 0, "testa"," test");
            a = createItem(Material.ANVIL, ChatColor.RED + "Adventure", 0, "testa"," test");
           
            inv.setItem(2, c);
            inv.setItem(4, s);
            inv.setItem(6, a);
    }
    
    If you need to get your Plugin instance, in your class you can 'this'

    Secondly you can convert your ItemStack variables to local (unless you are planning to use them). plus there is not need for you to store them anyways.

    Code:
    public void onEnable() {      
             ..........
    
            inv.setItem(2, createItem(Material.PISTON_EXTENSION, ChatColor.GREEN + "Grinder", 0, "testa"," test");
            inv.setItem(4, createItem(Material.ENDER_PORTAL_FRAME, ChatColor.YELLOW + "Sell to black market", 0, "testa"," test");
            inv.setItem(6, createItem(Material.ANVIL, ChatColor.RED + "Adventure", 0, "testa"," test");
    }
    
     
    Wingas likes this.
  15. Offline

    Wingas

    got it, thanks
     
Thread Status:
Not open for further replies.

Share This Page