Title says everything, I want to add enchant to this code PHP: $players->getInventory()->setChestplate(Item::get(Item::DIAMOND_CHESTPLATE));
PHP: $players->getInventory()->setChestplate(Item::get(Item::DIAMOND_CHESTPLATE)->addEnchantment(Enchantment::getEnchantment($id)->setLevel($level)));
Referring to what @dktapps said, the correct English term is "enchantment". If you want to set enchantments to items use the "\pocketmine\item\Item::addEnchantment()" method: https://github.com/pmmp/PocketMine-MP/blob/master/src/pocketmine/item/Item.php#L534
Error. Code: 09:48:50 [CRITICAL] Unhandled exception executing command 'host start' in host: Argument 1 passed to pocketmine\inventory\PlayerInventory::setHelmet() must be an instance of pocketmine\item\Item, null given, called in /root/fame/plugins/VIPParticles - Copy/src/Meme/Main.php on line 51 09:48:50 [CRITICAL] TypeError: "Argument 1 passed to pocketmine\inventory\PlayerInventory::setHelmet() must be an instance of pocketmine\item\Item, null given, called in /root/fame/plugins/VIPParticles - Copy/src/Meme/Main.php on line 51" (EXCEPTION) in "/src/pocketmine/inventory/PlayerInventory" at line 310 PHP: $level = mt_rand(1,5);$players->getInventory()->setHelmet(Item::get(Item::DIAMOND_HELMET)->addEnchantment(Enchantment::getEnchantment(0)->setLevel($level)));