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

Check player inv and check level enchant

Discussion in 'Development' started by ZackyVN, Nov 26, 2018.

  1. ZackyVN

    ZackyVN Baby Zombie

    Messages:
    150
    How to check player inv. If inside a player inv has a item with level enchant > 10 it will automatic delete it?
     
  2. wolfdale

    wolfdale Zombie Pigman

    Messages:
    535
    GitHub:
    diamond-gold
    PHP:
    foreach($player->getInventory()->getContents() as $index => $item)
    foreach(
    $item->getEnchantments() as $enchant)
    if(
    $enchant->getLevel() > 10){
    $player->getInventory()->clear($index);
    break;
    }
     
  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.