No Argument Errors

Discussion in 'Plugin Development' started by snake4212, Feb 17, 2013.

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

    snake4212

    This is my line of code:
    Code:
    else if (commandLabel.equalsIgnoreCase("mk")) {
       int page = 1;
       if(args[0].equalsIgnoreCase("2"))page = 2; 
       sendHelp(sender, page);
        }
    There are no errors I just want to know how to make it so if there are no args it sends help page 1
     
  2. Offline

    iBawb

    Why is the command label 'grandpa' when the kit is tank? Maybe that could be a conflict if you copied/pasted the code.
     
  3. Offline

    snake4212

    It is the tank I just havent edited the kit yet but that should cause any errors anyone should it?
     
  4. Use
    Code:
    [code] --- 
    [/CODE]
    Or
    Code:
    [syntax=java] --- [/syntax]
    Your code is not very readable.
     
  5. Offline

    iBawb

    If you have another class named grandpa that has the same command attached it will.
     
  6. Offline

    snake4212

    More Errors! Wooohooo

    Help!!!!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  7. Offline

    iBawb

    if(args.length==0)
     
  8. Offline

    snake4212

    Thanks

    Nevermind it doesn't work
    No errors listed however but when I type it in with with just /mk no args there is internal server error but
    /mk 1
    /mk 2 Work BLOWING MY BRAINS OUT!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  9. Offline

    mastermustard

    maybe because 1 word commands use commandlabel..... args==0 is 2 words
     
  10. Offline

    snake4212

    My problem is that I have a line of code and the arguments are messed up.
    I can write /mk 1 and /mk 2 for example and they work but when you do /mk I want it to display the /mk 1 Help Page this is my line of code if someone can help me fix it. When I do /mk it shows up as Internal error!
    Code:
        else if (commandLabel.equalsIgnoreCase("mk")) {
      int page = 1;
      if(args.length==0)page = 1;
      if(args[0].equalsIgnoreCase("1"))page = 1;
      if(args[0].equalsIgnoreCase("2"))page = 2;
      sendHelp(sender, page);
        }
    return false;
      }
     
      public void sendHelp(CommandSender sender, int page){
      if(page == 1){
          sender.sendMessage(ChatColor.RED + "" + ChatColor.BOLD + "[MooshyKitPVP] " + ChatColor.BLUE + "MooshyKits Help Page 1");
          sender.sendMessage(ChatColor.AQUA +"" +  ChatColor.BOLD + "Kits List:");
          sender.sendMessage(ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "PVP Kit:" + ChatColor.GREEN + "Full Iron Armor and a Diamond Sword!" + ChatColor.DARK_PURPLE + "(/PVP)");
          sender.sendMessage(ChatColor.DARK_GREEN + ""+ ChatColor.BOLD + "Archer Kit:" + ChatColor.GREEN + "Full Leather Armor and a Bow!" + ChatColor.DARK_PURPLE + "(/Archer)");
          sender.sendMessage(ChatColor.DARK_GREEN + ""+ ChatColor.BOLD + "Tank Kit:" + ChatColor.GREEN + "Full Diamond Armor and a Iron Sword!" + ChatColor.DARK_PURPLE + "(/Tank)");
          sender.sendMessage(ChatColor.DARK_RED + "/mk 2 to see next help page");
    }else if(page == 2){
          sender.sendMessage(ChatColor.RED + "" +  ChatColor.BOLD + "[MooshyKitPVP] " + ChatColor.BLUE + "MooshyKits Help Page 2");
          sender.sendMessage(ChatColor.AQUA + "" + ChatColor.BOLD + "Commands:");
          sender.sendMessage(ChatColor.DARK_GREEN + "" + ChatColor.BOLD + "/Lightspeed:" + ChatColor.BLUE + "Run at the speed of light, Speed Potion Level 100!");
    }
      }
    }
     
  11. Offline

    mastermustard

    Code:
    if(args[0].equalsIgnoreCase("1") || commandLabel.equalsIgnoreCase("mk"))page = 1;
     
  12. Offline

    c0mp

    Merged duplicate threads
     
  13. Offline

    snake4212

    Thanks

    Nope

    Someone got skype add me giuseppe42121 HELP ME PLEASE!

    HELP!P!P!P!!

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  14. Offline

    mastermustard

    what do you mean "no" it should work show me the new code

    stop bumping it hasnt been 12 hours

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  15. Offline

    snake4212

    Code:
        else if (commandLabel.equalsIgnoreCase("mk")){
       int page = 1;
       if(args.length==0)page = 1;
       if(args[0].equalsIgnoreCase("1") || commandLabel.equalsIgnoreCase("mk"))page = 1;
       if(args[0].equalsIgnoreCase("2"))page = 2; 
       sendHelp(sender, page);
     
  16. Offline

    mastermustard

    remove the
    Code:
     else if (commandLabel.equalsIgnoreCase("mk")){
      int page = 1;
    thats at the top
     
  17. Offline

    snake4212

    I need that else because it is the 10th command in the plugin so I still need the else if
     
  18. Offline

    mastermustard

    start watching tuorials -_-
    Code:
    else if(args[0].equalsIgnoreCase("1") || commandLabel.equalsIgnoreCase("mk"))page = 1;
       else if(args[0].equalsIgnoreCase("2"))page = 2;
        sendHelp(sender, page);
     
  19. Offline

    snake4212

    Still not working because page isnt a variable the way you set it up
     
  20. Offline

    mastermustard

    why can't you just put what it displays under the command....
    Code:
    }else
    if(args[0].equalsIgnoreCase("1") || commandLabel.equalsIgnoreCase("mk")){
    sender.sendMessage("sum message");
     
    }else
    if(args[0].equalsIgnoreCase("2")){
    sender.sendMessage("sum message");
    }
    your trying to make your code more complicated than it has to be
     
  21. Offline

    snake4212

    I know I feel really dumb :p
     
Thread Status:
Not open for further replies.

Share This Page