Plugin Command Not Working

Discussion in 'Plugin Development' started by GRocksMc, Feb 24, 2017.

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

    GRocksMc

    Right now I'm trying to make an application plugin.
    You would use /apply <application> | to apply for a rank on the server

    Java class:
    Code:
    package com.GRocks.ApplicationPlugin;
    
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Apply extends JavaPlugin {
    
        @Override
        public void onEnable(){
         
        }
    
        @Override
        public void onDisable(){
    
        }
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
        {
            if (cmd.getName().equalsIgnoreCase("apply"))
            {
                sender.sendMessage("Hello World!");
                return true;
            }
            return false;
        }
    }
    
    plugin.yml:
    Code:
    name: Applications
    version: 1.0
    main: com.GRocks.ApplicationPlugin.Apply
    When the server starts up it loads fine. but I can't use /apply | it just tells me that it's an unknown command and to do /help. I've even changed it to just say "Hello World!" and it still doesn't work.

    I am using Java Eclipse and there are no errors showing up or anything of the sort.

    I've probably made a very stupid mistake. I've looked for a while and couldn't find anything, so I decided I would ask on the forums. Thank you in advance.
     
    Last edited: Feb 24, 2017
  2. Offline

    MrGeneralQ

    You didn't register the command in your plugin.yml, add the following:

    Code:
    commands:
      apply
    So like this:

    Code:
    name: Applications
    version: 1.0
    main: com.GRocks.ApplicationPlugin.Apply
    commands:
      apply:
     
  3. Offline

    GRocksMc

    Thank you so much, that little thing solved the problem. Now I have to to make the plugin work how it's supposed to, but I don't know where to start.
     
    Last edited: Feb 24, 2017
  4. Offline

    MrGeneralQ

    I suggest to start learning Java first. Most problems here are because of lack on basic Java knowledge
     
    mine-care likes this.
Thread Status:
Not open for further replies.

Share This Page