Hi, i'm cracking my head for this one "instance" method, if anyone know how and why. Please explain and teach PHP: <?php/*** Created by PhpStorm.* User: RTG* Date: 22/9/2017* Time: 7:28 PM*/namespace RTG\TransferMyRank;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\Player;use pocketmine\plugin\PluginBase;class Main extends PluginBase { public $pp; public function onEnable() { $this->pp = $this->getServer()->getPluginManager()->getPlugin("PurePerms"); if (!$this->pp) { $this->getLogger()->warning("Ermmm, unable to spot PurePerms"); } else { $this->getLogger()->warning("Successfully connected to PurePerms"); } } public function onTransfer($sender, $target, $destination) { if ($target instanceof Player && $destination instanceof Player) { $api = $this->getServer()->getPluginManager()->getPlugin("PurePerms"); $grp = $api->getUserDataMgr()->getGroup($target); $sender->sendMessage($grp . " !"); } } public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool { switch ($command->getName()) { case "transfer": if (isset($args[0])) { if (isset($args[1])) { $this->onTransfer($sender, $args[0], $args[1]); } else { $sender->sendMessage("Done, rank transferred!"); } } else { $sender->sendMessage("[Usage] /transfer {target} {target}"); } return true; break; } }} Error: Code: [21:04:28] [Server thread/INFO]: An unknown error occurred while attempting to perform this command [21:04:28] [Server thread/CRITICAL]: Unhandled exception executing command 'transfer Steve AirySaturn21283' in transfer: Argument 1 passed to _64FF00\PurePerms\data\UserDataManager::__construct() must be an instance of _64FF00\PurePerms\PurePerms, string given, called in C:\Users\RTG\Documents\Tester Unit\plugins\TransferMyRank\src\RTG\TransferMyRank\Main.php on line 34 [21:04:28] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to _64FF00\PurePerms\data\UserDataManager::__construct() must be an instance of _64FF00\PurePerms\PurePerms, string given, called in C:\Users\RTG\Documents\Tester Unit\plugins\TransferMyRank\src\RTG\TransferMyRank\Main.php on line 34" (EXCEPTION) in "PurePerms/src/_64FF00/PurePerms/data/UserDataManager" at line 29 I don't understand the error. Thanks
You need to add a use statement for PurePerms. Add: Code: use _64FF00\PurePerms\PurePerms; and it should be good
I don't know why you stored $this->pp in onEnable() but try to fetch the plugin again through PluginManager.