Solved Can't find main class in plugin.yml

Discussion in 'Spigot Plugin Development' started by Jaffaaaa, Feb 15, 2020.

  1. Ok so I've been off spigot for around 8 months and I've come back. Making a very simple plugin to get back into it and I load it up for the first time to get the error:

    Code (Text):
    Could not load 'plugins\PremiumAuction-1.0.0.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `xyz.jaffaaaa.premiumauctions.Core'
    Even though if you look at this screenshot of the decompiled jar... it's all there.

    [​IMG]
    [​IMG]
    I must be doing something really stupid... Any help?

    Edit: I used to make plugins for 1.8-1.9 so maybe something's changed since I switched to 1.15.2?
     
  2. Hi, i don't see the problem but here is a plugin.yml i use on a plugin for 1.15.2 try adding those values in that order
    Code (YAML):
    name: BeeHivesTrees
    main
    : net.minemora.beehivestrees.BeeHivesTrees
    version
    : 1.2
    api-version
    : 1.15
    author
    : Esmorall
    description
    : Add a chance to spawn a beehive when a tree grows from a sapling.
    commands:
     
  3. You can also use getDescription().getName() and getDescription().getVersion() instead of declaring the name and version variable
     
  4. You have to uncheck I think all checkboxes while compiling the plugin with eclipse (except the ones which import your resources). Did you do so?
     
  5. It could be that something is not being included when you are building the artifact I’d check that out make sure it includes your plugin.yml
     
  6. can we see the rest of the error?
     
  7. Code (Text):
    [13:31:28] [Server thread/ERROR]: Could not load 'plugins\PremiumAuction-1.0.0.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `xyz.jaffaaaa.premiumauctions.Core'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:62) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:135) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:334) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:253) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.craftbukkit.v1_15_R1.CraftServer.loadPlugins(CraftServer.java:351) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.DedicatedServer.init(DedicatedServer.java:203) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at net.minecraft.server.v1_15_R1.MinecraftServer.run(MinecraftServer.java:784) [spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
    Caused by: java.lang.ClassNotFoundException: xyz.jaffaaaa.premiumauctions.Core
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_144]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:146) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:92) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_144]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_144]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_144]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_144]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:60) ~[spigot-1.15.2.jar:git-Spigot-800b93f-8160e29]
            ... 7 more
    I recently switched to intelliJ. I'm pretty sure I've done it right but it's still like how it's meant to be when I decompile the jar in Luyten
     
  8. I'm not sure what's the issue, but I suggest using a tool such as WinRar or 7Zip to check the JAR file after exporting it?
     
  9. That's what he's doing in the first post
     
  10. No hes using a java decompiler. Using winrar will show different
     
  11. Maybe your plugin.yml is in the wrong folder? I have the structure src-main-java-<my classes> and src-main-resources and my plugin.yml is in the resources folder
     
  12. Did you remember to replace the jar in your plugins folder after compiling it?
     
  13. The plugin.yml is in the right folder since spigot is trying to load the main class
     
  14. Tried checking on Winrar, looks fine
     
  15. how are you building/exporting your project?
    /e can we see your project structure in your IDE?
    /e2 i know you said it looks fine but can we see an image of the win-rar opening of the file? or just give us the jar and see if we can recreate it?

    /e3 you're not compiling. youre just adding the raw sources into a jar. when i decompile with luyten, compiled source files extensions are .class, not .java
    /e4 the lack of a meta-inf folder supports this claim
     
    #15 Warren1001, Feb 15, 2020
    Last edited: Feb 15, 2020
  16. Make sure in Intellij that you have the correct path, especially if you exported your project from Eclipse to Intellij. Package should be ...src > main > java > xyz.jaffaaaa.premiumauctions > Core.java