Paper
Paper copied to clipboard
Added PlayerUseBowWithoutProjectileEvent #11668
Added PlayerUseBowWithoutProjectileEvent when a player tries to load a crossbow or draw a bow without having a suitable projectile in their inventory. Makes it possible to set a projectile and enable the player to use the weapon nevertheless.
Maybe PlayerTryUseBowWithoutProjectileEvent would be better?
I already thought about using the PlayerReadyArrowEvent for this. The simplest way to implement the functionality to let a player fire a bow without having an arrow in their inventory seems to be this for me, because when creating a new ItemStack (even with CraftItemStack#asNmsCopy(), to set the arrow from the CraftItemStack used in the event), it would be diffcult to consume the arrow (removing the arrow from the player inventory) when the arrow ist not manipulated by the event. (get the arrow -> create a craftbukkit copy -> call the event with the arrow -> the arrow is not manipulated -> get the arrow from the event -> create a nms copy -> created a new ItemStack although the original one was not changed -> Player#useAmmo() breaks; or am I missing something?)
No you are not missing anything I don't think. I don't see a nice way to have this interact with player ready arrow event either no.
Naming wise, well, realistically this should probably not be limited to bows only. It is a general "PlayerFailedProjectileSearch" or something (shitty name but you get the gist :sweat_smile:) as this is going to be called for crossbows as well.
I'll try to get this PR into a pr party next weekend so I can poke some other maintainers on a better name for this, but I think the functionality this is adding is worth having :+1: