Solved Having trouble with a plugin.yml file..

Discussion in 'Plugin Development' started by Hoppys, Dec 9, 2015.

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

    Hoppys

    Hello! i'm kinda new to bukkit development, this will be my first plugin that i've learnt but i have a slight problem, i can't seem to find the error on why my plugin.yml file isn't working this is what it looks like.. if you've found the problem out, please let me know i would like to know where i've gone wrong. :)

    Plugin YAML

    name: HelloWorld
    main: me.hoppy.helloworld.HelloWorld
    version: 1.0

    Code:
    Code:
    package me.hoppy.helloworld;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class HelloWorld extends JavaPlugin {
     
        @Override
        public void onEnable() {
            System.out.println("Hello world is now enabled.");
        }
    
     
        @Override
        public void onDisable() {
            System.out.println("Hello world is now disabled.");
        }
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
        sender.sendMessage("Hello world!");
            return true;
     
        }
    }
    
    Console ERROR:
    https://gyazo.com/58c46844d697d7b3783c18856aaaad33
     
    Last edited: Dec 9, 2015
  2. Offline

    Zombie_Striker

    @Hoppys Please use the [code ][/code] tags by going into Insert>code.

    BTW: We need the whole error log. That is nothing. Doesn't even show us what line is at fault.

    [Edit] actually looking at your code brings up quite a few concerns:
    1. Bukkit already logs that your plugin has been enabled, so you do not need those lines in your onEnable/disable
    2. If you delete those lines, then the onEnable and onDisable will have nothing in them, meaning you can delete them
    3. You are not currently checking if the command is your command
    4. You plugin.yml does not specify any commands, and as such your onCommand will most likely not fire.
    5. You are always returning true. Return true when the command was a success (operated correctly) Return false if it failed to do something.
    [Second edit] did not see you were new, go here:
    https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
    Last edited: Dec 9, 2015
  3. Offline

    Hoppys

    ok thanks, but from looking at this http://wiki.bukkit.org/Plugin_YAML it's saying that i only need the main, name and version. but i'll try adding them and removing the onEnable as well as the onDisable. i'll let yu know what happens :)

    ahhh i see what you mean, the plugin works now since i put the commands in. Thanks a lot!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Dec 9, 2015
Thread Status:
Not open for further replies.

Share This Page