Solved Problem Registering a command.

Discussion in 'Plugin Development' started by Lammazz, Oct 26, 2014.

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

    Lammazz

    First off, I'm not new to java or bukkit by any means but for some reason a command isn't registering for me, I use the same registering method for all my commands and they work fine.

    This is what I'm currently trying...

    OnEnable:
    Code:java
    1. getCommand("achievements").setExecutor(new AchievementsCmd());


    AchievementsCmd Class:

    Code:java
    1. public class AchievementsCmd implements CommandExecutor {
    2.  
    3. public boolean onCommand(CommandSender sender, Command cmd, String CommandLabel, String[] args) {
    4.  
    5. if (cmd.getName().equalsIgnoreCase("achievements")) {
    6.  
    7. Player p = (Player) sender;
    8.  
    9. if (args[0].equalsIgnoreCase("11")) {
    10.  
    11. AchievementsInv.getInstance().openInventory(p, 11);
    12. return true;
    13.  
    14. }
    15.  
    16. }
    17.  
    18. return false;
    19.  
    20. }
    21.  
    22. }


    plugin.yml
    Code:
    commands:
      achievements:
        description: Open the achievements inventory for a player.
    Whenever I do "/help core", core being the plugin name, it doesn't show up the achievements command in the list of commands and if I try to actually do the command it just says the basic no command found, do /help.

    Btw, I know the achievements command is really unsafe it's just for testing.

    EDIT:
    Adding "@Override" before the command boolean fixed it for some reason.
     
  2. Offline

    Googlelover1234

    Any stack traces?
     
  3. Offline

    Lammazz

  4. Offline

    davidp027

    Try
    if(cmd.getCommandLabel().equalsIgnoreCase("achivement"){

    }
     
  5. Offline

    Lammazz

    Shouldn't use command label to check commands, it makes aliases hard to do. And in this case it wouldn't make a difference
     
Thread Status:
Not open for further replies.

Share This Page