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

Solved Error ocurres when try to add enchant to bow

Discussion in 'Development' started by Kyd, Aug 19, 2017.

  1. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Here is my code:
    PHP:
       $item Item::get(Item::BOW01);
       
    $item->addEnchantment(Enchantment::getEnchantment(22)->setLevel(1));
       
    $item->setCustomName("§bDetektivuv luk");
       
    $p->getInventory()->addItem($item);
    And here error:
    Code:
    [11:27:37] [Server thread/CRITICAL]: Could not execute task MurderMystery\Arena\ArenaScheduler: Call to a member function setLevel() on null
    [11:27:37] [Server thread/CRITICAL]: Error: "Call to a member function setLevel() on null" (EXCEPTION) in "murder/src/MurderMystery/Arena/Arena" at line 296
    Without addEnchantment works without error

    EDIT: 22 is infinity
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    jasonwynn10 likes this.
  3. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Ah, ok and is there way to register it trought plugin or I must add it to PMMP myself?
     
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Yeah, use ReflectionClass.
     
    jasonwynn10 likes this.
  5. Kyd

    Kyd Zombie Pigman

    Messages:
    678
    GitHub:
    boi1216
    Thanks
     
  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.