Before you give me an answer read the preamble. Thank you! Preamble: I'm sure that the player is correctly handling the bow in the same inventory slot. I already debugged it in various ways. That said, now I can talk about the problem! Initially, when a player spears an arrow, the bow's durability is set to 340 using the EntityShootBowEvent. After that, there is already in execution a repeating task that repairs the bow but here appears the problem. The durability's value doesn't change while the task tries to fix the bow. How can I fix the problem? Thank you! PHP: public function onEntityShootBow(EntityShootBowEvent $event) { $entity = $event->getEntity(); if ($entity instanceof Player) { $arena = $this->main->getArenaByLevel($entity->getLevel()); if ($arena !== null) { if ($arena->isInArena($entity)) { $bow = $event->getBow(); $bow->setDamage(340); $entity->getInventory()->sendSlot($entity->getInventory()->getHeldItemSlot(), $entity); } } } } PHP: public function onRun(int $currentTick) { foreach ($this->arena->getPlayers() as $player) { $bow = $player->getInventory()->getItem(1); if ($bow->getId() === Item::BOW) { if ($bow->getDamage() > 0) { if (($bow->getDamage() - 70) < 0) $bow->setDamage(0); else $bow->setDamage(($bow->getDamage() - 70)); //TODO: I need to understand why the damage value isn't set.. $player->getInventory()->sendSlot(1, $player); } } } } }} Spoiler: Debug PluginTask started Bow damage = 0 EntityShootBowEvent called -> Bow damage = 340 /*Task cycle*/ Bow damage > 0 ? Yes! -> Bow damage = 340 - 70 (270) /*Another task cycle*/ What should it do: Bow damage > 0 ? Yes! -> Bow damage = 270 - 70 (200) What it does: Bow damage > 0 ? Yes! -> Bow damage = 340 - 70 (270) //And it continues forever without changing damage value...
When you use getItem() you are operating on a clone of the item which is in the inventory, not the actual item itself. You need to set the modified version back into the inventory using setItem() for your changes to appear.