Solved My First plugin.

Discussion in 'Plugin Development' started by cnniillaa, Jan 10, 2014.

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

    cnniillaa

    Hello I have owned my own mc server for a while and became very interested in plugins so i decided to learn how to create them..... i started with a tutorial you can find HERE...
    After watching this for what seemed like the 20th time i could not figure out why my plugin is not loading the error and coding will be posted below.


    ----------------------------------------------------------------------------------------------------------------

    package me.cody.HelloWorld;

    import java.util.logging.Logger;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin {
    public final Logger logger = Logger.getLogger("Minecraft");

    public void onEnable(){
    logger.info("[HelloWorld] has been enabled");
    }

    public void onDisable() {
    logger.info("[HelloWorld] has been Disabled"); }


    public boolean onCommand(final CommandSender sender, Command cmd, String commandLabel, String[] arg){
    final Player player = (Player) sender;
    if (commandLabel.equalsIgnoreCase("hello")) {
    player.sendMessage(ChatColor.BOLD + "You typed /hello");
    }

    else if (commandLabel.equalsIgnoreCase("world")) {
    player.sendMessage(ChatColor.BOLD + "You typed /world");
    }
    return false;
    }

    }
    -------------------------------------------------------------------------------------------------------------As you can see its very simple because it is my first one ever attempted..
    ------------------------------------------------------------------------------------------------------------
    This is the error
    [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:52 [Server] INFO at java.lang.Class.forName(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:52 [Server] INFO at java.lang.Class.forName0(Native Method) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at java.security.AccessController.doPrivileged(Native Method) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO at java.net.URLClassLoader$1.run(Unknown Source) ~[?:1.7.0_21]
    10.01 21:09:51 [Server] INFO Caused by: java.lang.ClassNotFoundException: me.cody.HelloWorld.Main
    10.01 21:09:51 [Server] INFO at net.minecraft.server.v1_7_R1.ThreadServerApplication.run(SourceFile:617) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at net.minecraft.server.v1_7_R1.MinecraftServer.run(MinecraftServer.java:424) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at net.minecraft.server.v1_7_R1.DedicatedServer.init(DedicatedServer.java:126) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at net.minecraft.server.v1_7_R1.DedicatedPlayerList.<init>(SourceFile:14) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at net.minecraft.server.v1_7_R1.PlayerList.<init>(PlayerList.java:63) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.<init>(CraftServer.java:233) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.craftbukkit.v1_7_R1.CraftServer.loadPlugins(CraftServer.java:255) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:231) [craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:308) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184) ~[craftbukkit-1.7.2.jar:git-Bukkit-1.7.2-R0.2-b2974jnks]
    10.01 21:09:51 [Server] INFO org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: me.cody.HelloWorld.Main
    10.01 21:09:51 [Server] ERROR Could not load 'plugins/HelloWorld.jar' in folder 'plugins'
    10.01 21:09:51 [Server] INFO This server is running CraftBukkit version git-Bukkit-1.7.2-R0.2-b2974jnks (MC: 1.7.2) (Implementing API version 1.7.2-R0.2)
    10.01 21:09:51 [Server] INFO Starting Minecraft server on 198.27.69.154:25602
    10.01 21:09:51 [Server] INFO Generating keypair
    10.01 21:09:51 [Server] INFO Default game type: SURVIVAL
    10.01 21:09:51 [Server] INFO Loading properties
    10.01 21:09:51 [Server] INFO Starting minecraft server version 1.7.2
    10.01 21:09:47 [Server] INFO Loading libraries, please wait...
    10.01 21:09:47 [Multicraft] Loaded config for "Mod: CraftBukkit 1.7.2 (BETA Build #2974)"
    10.01 21:09:47 [Multicraft] Starting server!
    10.01 21:09:47 [Multicraft] Loading server properties
    10.01 21:09:46 [Multicraft] Server stopped
    ----------------------------------------------------------------------------------------------------------
    It shows that HelloWorld.jar is in there but it wont start up if you have any knowledge please help me and thanks.
     
  2. Offline

    WizKhalifa

    Delete 'final' in this line...

    public boolean onCommand(final CommandSender sender, Command cmd, String commandLabel, String[] arg){
     
    cnniillaa likes this.
  3. WizKhalifa cnniillaa
    He has an invalid plugin.yml.

    Make sure that your plugin.yml is formatted properly. Check the line that says "main:", that is, if you have it, and make sure it matches the package+the main class(one that extends Java). In this case, you would make it like this:
    Code:
    main: me.cody.HelloWorld.Main
    It is CaSe sEnSiTiVe!
    If you still get an error after doing this show me the Plugin.yml.

    EDIT: Didn't read all of the StackTrace. Can you show me what is in the Package Explorer(if your using Eclipse). By that I mean the thingy like this:
    [​IMG]
     
    cnniillaa likes this.
  4. Offline

    cnniillaa

    K i removed it it seems to have the same error?

    K I had that done here is the plugin.yml
    1. name: HelloWorld
    2. main: me.cody.HelloWorld.Main
    3. version: 1.0
    4. description: >
    5. Tutorial plugin!
    6. commands:
    7. hello:
    8. description: says something back!
    9. world:
    10. description: says something back (again)!

    Here is the image Untitled.png Untitled.png

    Thanks!
     
Thread Status:
Not open for further replies.

Share This Page