I'm trying to execute a function in another plugin but it tells me undefined variable server code: 1 PHP: public function PvP($player){ $plugin = $this->getServer()->getPluginManager(); $formapi = $plugin->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $event, array $args){ $result = $args[0]; $player = $event->getPlayer(); if($result === null){ } switch($result){ case 0: $this->gamesf($player); return; case 1: $Server->getInstance()->getPluginManager()->getPlugin("buhc")->app(); //function that I want to execute return; } }); $form->setTitle(TextFormat::WHITE . "--= " . TextFormat::BOLD . TextFormat::DARK_PURPLE . "Juegos" . TextFormat::RESET . TextFormat::WHITE . " =--"); $name = $player->getName(); $form->addButton("ATRAS"); $form->addButton("BUHC"); $form->sendToPlayer($player); } Code: 2 error PHP: public static function app(Player $player){ $this->arenaManager->addNewPlayerToQueue($player); //function that I want to execute } Spoiler: Error 2018-01-10 [01:03:14] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.0.0': Undefined variable: Server on jojoe77777\FormAPI\FormAPI 2018-01-10 [01:03:14] [Server thread/CRITICAL]: ErrorException: "Undefined variable: Server" (EXCEPTION) in "CoreGames/src/YunoSiwa/CoreGames/Main" at line 124 2018-01-10 [01:03:14] [Server thread/DEBUG]: #0 CoreGames/src/YunoSiwa/CoreGames/Main(124): pocketmine\error_handler(integer 8, string Undefined variable: Server, string C:\Users\usuario\Desktop\VeryImportantPig\plugins\CoreGames\src\YunoSiwa\CoreGames\Main.php, integer 124, array Array()) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #1 FormAPI-master/src/jojoe77777/FormAPI/FormAPI(66): YunoSiwa\CoreGames\Main->YunoSiwa\CoreGames\{closure}(pocketmine\Player object, array Array()) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #2 src/pocketmine/plugin/MethodEventExecutor(38): jojoe77777\FormAPI\FormAPI->onPacketReceived(pocketmine\event\server\DataPacketReceiveEvent object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #3 src/pocketmine/plugin/RegisteredListener(98): pocketmine\plugin\MethodEventExecutor->execute(jojoe77777\FormAPI\FormAPI object, pocketmine\event\server\DataPacketReceiveEvent object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #4 src/pocketmine/plugin/PluginManager(721): pocketmine\plugin\RegisteredListener->callEvent(pocketmine\event\server\DataPacketReceiveEvent object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #5 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(91): pocketmine\plugin\PluginManager->callEvent(pocketmine\event\server\DataPacketReceiveEvent object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #6 src/pocketmine/network/mcpe/protocol/BatchPacket(115): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\ModalFormResponsePacket object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #7 src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter(92): pocketmine\network\mcpe\protocol\BatchPacket->handle(pocketmine\network\mcpe\PlayerNetworkSessionAdapter object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #8 src/pocketmine/Player(2998): pocketmine\network\mcpe\PlayerNetworkSessionAdapter->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #9 src/pocketmine/network/mcpe/RakLibInterface(143): pocketmine\Player->handleDataPacket(pocketmine\network\mcpe\protocol\BatchPacket object) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #10 vendor/pmmp/raklib/server/ServerHandler(99): pocketmine\network\mcpe\RakLibInterface->handleEncapsulated(string 192.168.1.68:43921, raklib\protocol\EncapsulatedPacket object, integer 0) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #11 src/pocketmine/network/mcpe/RakLibInterface(82): raklib\server\ServerHandler->handlePacket() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #12 src/pocketmine/network/Network(89): pocketmine\network\mcpe\RakLibInterface->process() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #13 src/pocketmine/Server(2522): pocketmine\network\Network->processInterfaces() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #14 src/pocketmine/Server(2274): pocketmine\Server->tick() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #15 src/pocketmine/Server(2149): pocketmine\Server->tickProcessor() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #16 src/pocketmine/Server(1737): pocketmine\Server->start() 2018-01-10 [01:03:14] [Server thread/DEBUG]: #17 src/pocketmine/PocketMine(554): pocketmine\Server->__construct(BaseClassLoader object, pocketmine\utils\MainLogger object, string C:\Users\usuario\Desktop\VeryImportantPig\, string C:\Users\usuario\Desktop\VeryImportantPig\plugins\) 2018-01-10 [01:03:14] [Server thread/DEBUG]: #18 C:/Users/usuario/Desktop/VeryImportantPig/Phar.phar(1): require(string
Make sure to have the use pocketmine\Server; and also replace $Server->getInstance()->getPluginManager()->getPlugin("buhc")->app(); with $this->getServer()->getInstance()->getPluginManager()->getPlugin("buhc")->app();