1.16.5 Check with which item a player has killed

Discussion in 'Spigot Plugin Development' started by DanceDown, Jul 12, 2021.

  1. Hello there!
    As the title suggests, I want to know how you can check if a player killed with a netherite sword (with a specific name) or with a bow (with a specific name). The problem is, that the killer might have a bow in the offhand and a sword in the main hand.
    How can I now get the item which was killed with (in the PlayerDeathEvent)? Is there another event which specifies that? Do I have to go the complex way and track the shot arrow from this bow?
     
  2. Probably might want to check EntityDamageByEntityEvent. There, event.getDamager() might return Arrow and Arrow.getShooter() might return Player. If that is true, then victim was shot with a bow. Otherwise, just check for item in main/offhands.
     
    • Like Like x 1
    • Agree Agree x 1
  3. I'll try that. Thank you for your suggestion.
     
    • Like Like x 1