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

Solved [Self-Solved] Lore

Discussion in 'Development' started by Karanpatel567, Dec 3, 2017.

  1. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Hey PMMP devs, I would like to know how to set a lore on a item and check on PlayerInteractEvent if the player has that item with the lore.
     
  2. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    What u mean by that?
     
  3. DaPigGuy

    DaPigGuy Slime

    Messages:
    86
    GitHub:
    DaPigGuy
  4. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
  5. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    This is the developer section. If you want code, you should ask in the facepalm section. Otherwise, make an attempt to understand it on your own before asking for code.
     
  6. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Yes I know it's the developer section... Other people do the same thing aswell. I actually didn't know, if you have a problem me not knowing it how would i know then?
     
    Last edited: Dec 4, 2017
  7. EdwardHamHam

    EdwardHamHam Skeleton

    Messages:
    962
    GitHub:
    edwardhamham
    No the problem is that you're just asking for code and not an explanation. You're just asking for us to give you the code without you trying to understand it.
     
    jasonwynn10 likes this.
  8. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    if you want to add Lore if the Item doesn't have one use this code:
    PHP:
    /**
    * @param Item $item
    * @param array $lore
    * @return Item
    */
    public function addLoreIfNotExist(Item $item, array $lore) : Item
    {
        if(
    $item->getLore() === []){
            return 
    $item->setLore($lore);
        }
        return 
    $item;
    }
     
  9. Karanpatel567

    Karanpatel567 Baby Zombie

    Messages:
    115
    GitHub:
    Karanpatel567
    Thanks for code but I self solved this!
     
  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.