WeaponMechanics / MechanicsMain

A New Age of Weapons in Minecraft.
https://www.spigotmc.org/resources/WeaponMechanics.99913/
MIT License
71 stars 26 forks source link

Weapon hits do not seem to trigger PlayerItemDamageEvent #414

Open Indyuce opened 2 months ago

Indyuce commented 2 months ago

Current/Expected Behavior

Weapon hits do lower the vanilla durability bar of items but do not apply the PlayerItemDamageEvent Bukkit event. When player A shoots player B, if player B is wearing an armor item, the durability of the armor item goes down, but no event is called.

I am working on a plugin which implements custom durability for every item. The fact that ItemDamage events are not being called makes it hard for me to update the remaining item custom durability when a player is SHOT by any weapon.

This make senses to align weapon hit durability logic onto corresponding vanilla behaviour with, say, when a player is hit by an arrow. Players shot by an arrow do trigger this event.

Steps To Reproduce

  1. Write a simple plugin that listens to PlayerItemDamageEvents and prints out the content of this event in the console.
  2. Player B is wearing an iron chestplate not marked with the Unbreakable NBT tag.
  3. Player A shoots player B with any weapon, I tried using an AK-47
  4. No console output. Player B does lose vanilla durability points on their item but no ItemDamage event is called.

Log File

When A hits B with an arrow (event gets called)

[19:11:33 INFO]: Indyuce issued server command: /i arrow
[19:11:35 INFO]: Indyuce issued server command: /i bow 1
[19:11:36 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:11:37 INFO]: item damage event Indyuce 1 BOW // player A consuming durability of bow used
[19:11:37 INFO]: Event damage entity PROJECTILE PLAYER damager ARROW
[19:11:37 INFO]: item damage event Indusich 2 IRON_CHESTPLATE // <====== item damage event!!!

When A repeatedly hits B with weapon (no event is called)

[19:12:43 INFO]: Indyuce issued server command: /ml statmod Indusich MAX_HEALTH 100000
[19:12:45 INFO]: Indyuce issued server command: /heal Indusich
[19:12:46 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:46 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: interact event Indyuce RIGHT_CLICK_AIR
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER
[19:12:47 INFO]: Event damage entity ENTITY_ATTACK PLAYER damager PLAYER

latest.log

Anything else?

No response