You should use something like this: PHP: public function onInteract(PlayerInteractEvent $ev){ if($ev->getItem()->getId() === /*Id of Item*/){ $this->getServer()->dispatchCommand($ev->getPlayer(), "say hello world."); } }
NEVER just copy code. If you just copy someone else's code it will almost never work for you. Learn how to program properly or no one will assist you.