Run an action after playercommand

Discussion in 'Plugin Development' started by imotionzz, Jun 9, 2013.

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

    imotionzz

    Can i run a piece of code when a command is executed fom another plugin?
     
  2. Offline

    chasechocolate

    You can use PlayerCommandPreprocessEvent to check when a player runs a command.
     
  3. Offline

    imotionzz

  4. Offline

    Compressions

    imotionzz
    Code:
    @EventHandler
    public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent e) {
    Player player = e.getPlayer();
    if(e.getMessage().startsWith("/plugins")) {
    e.setCancelled(true);
    player.sendMessage(ChatColor.RED + "No sir!");
    }
    }
     
Thread Status:
Not open for further replies.

Share This Page