Hey. How can i do command, like this: if player type: command name it do something. but i can't do it. I must do commandname and in plugin.yml commandname then it work, but if i try command name(space beetwen command name) and in plugin.yml command name it doesn't work.
Try reading here": http://wiki.bukkit.org/Plugin_Tutorial It explains onCommand and everything you would need for a basic plugin
Ahh i know how to do command but: Code: if(commandLabel.equalsIgnoreCase("command name") { //code } and in plugin.yml: Code: commands: command name: description: description IT DOESN't WORKS. but: Code: if(commandLabel.equalsIgnoreCase("commandname"){ //code } and in plugin.yml: Code: commands: commandname: description: description IT WORKS!!
Yeah you can only specify one words for a command start. Then if you want for example "gg start", then you check args Code: { if (args.length == 0) { p.sendMessage("ERROR"); } else if (args.length == 1) { dostuff(p, args[0]); } else p.sendMessage("ERROR"); } args[0] is the argument after "gg args[0]", then args[1] would be after "gg args[0] args[1]" hope you get it. also i showed how you can pass that arg string to a method too and to check the amount of args after "gg".
i used cmd.getName().equalsIgnoreCase("reload it"); and if i type /reload it it don't work. I will try now HouseMD It still doesn't work. Code: public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String args[]){ Player player = (Player) sender; if(sender instanceof Player == true){ if(commandLabel.equalsIgnoreCase("reload it") && player.hasPermission("reloadit.plg")){ if(args.length == 0) { player.sendMessage(ChatColor.BLUE + "ERROR."); }else if (args.length == 1){ this.reloadConfig(); return true; } } } return false; } OKAY IT WORKS!! Thanks all.
/reload is a default bukkit command, and if you add /reload it, it wont trigger because of the standard /reload try reversing it /it reload or make it one: /reloadit