I have one plugin with that cmd: PHP: switch($command->getName()) { case "spawn": { $mapname = "world"; $sender->getPlayer()->sendMessage("[rBServer] Teleportiere zum Spawn"); } //Prevents most crashes if(Server::getInstance()->loadLevel($mapname) != false) { $sender->getPlayer()->teleport(Server::getInstance()->getLevelByName($mapname)->getSafeSpawn()); //$sender->teleport($this->main->getServer()->getDefaultLevel()->getSpawnLocation()); } else { $sender->getPlayer()->sendMessage("[CRITICAL_ERROR] ERR_005_sp_'".$mapname."' DAS IST EIN KRITISCHER FEHLER! BITTE REPORTE IHN UMGEHEND AUF http://robskebueba.de.tl/PSR.htm"); } return true; } And I have another plugin that handles effects, I want to provide an api for the other plugin like On command in first plugin: call(PlayerIssuedSpawnCommand,$sender) On call PlayerIssuedSpawnCommand in the other plugin get(PlayerIssuedSpawnCommand,$sender) ...
Make your command implementation into an independent public function (with proper parameters passed). Then you can call that function directly from the other plugin.
public function onCommand(CommandSender $sender, Command $command, $label, array $args){ like that? //realy nooby in php
Just look at the source code of DevTools, how it handles commands. https://github.com/PocketMine/DevTools/blob/master/src/DevTools/DevTools.php#L59 If the functions become public, then they are what you are looking for. I just reread your posts, and this doesn't seem to be what you are looking for. Can you state your purpose of making this, for example, what you want to achieve in these plugins?
Ok, i tried to use that: (Will now provide full codes for better understanding) PHP: public function onCommand(CommandSender $sender, Command $command, $label, array $args){ switch($command->getName()) { case "spawn": { $mapname = "world"; $sender->getPlayer()->sendMessage("[rBServer] Teleportiere zum Spawn"); } //Prevents most crashes if(Server::getInstance()->loadLevel($mapname) != false) { $sender->getPlayer()->teleport(Server::getInstance()->getLevelByName($mapname)->getSafeSpawn()); //$sender->teleport($this->main->getServer()->getDefaultLevel()->getSpawnLocation()); return $this->spawnCommand($sender, $command, $label, $args); } else { $sender->getPlayer()->sendMessage("[CRITICAL_ERROR] ERR_005_sp_'".$mapname."' DAS IST EIN KRITISCHER FEHLER! BITTE REPORTE IHN UMGEHEND AUF http://robskebueba.de.tl/PSR.htm"); } return true; }} and in the other plugin: PHP: public function spawnCommand(CommandSender $sender, Command $command, $label, array $args){//code} Now, when i issue /spawn it says: Call to undefined method robske\SignPortal\Main::spawnCommand()
Define spawnCommand in the first plugin. $this means the current class you're writing the code in, so why would you put the function in another plugin?