Show a previous attempt, we're not going to just whoosh you up code because you ask. Also, I'd try using the search bar while you're at it.
use player interact event to detect what block they’re holding, then use Server::dispatchCommand() to run a command as the player
Ill be helpful PHP: public function onInteract(PlayerInteractEvent $event){$player = $event->getPlayer();$item = $event->getItem(); if($item->getId() == Add item id here){ $command = "Add command here"; $this->getServer()->getCommandMap()->dispatch($event->getPlayer(), $command); }}Make sure to use pocketmine\event\player\PlayerInteractEvent;
'dispatch' to dispatchCommand why you use again '$event->getPlayer ()' on the function dispatch if you have already defined $player....