So I have this code: Code: $this->purePerms->setGroup($player,"Hero"); $ppGroup = $api->getGroup("Hero"); $api->setgroup($player, "Hero"); $sender->sendMessage("You won a Hero Rank!"); It says this: Code: [20:43:52] [Server thread/CRITICAL]: Unhandled exception executing command 'legendary' in legendary: Call to a member function setGroup() on null [20:43:52] [Server thread/CRITICAL]: Error: "Call to a member function setGroup() on null" (EXCEPTION) in "/plugins/zip_iSoftCrates_MCPE14_055dPYHtaCv4Jc_/src/iSoftMC/iSoftCrates/Commands/legendary" at line 70 I want it to set the players rank to Hero but it aint working
That code is outdated if you are using recent versions of PurePerms. To get the group for $p it should be: Code: $ppGroup = $this->purePerms->getUserDataMgr()->getGroup($p); where $p is the Player object, and $ppGroup is a PurePerms PPGroup object. and to set group with $p as the Player and $newgroup as a PPGroup: Code: $this->purePerms->getUserDataMgr()->setGroup($p, $newgroup, null); To get the name of a group from a PPGroup object: Code: $groupname = $ppGroup->getName(); However... to get a ppGroup object from the group's name: Code: $ppGroup = $this->purePerms->getGroup($groupname); Once again, the answers are all in PurePerms source code - search for setGroup and you'll see it's now in PurePerms UserDataManager class: Code: public function setGroup(IPlayer $player, PPGroup $group, $levelName, $time = -1) ....
Im still confused, I am a HUGE noob at coding. So what would I put in my code? I have this: Code: this->purePerms->setGroup($player,"Hero");//bad code $ppGroup = $api->getGroup("Hero");//bad code $api->setgroup($player, "Hero");//bad code $sender->sendMessage("You won a Hero Rank!"); I don't do this stuff very much and I don't know how to put it all together.
PHP: $group = $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup($p); $groupname = $group->getName(); if($groupname == "Hero"){ $sender->sendMessage("You won Hero Rank!"); }
Hm, I still get this error: Code: [15:58:44] [Server thread/CRITICAL]: Unhandled exception executing command 'legendary' in legendary: Call to a member function getPluginManager() on null [15:58:44] [Server thread/CRITICAL]: Error: "Call to a member function getPluginManager() on null" (EXCEPTION) in "/plugins/zip_iSoftCrates_MCPE14_055dPYHtaCv4Jc_/src/iSoftMC/iSoftCrates/Commands/legendary" at line 70 This is line 70: Code: $group = $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup($p);
You need to read the error! It is telling you: Call to a member function getPluginManager() on null So that means that $this->getServer() is null in iSoftCrates/Commands/legendary" at line 70. If you understand how the code you have posted so far is supposed to work... then you've already got enough information to fix this