Running a command from another Plugin on Item Tap. When player interacts with an Item it will run a command like /wp [world] on
PHP: public function handleInteract(PlayerInteractEvent $event){ $items = [Item::BONE => function(Player $player){$player->transfer("127.0.0.1", 19133);}, Item::APPLE => function(Player $player){$player->sendMessage("This item not work today. Try in another day! :)");}]; if(isset($items[$event->getItem()->getId()])){ $items[$event->getItem()->getId()]($event->getPlayer()); }}
You could have searched for "dispatchCommand" but instead you wanted to wait for someone to search for it and paste the link. https://forums.pmmp.io/threads/how-...ho-clicked-on-another-player.4291/#post-40024
If you want to run a command when a player holds a certain item: PHP: public function onItemHeld(PlayerItemHeldEvent $event) { $player = $event->getPlayer(); $item = $event->getItem(); if($item->getId() === 399) { // if the players holds a Nether Star $player->getInventory()->removeItem(Item::get(399)); // remove the item and run command(s) below $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "<command here>"); // runs the command as console }} If you want it to run the command only if the interacts with that item, use the PlayerInteractEvent.