Help needed - Command Registration/Listening

Discussion in 'Plugin Development' started by RyanTheLeach, Mar 12, 2011.

Thread Status:
Not open for further replies.
  1. Offline


    What is the easiest "proper" up-to-date method of reacting to a player/server/console command?

    I've been looking at plugin source, forum posts etc and found contradicting methods....
  2. Offline

    Edward Hand

    There are are 2 (or maybe 3) ways you might see it done.

    One is to hook into the onPlayerCommand event, which will no longer work - it was removed from craftbukkit several versions ago.

    Another would be to use the onPlayerChat event, but I don't really know why you'd do that.

    The propper way is by registering the command in your plugin.yml and having a function:
    public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    in your main JavaPlugin class. That will be called whenever one of your registered commands are used.
  3. Offline


  4. Offline


    If you really need onPlayerCommand, there is onPlayerCommandPreprocess, for those special cases where onCommand doesn't cut it.
Thread Status:
Not open for further replies.

Share This Page