Code (Text): @EventHandler public void onEntityHit(EntityDamageByEntityEvent event){ if(event.getDamager() instanceof Arrow){ ((CraftPlayer)event.getEntity()).getHandle().getDataWatcher().set(new DataWatcherObject<>(10, DataWatcherRegistry.b),0); } } I read elsewhere that there's a lack of information about removing arrows and if it's even possible. The code is being executed. The arrows are being removed off the player, but each time, the last arrow isn't removed. I uploaded a video to better understand. In the video, the previous arrow is being deleted but the arrow being fired isn't getting deleted. I need it to delete every one of them... Without the plugin, the arrows would accumulate Thanks
Probable cause is the arrow is being added after the event is called, hence there always being a left-over arrow. Two solutions you could try is either a) run the code after a tick or b) find another event that is called after the arrow is added to the entity.
if you want to control the amount of arrows in any player at all times (for example no arrows, ever), listen for the ENTITY_METADATA (use protocollib) and then use Code (Text): PacketContainer pc = event.getPacket(); List<WrappedWatchableObject> entityData = pc.getWatchableCollectionModifier().read(0); entityData.add(new WrappedWatchableObject(new WrappedDataWatcher.WrappedDataWatcherObject( 10, WrappedDataWatcher.Registry.get(Integer.class)), <amount of arrows here (e.g. 40)> )); to specify the amount of arrows in the player. You should obviously also do some checks as to whether the entity is a player etc.