Solved Player killed another Player

Discussion in 'Plugin Development' started by boardinggamer, Nov 19, 2012.

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

    boardinggamer

    I tried using the EntityDamageByEntityEvent and seeing if they lost all there health but it seems to call that multiple times which isn't good.

    can someone tell me a simple way to find out if a player killed another player.
     
  2. Offline

    ZeusAllMighty11

    PlayerDeathEvent

    - Check if both entities are instanceof Player before casting to prevent NPE
    - Make a variable for killer
    - Make a variable for victim

    // do stuff
     
  3. Offline

    boardinggamer

    ZeusAllMighty11
    In playerDeathEvent you can only get the player that died. (That's all I saw anyway)
     
  4. Offline

    ZeusAllMighty11

    EntityDeathEvent ?
     
  5. Offline

    boardinggamer

    same as PlayerDeathEvent
     
  6. Offline

    NinjaW0lf

    Use PlayerDeathEvent(I think EntityDeathEvent works too):
    Code:java
    1. @EventHandler
    2. public void onPlayerDeath(PlayerDeathEvent event) {
    3. Player player = (Player)event.getEntity();
    4. if ((player.getKiller() instanceof Player)) {
    5. //do stuff
    6. }
    7. }
     
  7. Offline

    boardinggamer

    I used an old plugin I made to get the source on how to do it but thanks =D
     
Thread Status:
Not open for further replies.

Share This Page