1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Item "description"

Discussion in 'Development' started by Aviv, Dec 9, 2016.

  1. Aviv

    Aviv Baby Zombie

    Messages:
    156
    thats what i meant.
    so my way to rename an item:
    PHP:
    $enchants explode("\n"$item->getName());//didnt know $item->getName() also returns its custom name if has :D
    unset($enchants[0]);//removes the first line, the name of the item
    $item->clearCustomName();
    $item->setCustomName($newName "\n" implode("\n"$enchants));
    eg:
    Godly sword
    Rekt V
    Demolish IV
    $newName = DSword
    PHP:
    $enchants explode("\n"$item->getName()); //["Godly sword", "Rekt V","Demolish IV"]
    unset($enchants[0]); // removes "Godly sword" from the array
    $item->clearCustomName();
    $newName "DSword";
    $item->setCustomName($newName"\n" implode("\n"$enchants)); // $enchants is the custom enchants the old named sword had 
     
    Last edited: Dec 14, 2016
    Muqsit likes this.
  2. Aviv

    Aviv Baby Zombie

    Messages:
    156
    thanks, i think your way is more efficient than mine imma rewrite the system :)
     
    Last edited: Dec 15, 2016
  3. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Also, my bad. Typo..
    It should be...
    PHP:
    if (strpos($item->getName(), "\n") !== false) {
    This one is wrong..
    PHP:
    if (strpos($item->getName(), '\n') !== false) {
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.