What is wrong with this code for my spell plugin?

Discussion in 'Plugin Development' started by thok13, Feb 7, 2013.

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

    thok13

    Code:
            if(cmd.getName().equalsIgnoreCase("cast"))
            {
                Player caster = (Player)sender;
               
                if(args.length < 1)
                {
                    sender.sendMessage("Not enough arguments!");
                    return true;
                }
                else if(caster.getItemInHand().getItemMeta().getDisplayName().contains("wand"))
                {
                    if(args[0] == "test")
                    {
                        sender.sendMessage("SPELL");
                    }
                    return true;
                }else{
                    sender.sendMessage("You must be holding a wand!");
                    return true;
                }
            }
    What is wrong with this code? I tried
    Code:
    else if(true)
    instead of
    Code:
    else if(caster.getItemInHand().getItemMeta().getDisplayName().contains("wand"))
    When I do /cast test it doesn't send me the message or give me an error or anything! pleas help me....
     
  2. Offline

    chasechocolate

    Did you register it in your plugin.yml? Also, try removing the "else" from the ItemMeta check. Instead of check if args.length < 1, do args.length == 1.
     
  3. Offline

    thok13

    I will try that. I registered the command in my plugin.yml. Do I have to register the sub commands too?
     
Thread Status:
Not open for further replies.

Share This Page