How do I create a command event?

Discussion in 'Plugin Development' started by EpicBlargh, Jul 4, 2012.

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


    The one in the Wiki that is provided doesn't work properly and I end up receiving errors. This is starting to get pretty annoying because I can't develop this plugin without this working.
  2. Offline


    The easiest way to setup a function in your main class.

    public boolean onCommand (CommandSender sender, Command command, String label, String[] args)
         if (label.equalsIgnoreCase("test"))
             //You can determine the arguments here.
             player.sendMessage("This is a test.");
             return true;
       return false;
  3. Offline


    Make sure to put your commands in the plugin.yml aswell
  4. Offline


    so i got how to do the commands, but who do you actually make it so that java checks the command inside an event. for example

    public void onPlayerMoveEvent(PlayerMoveEvent event(){
    Some code here
    Some other code here
    (can i put the command here?)
    and so on!

    i sthis posible?
  5. Offline


    PlayerMoveEvent is fired when a player moves, not when they execute a command. They are two separate things. If you want a command to affect movement after the command has been executed, you need to store the user who executed the command in an ArrayList or HashMap, which you can then check inside the PlayerMoveEvent.
Thread Status:
Not open for further replies.

Share This Page