.getRichtClicked()

Discussion in 'Plugin Development' started by Abraham0607, Sep 8, 2012.

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

    Abraham0607

    Hey,

    I'm trying to do a plugin where I need to know which player rightclicks which player.
    I know which player rightclicks, but I don't know how to 'convert' the rightclicked entity
    to a player name...

    Here's some code:
    Where the "XXXXX" is, I don't know what to write.
    I hope somebody could help me and I hope you apologize my mistakes if I made some,
    I'm not English.

    Thanks,
    Abraham0607/PixelAllianz
     
  2. Offline

    Seadragon91

    Player rightclickedPlayer = (Player) event.getRightClicked();

    If you know the entity type you can cast it, in that case a entity to a player.
     
  3. Yes, should work like this:

    Code:
     @EventHandler
    public void testclass(PlayerInteractEntityEvent event) {
    if (event.getRightClicked().getType() == EntityType.PLAYER) {
    Player rightclickedPlayer = (Player) event.getRightClicked();
     
    }
    }
    
     
  4. Offline

    Abraham0607

    Thanks guys!
     
Thread Status:
Not open for further replies.

Share This Page