Hello, When I installed the new pocketmine(3.0.0-ALPHA11) I had an error with my plugin: PHP: [23:45:08] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'SpaceLife v1.0.0': Call to undefined method pocketmine\item\enchantment\ProtectionEnchantment::setLevel() on SpaceLife\Main[23:45:08] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\item\enchantment\ProtectionEnchantment::setLevel()" (EXCEPTION) in "SpaceLife/src/SpaceLife/Main" at line 194 How I can fix it?
You need to use the EnchantmentInstance class now. Example: PHP: //All used classes are located in the namespace pocketmine\item\enchantment$enchantment = Enchantment::getEnchantment(Enchantment::PROTECTION);$level = 10;$item->addEnchantment(new EnchantmentInstance($enchantment, $level));
what is this now?: PHP: Call to undefined method pocketmine\inventory\PlayerInventory::setHelmet()[12:18:31] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\inventory\PlayerInventory::setHelmet()" (EXCEPTION) in "SpaceLIfe/src/SpaceLife/Main" at line 287 this is the code: PHP: [282] $item = Item::get(302, 0, 1);[283] $item->setCustomName("§9Space §fHelmet");[284] $enchantment = Enchantment::getEnchantment(Enchantment::PROTECTION);[285] $level = 10;[286] $item->addEnchantment(new EnchantmentInstance($enchantment, $level));[287] $sender->getInventory()->setHelmet($item);
You're using the wrong inventory. This would be correct: PHP: $sender->getArmorInventory()->setHelmet($item);
Okay it is work but if i want to remove the helmet from the player the console send for me: PHP: [16:25:23] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\player\PlayerJoinEvent' to 'SpaceLife v1.0.0': Argument 1 passed to pocketmine\item\Item::getEnchantment() must be of the type integer, object given, called in C:\Users\Reem\Desktop\PocketMine-MP\plugins\SpaceLife\src\SpaceLife\Main.php on line 205 on SpaceLife\Main[16:25:23] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to pocketmine\item\Item::getEnchantment() must be of the type integer, object given, called in C:\Users\Reem\Desktop\PocketMine-MP\plugins\SpaceLife\src\SpaceLife\Main.php on line 205" (EXCEPTION) in "src/pocketmine/item/Item" at line 316 This is my code: PHP: [201] $item = Item::get(302, 0, 1);[202]$item->setCustomName("§9Space §fHelmet");[203] $enchantment = Enchantment::getEnchantment(Enchantment::PROTECTION);[204] $level = 10;[205] $item->getEnchantment(new EnchantmentInstance($enchantment, $level)); //Here is the proplem:/[206] $player->getArmorInventory()->remove($item);