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

Enchant Checking

Discussion in 'Plugin Help' started by ObeyBeastJj23, Apr 20, 2017.

  1. ObeyBeastJj23

    ObeyBeastJj23 Spider

    Messages:
    13
    I was wondering if there was a way to check enchantments on an item along with checking the id.. If this is possible and someone could tell me how i would be very greatful
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    I suggest looking at the member functions in pocketmine\item\Item. You can use these two functions to get the ID and check if it has an enchantment. How you get the Item object is up to you.
    PHP:
     /** @var Item $item */
     //Checks if Item is a Diamond Sword.
     
    if($item->getId() == Item::DIAMOND_SWORD) {
      
    //The item is a Diamond Sword.
     
    }
     
    //Checks if Item has enchantment ID 9 (Sharpness)
     
    if(!is_null($item->getEnchantment(9))) {
      
    //The item has the enchantment.
     
    }
     
  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.