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

Solved How can I complement PurePerms with my Plugin?

Discussion in 'Development' started by Minetron26, Sep 13, 2018.

  1. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Hello !, I need to know if there is any way to use PurePerms for the code of my Plugin, how to make that when executing a command it is added to a certain group to the user that executed it.
     
  2. RyanShaw

    RyanShaw Witch

    Messages:
    69
    PHP:
            $pp Server::getInstance()->getPluginManager()->getPlugin('PurePerms');//get the plugin
            
    $pp->setGroup($player,$pp->getGroup("Guest")); //use its api
     
    Last edited: Sep 14, 2018
    Aericio and Minetron26 like this.
  3. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Okey, thanks
     
  4. Emirhan Akpınar

    Emirhan Akpınar Slime

    Messages:
    90
    You can use this too,

    PHP:
    /** @var Server $server */
    $server->dispatchCommand(new ConsoleCommandSender(), "setgroup ".$player->getName()." Guest");
     
  5. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    using commands isnt encouraged

    if the plugin/function have an api you should always use it
    for example what if your player name have a space
    now the whole command fall apart and potentially allowing dangerous exploits
     
    HimbeersaftLP and Muqsit like this.
  6. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Yes, thanks for that, but now I need to know how I can add a permission to the Player?
     
  7. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    See how PurePerms itself does it

    PHP:
    $pp>getUserDataMgr()->setPermission($player$permission);
    Edit: Used permalink, added code example.
     
  8. Minetron26

    Minetron26 Witch

    Messages:
    55
    GitHub:
    minetron26
    Thank you
     
  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.