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

Solved Give Enchanted Items error

Discussion in 'Development' started by Jackins, May 7, 2017.

  1. Jackins

    Jackins Slime

    Messages:
    92
    Hi guys, i've wanted to ask for this error on give enchanted items to players...

    PHP:
       $inventory->addItem(Item::get(293,0,1)->addEnchantment(Enchantment::getEnchantment(12)));
    it gives this error:
    Screenshot_2.png
     
  2. Jackins

    Jackins Slime

    Messages:
    92
    Sure!
    PHP:
            $item Item::get(311,0,1);
            
    $item->addEnchantment(Enchantment::getEnchantment(0)->setLevel(2));
            
    $item->setCustomName("§l§9Magical Chestplate§r");
            
    $inventory->addItem($item);
     
  3. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    The error isn't for line 251 of the plugin. You would notice if you read it more carefully.
    The error happens because your item isn't a valid Item object.
    This should be a solution to your problem.
     
  4. Jackins

    Jackins Slime

    Messages:
    92
    BaseInventory is not plugin's class.
     
  5. Jackins

    Jackins Slime

    Messages:
    92
    I know... I thought that he's searching for my working code... And i just shared it... Btw... I just put Solved on thread so :/
     
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    Oh, good! You never know when somebody marks the thread as solved on accident. Some people do that.
     
  7. Jackins

    Jackins Slime

    Messages:
    92
    Ah, sorry for this! Btw thanks for these helps :)
     
  8. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    How do you accidentally mark a topic as solved?? :facepalm:
     
    Jackins likes this.
  9. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I've seen people add the solved tag when they first create their thread.
     
  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.