Solved Its keeps saying its not seeing Main

Discussion in 'Plugin Development' started by BushGamingYT, Jan 17, 2019.

Thread Status:
Not open for further replies.
  1. When I try to use my plugin it gives an error in console but I can't see to fix it.

    Code:
    Code:
    package com.nodupechat.plugin;
    
    import java.util.HashMap;
    
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin implements Listener {
      
        @Override
        public void onEnable() {
            org.bukkit.Bukkit.getPluginManager().registerEvents(this, this);
        }
      
        HashMap<String, Boolean> Chat = new HashMap<String, Boolean>();
        @EventHandler
        public void onChat(AsyncPlayerChatEvent e) {
            String Message = e.getMessage();
            if(Message == Chat.getOrDefault(Message, true)) {
                Player player = e.getPlayer();
                player.sendMessage(ChatColor.GOLD + "You cannot say the same message twice");
            }
            Chat.put(Message, true);
        }
    }
    
    Console:
    Code:
    [00:07:55] [Server thread/ERROR]: Could not load 'plugins\nodupechat.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.nodupechat.plugin.Main'
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:60) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:132) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:327) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.loadPlugins(CraftServer.java:323) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:213) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:697) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: com.nodupechat.plugin.Main
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_191]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:134) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:80) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_191]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_191]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:58) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        ... 7 more
    
    Plugin.yml:
    Code:
    name: NoDupeChat
    version: 1.0
    description: StopsDupeChat
    main: com.nodupechat.plugin.Main
    
     
  2. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT Open the exported jar with a zip program, what is in it?
     
  3. Offline

    timtower Administrator Administrator Moderator

  4. This is what it looks like but I am not sure if I might of unchecked or checked anything by accident, does it look alright? also, I have implemented the spigot.jar and the JavaDoc so I'm not sure about that (also I know your plugin is called "NoDupeChat" but mine was called different, I just changed it to that because it gave me errors and I wondered if it was my name for it)
    View attachment 32102
    @timtower
     
    Last edited: Jan 18, 2019
  5. When i export the jar file i look into what it is actually exporting and it has the src files checked, everything should be working

    Update: I had to tick "Export Java source files and resources", but it was never ticked and still worked
    Update 2: It gives the source file and the rest but still gives error in console:
    [​IMG]
    Any ideas @timtower
     
    Last edited: Jan 20, 2019
  6. All the latest infomation:
    Error:
    Code:
    [16:05:45] [Server thread/ERROR]: Could not load 'plugins\NoDupeChat.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `com.nodupechat.plugin.Main'
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:60) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:132) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:327) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.craftbukkit.v1_13_R2.CraftServer.loadPlugins(CraftServer.java:323) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at net.minecraft.server.v1_13_R2.DedicatedServer.init(DedicatedServer.java:213) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at net.minecraft.server.v1_13_R2.MinecraftServer.run(MinecraftServer.java:697) [Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_191]
    Caused by: java.lang.ClassNotFoundException: com.nodupechat.plugin.Main
        at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_191]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:134) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:80) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
        at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_191]
        at java.lang.Class.forName0(Native Method) ~[?:1.8.0_191]
        at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_191]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:58) ~[Spigot.jar:git-Spigot-518206a-a5b9c7b]
        ... 7 more
    
    Plugin Path/Code/Plugin.yml:
    [​IMG]
    WinRAR of plugin:
    [​IMG]
     
  7. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT Go into the jar, find the main class. Is it there?
     
  8. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT Check the output all output folders
    The java file is useless for the server.
     
  9. I don't know why it keeps making into a java file and not a class, i am just going to reinstall ecplise and see if my settings reset to default
     
  10. Offline

    timtower Administrator Administrator Moderator

    Don't, why the overkill?
    Tick the top box and try again.
    And make sure that there are no errors.
     
  11. @timtower ok, I can't even unistall ecplise anyway xD
    This is what it looks like:
    [​IMG]
    Apparently when I check "Export java files and resources", it exports the package and java file but I never use to have to do this.
    Also, this popped up:
    [​IMG]
     
    Last edited: Jan 22, 2019
  12. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT There is your issue.
    Remove the bin folder from the project directory
     
  13. K @timtower but how did you know there was a bin folder from that error?
     
  14. Offline

    timtower Administrator Administrator Moderator

    "Class files not found"
    Class files means compiled, compiled is bin.
     
  15. Cool @timtower, i test it when i get home, im omw now

    @timtower I deleted the bin file and it still does not work.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    EDIT by Sender: Sorry I am not sure if @s work when you edit posts
     
    Last edited: Jan 22, 2019
  16. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT Same error? Different error?
    What files/folders are in the project root as seen by the project explorer?
     
  17. @timtower same error and this is what they look like:
    [​IMG]
    and:
    [​IMG]
     
  18. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT normal file explorer, not the eclipse one.
    Why do you have two?
     
  19. @timtower 1 is package explorer and the other is a navigator, what do you mean by normal non-ecplise file explorer?
     
  20. Offline

    timtower Administrator Administrator Moderator

  21. i have no clue what that is sorry
     
  22. Offline

    timtower Administrator Administrator Moderator

    Go to my documents.
    Now use that window.
     
  23. @timtower are you just talking about windows folders?
     
  24. Offline

    timtower Administrator Administrator Moderator

    Yes
     
  25. Offline

    timtower Administrator Administrator Moderator

    @BushGamingYT Tried deleting the project (just the project) while maintaining the src and plugin.yml ?
     
  26. @timtower seem to export everything well, I think I might have just had to delete src file and recreate it then add the Main.java to it
     
  27. Offline

    timtower Administrator Administrator Moderator

    Project settings could also have been bad.
     
Thread Status:
Not open for further replies.

Share This Page