Hello! I came across making this "setting lore on the item when held" code and I encountered some bugs. PHP: public function itemHeld(PlayerItemHeldEvent $event) { $item = $event->getItem(); $player = $event->getPlayer(); foreach ($item->getEnchantments() as $enchantmentInstance) { $enchantment = $enchantmentInstance->getType(); if ($item->getId() === 403 && $enchantment instanceof CustomEnchant) { $enchant = CustomEnchantManager::getEnchantmentByName($enchantment->getDisplayName()); $lore = [ " ", TextFormat::RESET . TextFormat::YELLOW . $enchant->getDescription(), " ", TextFormat::RESET . TextFormat::GRAY . "You need 20 levels to combine!", TextFormat::RESET . TextFormat::GRAY . "Drag'n drop to the item to enchant" ]; if ($item->getLore() === $lore){ } else { $item->setLore($lore); $player->getInventory()->setItemInHand($item); } } } } } The code works perfectly fine on giving the item(setItemInHand), but it doesn't seem to remove the old item. I've also tried removeItem($player->getInventory()->getItemInHand) but didn't work either
Thank you for your answer! However, I forgot to put the prefix as solved.. I've fixed the issue a while ago. But thank you again for your reply!