onPlayerRightClick() - What listener / API function?

Discussion in 'Plugin Development' started by Shay Williams, Jun 14, 2011.

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

    Shay Williams

    Where should I be looking to register an event that detects when a player right clicks another player?
    Thanks.
     
  2. Offline

    Taco

    Put something like this in OnEnable()
    Code:
    pm.registerEvent(Event.Type.PLAYER_INTERACT, playerListener, Priority.Normal, this);
     
  3. Offline

    Shay Williams

    Riiiiiight.

    But I can't figure out how to get the entity you right click, you can only get the block you right click :3.
     
  4. Offline

    nisovin

    Use PLAYER_INTERACT_ENTITY.
     
  5. Offline

    Scetch

    Inside your onPlayerInteractEntity put:

    Entity target = event.getRightClicked();

    Then to check if it's a player do:

    If (target instanceof player) {
    player.sendMessage("You clicked on " + ((Player)target).getName());
    }else{
    player.sendMessage("That isn't a player!");
    }
     
Thread Status:
Not open for further replies.

Share This Page