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

How do I fix this warning?

Discussion in 'Development' started by Junkdude, Mar 13, 2017.

  1. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    I keep getting this annoying warning and i dont know how to fix it.
    Warning: Creating default object from empty value in /home/icefac/plugins/Core/src/Junkdude/Utils.php on line 168
    Here's the code btw.
    PHP:
    case 1:
                
    $book->setCustomName(TF::YELLOW."Custom Enchant Book"."\n".TF::GREEN."Blindness I");
                
    $book->addEnchantment(Enchantment::getEnchantment(101)->setLevel(1));
                
    $tag $book->getNamedTag() ?? new CompoundTag("", []);
                
    $tag->namedtag->cebook = new IntTag("cebook"1);
                
    $book->addEnchantment(Enchantment::getEnchantment(100)->setLevel(1));
                
    $book->setNamedTag($tag);
                
    $p->getInventory()->addItem($book);
                return;
     
  2. SavionLegendZzz

    SavionLegendZzz Slime

    Messages:
    75
    GitHub:
    savionlegends
    What is line 168?
     
  3. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Read the error. "Empty object". Now i could be wrong, but this looks like an empty object
    new CompoundTag("", []); (the [] bit)
     
    SavionLegendZzz likes this.
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    at least give us full code or with lines or else it is pretty much blind shooting
     
    Awzaw and TheDiamondYT like this.
  5. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    @SavionLegendZzz line 168 is $tag->namedtag->cebook = new IntTag("cebook", 1);
     
  6. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
  7. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You didn't define $tag->namedtag
     
  8. Junkdude

    Junkdude Zombie

    Messages:
    346
    GitHub:
    JunkDaCoder
    *facepalm*
     
  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.