I know this is a noob question, but I don't understand why if (commandlabel.equalsIgnoreCase("sz")) { if (args[0] == "join") { player.teleport(new Location(world, x1, y1, z1)); player.sendMessage(ChatColor.GREEN + "You have joined sz!"); } } isn't working. Its supposed to tell the player "You have joined sz!" whenever they type /sz join. There are no errors, but when I type /sz join, it says "unknown command." Please help. Thanks, Lactem
-_- It is in my plugin.yml. Perhaps the format is wrong? I have it like this: commands: sz join: description: makes you join sz usage: /sz join (The spacing is correct, but bukkit forums won't let me space it how I please.)
yep 100% wrong. Code: name: PluginName main: package.name.to.main.class version: 1.0 commands: sz: description: Alias for sz usage: /sz
Thanks. I'll try that out. By the way, I have the name, main, and version, but I didn't see it necessary to include them, as the problem was with commands. Also, what about the join part of /sz join?
The actual command is just /sz. The arguments are everything that comes after it. So in plugin.yml you just put the first word.
I understand, but then where would I put my argument? Here is my code: if (cmd.getName().equalsIgnoreCase("sz")) { if ((args.length >= 1) && (args[0] == ("join"))) { if (args.length == 1) { player.teleport(new Location(world, x1, y1, z1)); player.sendMessage(ChatColor.GREEN + "You have joined sz!"); return true; } } }
Could you please give me an example of what it should look like? If I just leave it at if (cmd.getName().equalsIgnoreCase("join")), then it won't work. Its the same if I leave it at (cmd.getName().equalsIgnoreCase("sz")).
What do you mean "return the name of the command as declared in the plugin.yml?" Do you just want me to give you my whole code and you tell me what to do differently?
Yeah, but I want my command to have a space between "sz" and "join." That isn't working out so well...
When you use a command in game, you type them with your command. As for how you process them, they are passed in as the String array when your onCommand is called.
As defined by the CommandExecutor interface. onCommand methods must have the following signature. Code: onCommand(CommandSender sender, Command command, String label, String[] args) Parameters, are another name for arguments, shortened to args. If you cannot process a String array, I recommend you read this
plugin.yml: Code: commands: sz: description: blah usage /<command> Code:JAVA public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {if(cmd.getName().equalsIgnoreCase("sz") {if(sender instanceof Player) {if(args[0].equalsIgnoreCase("join") {// player typed /sz join}}}}
anyone playing is always able to type that in their chat.... Lactem, put that in code or syntax tags.... EDIT by Moderator: merged posts, please use the edit button instead of double posting.