How do I fix this?

Discussion in 'Plugin Development' started by john55223, Feb 1, 2012.

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

    john55223

    The command always lists the potion help..... would i remove "potion" gunna try that
    if(commandLabel.equalsIgnoreCase("Potion Help") || commandLabel.equalsIgnoreCase("Potion")){
    player.sendMessage(ChatColor.
    GREEN + "/Potion Primary Will send you the list for the primary/base potions");
    player.sendMessage(ChatColor.
    GREEN + "/Potion Secondary Will send you the list for the Secondary potions");
    player.sendMessage(ChatColor.
    GREEN + "/Potion [Name] Will give you recipie/steps to make the potion");
    }


    if(commandLabel.equalsIgnoreCase("Potion Primary")){
    player.sendMessage(
    "Primary potions are: Awkward, Mundane, Thick potion, and potion of Weakness");
    }

    if(commandLabel.equalsIgnoreCase("Potion Awkward")){
    player.sendMessage(ChatColor.
    GREEN + "1.)Fill a Water Bottle with water");
    player.sendMessage(ChatColor.
    GREEN + "2.)Put the water bottle in your brewing stand");
    player.sendMessage(ChatColor.
    GREEN + "Collect a NetherWart, and use the brewing table (placing the netherwart on top)");
    }


    if(commandLabel.equalsIgnoreCase("Potion Mundane")){
    player.sendMessage(ChatColor.
    GREEN + "1.)Fill a Water Bottle with water");
    player.sendMessage(ChatColor.
    GREEN + "2.)Put the water bottle in your brewing stand");
    player.sendMessage(ChatColor.
    GREEN + "3.)Add a piece of RedstoneDust, to the top slot of your brewing stand");
    player.sendMessage(ChatColor.
    GREEN + "4.)Wait for the brewing to be complete");
    }
     
  2. Offline

    Kierrow

    1.) Please try formatting your post better.
    2.) When you are listening for a command, don't use the 'command_label' String.
    It yields too many problems. Instead, use this to figure your stuff out:

    Code:
    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (cmd.getName().equalsIgnoreCase("potion") {
            if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
                //help command
            } else if (args[0].equalsIgnoreCase("primary")) {
                //primary
            } else if (args[0].equalsIgnoreCase("awkward")) {
                //awkward
            } else if (args[0].equalsIgnoreCase("mundane") {
                //mundane
            } else {
                //other i guess
            } 
        } else {
            return false;
        }
       
        return true;
    }
     
  3. Offline

    john55223

    Thank you for all your help. Can you explain to me the difference between the commandlabel, and this. and what the top part means (Below)

    if (cmd.getName().equalsIgnoreCase("potion") {
    if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
     
Thread Status:
Not open for further replies.

Share This Page