Hello! I am a reliviely new at coding, and I am not so good. So far, I have created a few commands that I need help with. I got it set up so if I do "/dota" it will send me a message. I really want to make it so I can do something like "/dota help" and it would send me a nother message. I now how to do the command arguments == 1 and stuff, but I dont know how to "select" the command. For an example., I have 2 commands in one class. How do I select a command so that I can add the args? A example code would be very helpfull. Thanks again, - JPG2000
Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { Player player = (Player) sender; if (commandLabel.equalsIgnoreCase("dota")) { if (player.hasPermission("dota.dota")) { //You can change the permission to what you want player.sendMessage("Pong"); // Change pong to what you want } }else if(commandLabel.equalsIgnoreCase("dota")){ if(player.hasPermission("dota.dota")){ if(args[0] == help){ //Computer starts counting arguments at 0 player.sendMessage("Customize help message"); } } } //add another else if here } EDIT: Oh wow, that code was not formatted correctly. JPG, online chat room where we can talk? Skype broke on my computer, had to uninstall it.
MeZTech That code will never enter the second part because of the else if. That args[0]==help needs .equals and quotes.
Im sooooo confuzed! Ok, so If I have multiple commands in one class, how do I specify what command I want to add more args to?