use pocketmine\event\inventory\InventoryOpenEvent; public function onInventoryOpen(InventoryOpenEvent $event){ $inventory = $event->getInventory(); $player = $event->getPlayer(); if($inventory instanceof ChestInventory or $inventory instanceof FurnaceInventory){ if($player->isCreative()){ $event->setCancelled(true); $player->sendMessage("[Limit]>>>Don't do it !"); } } When people open the chest who gamemode is creative can't trigger this event! please give me help QWQ
Did you import the ChestInventory and FurnaceInventory classes? PHP: use pocketmine\inventory\ChestInventory;use pocketmine\inventory\FurnaceInventory;
Fewer lines of code ≠ better. OP's example is plenty readable, and there would likely be no noticeable difference in how the plugin runs.
There are a few possible reasons your code isn't working - but the code snippet you posted isn't enough: for example, did you register the plugin to handle events? Please post the full code, or a link to the plugin on github.