InventoryClickEvent not being called

Discussion in 'Spigot Plugin Development' started by BersamBas, Jul 29, 2018.

  1. Registering it (Both are in main class)
    Code (Java):
        getServer().getPluginManager().registerEvents(this, this);
    Event Code:
    Code (Java):
    public void inventoryClick (InventoryClickEvent event) {
        if(event.getInventory().getTitle().equalsIgnoreCase(ChatColor.GREEN + "Necromancer" + ChatColor.GOLD + " Menu")) {
    For some reason whenever I do anything it does not get called. Any ideas why? Please let me know thank you!
  2. Does the class implement Listener?
  3. Code (Java):
    public class main extends JavaPlugin implements Listener
  4. Can you send your whole main class and plugin.yml. Also, I take it there are no console errors?
  5. I never noticed it till now lol. Not the best with errors, but I know for sure it isn't the version or anything, cause other of my plugins work fine using the same API. Any idea for the fix?

    Code (Text):
    [23:45:40 INFO]: [PotatoesNecromancer] Enabling PotatoesNecromancer v1.0
    [23:45:40 ERROR]: Error occurred while enabling PotatoesNecromancer v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins\NECROMANCER V1.0.jar
            at ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at com.Potato.PotatoesNecros.main.onEnable( ~[?:?]
            at ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.t( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.l( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.a( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.DedicatedServer.init( [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at Source) [?:1.8.0_161]
    [23:45:40 INFO]: Server permissions file permissions.yml is empty, ignoring it
    [23:45:40 INFO]: Done (2.511s)! For help, type "help" or "?"
  6. Well this is completely another thing. The plugin is not enabled, so its listener is also not registered. XD

    I bet u are missing "config.yml" in src folder (or src/main/resources folder if u use maven). Please show full code of ur main class if u need further help.
    • Agree Agree x 1
    • Optimistic Optimistic x 1
  7. There are posts and tutorials about how to read errors and stack traces. They're immensely helpful when debugging, that being the point of them. Definitely take some time to get used to them. In short, it tells you what methods are called in order to lead up to the point where the error is thrown. You can usually spot your own class names in the traces, and look at which of your methods triggered an error.

    This error is simply saying that your compiled jar file doesn't contain the default config.yml -- Depending on your IDE and workflow, there are different ways to include it. If you have a resources folder of some sort, your default config will generally go in there. If it's any help, the config should be in the same place as the plugin.yml when it's compiled.
    • Like Like x 1