What would be the correct code for, if i was to type /gender <male/female>, and if not equaling these options will result in the command "Gender does not exist." How would i do something like this.
A better way to do it: Code:java if(args[0].equalsIgnoreCase("male") { //Is male}else if(args[0].equalsIgnoreCase("female") { //Is female}else sender.sendMessage("Insert message here"); return true;
gomeow chasechocolate I know how to make a command, I meant not for the first arg but for the 2 arg. So when a player types in /gender female/or male. Instead of allowing them to type anything in. I'm using this for putting it in to the config.yml.
Code:java if(args.length == 2){if(args[1].equalsIgnoreCase("male")){//Male code}else if(args[1].equalsIgnoreCase("female")){//Female code}else{player.sendMessage(ChatColor.DARK_RED + "That is not a gender!");}} That works for if the 2nd arg is male or female
No, that's wrong. Dyrocraft If you had a command: /gender female gender would be the commandLabel(or whatever you called it, I call it label) female is args[0] Args does not include the command
And also, args start at zero, not one. For genders to be saved in the config, I would make a string list in the config; one for male, one for female.
I know, he asked for the second arg, im confused on what he is asking Lol. I know that args[1] is the 2nd arg and that the commandLabel doesn't count as an arg T_T He said he is asking for the second arg not the first, so i thought he meant /gender something male/female
You need to think like you didn't know, because many people think that the command label is included in the args.
Code:java if(args[0].equalsIgnoreCase("male"){ //Is male getConfig().set("genders." + player.getName(), "male"); return true;}else if(args[0].equalsIgnoreCase("female"){ //Is female getConfig().set("genders." + player.getName(), "female"); return true;} else { sender.sendMessage("No."); return true;}
Ok im understanding this a bit more, these examples are not very far from what my looking for. Thank you all for your help, and time