1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

PurePerms Bugs

Discussion in 'Plugin Help' started by SuperDude36, Feb 22, 2017.

  1. SuperDude36

    SuperDude36 Spider Jockey

    Messages:
    26
    GitHub:
    superdude36
    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 :(
     
    Last edited by a moderator: Feb 22, 2017
  2. RoyalMCPE

    RoyalMCPE Slime

    Messages:
    87
    What exactly is on line 70
     
  3. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    What is $api? Show more of your code please.
     
  4. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    make sure pureperm is loaded
     
  5. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    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)
    ....
    
     
    corytortoise and Vaivez66 like this.
  6. SuperDude36

    SuperDude36 Spider Jockey

    Messages:
    26
    GitHub:
    superdude36
    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.
     
  7. MyNET

    MyNET Silverfish

    Messages:
    24
    PHP:
       $group $this->getServer()->getPluginManager()->getPlugin("PurePerms")->getUserDataMgr()->getGroup($p);
       
    $groupname $group->getName();
       if(
    $groupname == "Hero"){
           
    $sender->sendMessage("You won Hero Rank!");
       }
     
  8. SuperDude36

    SuperDude36 Spider Jockey

    Messages:
    26
    GitHub:
    superdude36
    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);
    
     
  9. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    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
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.