hi,my command gives an argument error when i run it, but it does run the command Code: else if (cmd.getName().equalsIgnoreCase("donator")) { String player = sender.getName(); if (args.length <1 ){
loderos What error? Can you show some more code and the full error including the stack trace? But I think it is because of Code:java if (args.length <1 ){ With that code you check if there are NO arguments and not if the player entered arguments.
loderos Well, then it would be right, but still doesn't explain the error. If you still have problems with the error please post it here.
To check if it doesn't have any args, wouldn't you use Code:java if(args.length == 0){// do stuff} else if(args.length ???){// meow}
kreashenz Well args.length can't be smaller than 0, so args.length < 1 and args.length == 0 is the same I think.
Minecrell I think Either way, it'd work, I guess.. [EDIT] Woah, the BBCode actually worked.. Wasn't expecting it to.
Code:java if(args.length == 0) {//Tell them they need more argumentsreturn false;}else if(args.length == 1) {//Do the code herereturn true;}else {//Tell them what to do heresender.sendMessage(ChatColor.RED + "Review your argument count!");return false;} The first chunk of code checks if they have no args, the second chunk checks to make sure they only have one argument, while the third is an else statement, so that if their argument length is anything else, it sends them the message telling them the command. wow, people replied fast XD EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I also don't think you should return false, after any case.. I don't use it, but I guess it might just be a habit for me.
yeah, I just learned code that way, but i also don't add in the annoying usage message in the plugin.yml, I prefer to tell them manually.