At line 38 error :/ PHP: <?phpnamespace dellitem;use pocketmine\Server;use pocketmine\event\Cancellable;use pocketmine\event\CancellableTrait;use pocketmine\block\Block;use pocketmine\event\Event;use pocketmine\inventory\CraftingRecipe;use pocketmine\inventory\ShapedRecipe;use pocketmine\inventory\transaction\CraftingTransaction;use pocketmine\item\Item;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\event\Listener;use pocketmine\level\Position;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\inventory\CraftItemEvent;use pocketmine\block\Block\getItemId;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onDisable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); } public function OnCraftEvent(CraftItemEvent $event){ if($event->getRecipe()->getResult()->getId() === Item::BOW){ $event->setCancelled(); } }} and error on console [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\inventory\ShapedRecipe::getResult()" (EXCEPTION) in "plugins/Delitem/src/dellitem/Main" at line 38 [17:14:36] [Server thread/DEBUG]: #0 src/pocketmine/plugin/MethodEventExecutor(38): dellitem\Main->OnCraftEvent(pocketmine\event\inventory\CraftItemEvent object) [17:14:36] [Server thread/DEBUG]: #1 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(dellitem\Main object, pocketmine\event\inventory\CraftItemEvent object) [17:14:36] [Server thread/DEBUG]: #2 src/pocketmine/event/Event(99): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\inventory\CraftItemEvent object) [17:14:36] [Server thread/DEBUG]: #3 src/pocketmine/inventory/transaction/CraftingTransaction(141): pocketmine\event\Event->call() [17:14:36] [Server thread/DEBUG]: #4 src/pocketmine/inventory/transaction/InventoryTransaction(276): pocketmine\inventory\transaction\CraftingTransaction->callExecuteEvent() [17:14:36] [Server thread/DEBUG]: #5 src/pocketmine/inventory/transaction/CraftingTransaction(160): pocketmine\inventory\transaction\InventoryTransaction->execute() [17:14:36] [Server thread/DEBUG]: #6 src/pocketmine/Player(2339): pocketmine\inventory\transaction\CraftingTransaction->execute() [17:14:36] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(148): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [17:14:36] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(156): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object
Yes but I have never had this error before and I'm French suid can you explain to me clearly this error? Thank you
Error to getitem I did not understand why [Server thread/CRITICAL]: Error: "Call to a member function getId() on array" (EXCEPTION) in "plugins/Delitem/src/dellitem/Main" at line 38 [07:36:29] [Server thread/DEBUG]: #0 src/pocketmine/plugin/MethodEventExecutor(38): dellitem\Main->OnCraftEvent(pocketmine\event\inventory\CraftItemEvent object) [07:36:29] [Server thread/DEBUG]: #1 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(dellitem\Main object, pocketmine\event\inventory\CraftItemEvent object) [07:36:29] [Server thread/DEBUG]: #2 src/pocketmine/event/Event(99): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\inventory\CraftItemEvent object) [07:36:29] [Server thread/DEBUG]: #3 src/pocketmine/inventory/transaction/CraftingTransaction(141): pocketmine\event\Event->call() [07:36:29] [Server thread/DEBUG]: #4 src/pocketmine/inventory/transaction/InventoryTransaction(276): pocketmine\inventory\transaction\CraftingTransaction->callExecuteEvent() [07:36:29] [Server thread/DEBUG]: #5 src/pocketmine/inventory/transaction/CraftingTransaction(160): pocketmine\inventory\transaction\InventoryTransaction->execute() [07:36:29] [Server thread/DEBUG]: #6 src/pocketmine/Player(2339): pocketmine\inventory\transaction\CraftingTransaction->execute() [07:36:29] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(148): pocketmine\Player->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [07:36:29] [Server thread/DEBUG]: #8 src/pocketmine/network/mcpe/protocol/InventoryTransactionPacket(156): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleInventoryTransaction(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object) [07:36:29] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(108): pocketmine\network\mcpe\protocol\InventoryTransactionPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object) [07:36:29] [Server thread/DEBUG]: #10 src/pocketmine/network/mcpe/protocol/BatchPacket(119): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\InventoryTransactionPacket object)
The way you are using it is wrong, consider using an IDE to help you with this kind of errors PHP: foreach($event->getRecipe()->getResults() as $result) if($result->getId() === Item::BED){ $event->setCancelled(); break; }
Here is the whole code for the curious PHP: <?phpnamespace dellitem;use pocketmine\Server;use pocketmine\event\Cancellable;use pocketmine\event\CancellableTrait;use pocketmine\block\Block;use pocketmine\event\Event;use pocketmine\inventory\CraftingRecipe;use pocketmine\inventory\ShapedRecipe;use pocketmine\inventory\transaction\CraftingTransaction;use pocketmine\item\Item;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\Player;use pocketmine\entity\Effect;use pocketmine\entity\EffectInstance;use pocketmine\event\Listener;use pocketmine\level\Position;use pocketmine\event\player\PlayerInteractEvent;use pocketmine\event\inventory\CraftItemEvent;use pocketmine\block\Block\getItemId;class Main extends PluginBase implements Listener{ public function onEnable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); $this->getServer()->getPluginManager()->registerEvents($this,$this); } public function onDisable(){ $this->getLogger()->info("§1[Blutonia]§r DellItem Loading... ━━━━━━M━━A━━T━━R━━O━━X━━P━━L━━A━━Y━━━━━━"); } //CraftEvent public function OnCraftEvent(CraftItemEvent $event){ foreach($event->getRecipe()->getResults() as $result) if($result->getId() === Item::BED or $result->getId() === Item::BOW){ $event->setCancelled(); $event->getPlayer()->sendTip("§4Cette item n'est pas disponible"); break; } }}