Hi! I've just been learning most of this API as well as java in general lately and, being used to the onPlayerCommand, I was wondering if someone could provide an example of a simple command as I'm not really understanding the transition. I downloaded the source of a different plugin to try and figure it out but it seems like it's not working. From what I understand the onCommand goes into the 'public class ... extends JavaPlugin' So I currently have it in there like this: Code: @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { String[] split = args; String commandName = cmd.getName().toLowerCase(); if(sender instanceof Player) { System.out.println("Command cmd = " + sender); System.out.println("Args = " + args); Player player = (Player) sender; // zone command if(commandName.equals("zone")) { System.out.println("IT'S HERE!"); // zone create if(split[0].equalsIgnoreCase("create")) { if(player.isOp()) { System.out.println("Wow! IT WORKS!??!?"); } } } return false; } Hope someone can help me out, -Mike
I do the same thing! The BigBrother source code has a nice example of using onCommand; Code: @Override public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { try { String[] split = args; String commandName = command.getName().toLowerCase(); ... etc
to make it so that when the command is issued by the player or other source it gets sent to the appropriate plugin.
It goes like this (add this at the end of the plugin.yml) commands: zone: description: A description usage: | /<command> - usage
You can leave all the fields blank if you wish, but they have to appear. This is the version used for ServerPort Code: name: Server Port main: com.raphfrk.bukkit.serverport.ServerPortBukkit version: 261 commands: worldlist: description: usage: pos: description: usage: release: description: usage: getinv: description: usage: serverport: description: usage: drawgate: description: usage: cancelredirect: description: usage: regengates: description: usage: stopcircle: description: usage: circleload: description: usage: Ofc, I probably should include the fields when I am less lazy --- merged: Feb 27, 2011 1:07 PM --- Bukkit will only send you commands if you have registered them.