Hey, so Im making custom enchantments and I want to replace (Ex Haste 1 is already in the name) With Haste 2, so Here's what I do PHP: if($item->hasEnchantment($enchantment->getId())){ $lvl = $item->getEnchantment($enchantment->getId())->getLevel(); $name = $item->getName(); str_replace("\n" . $e->getName() . " " . $lvl, '', $name); var_dump($lore); $item->setCustomName($name); $item->removeEnchantment($enchantment->getId()); } Though It doesnt remove it, for ex the name of a pickaxe would be "Diamond Pickaxe\n§9Haste 1" We want to remove \n§9Haste 1 then we set \n§9Haste 2 but thats not working, it just sets \n§9Haste 2 without removing the other one which is pretty annoying "e->getName()" = §9Haste Ive tried var_dump and it gets the correct String, but it doesnt remove it
ok well.. what Ive done is assigning the str_replace to a variable and made a string instead(don't think it will change anything but oh well) and it works.. I really need to start waiting before posting in these forums PHP: $hi = "\n$name $lvl1"; var_dump($hi); $hello = str_ireplace($hi, "", $lore); $item->setCustomName($hello); $item->removeEnchantment($enchantment->getId());