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

Set permission via code

Discussion in 'Development' started by JarguarLoveMC, Mar 29, 2019.

  1. JarguarLoveMC

    JarguarLoveMC Spider Jockey

    Messages:
    49
    I need help setting player permission via code. Please dont reply with "just use $this"

    I'm not sure if this is correct or what to do next eh :/


    $plugin = Example\Main
    $perm = “example.command”
    $bool = true

    $event->getPlayer()->addAttachment($plugin, $perm, $bool);
    }

    Thanks for taking time into reading this post
     
  2. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    try looking at pureperms code or using the search tab
     
  3. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    if you're using PurePerms
    PHP:
    /** @var PurePerms $pp */
    /** @var Player $player */
    $pp->getUserDataMgr()->setPermission($player"permission");
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PurePerms is spagetti. I do not recommend it for trying to understand the concepts.

    Sofe made a plugin a while back that simplifies the permission attachment system to something readable. I recommend looking at it to get some understanding. https://github.com/SOF3/simple-plugins/tree/master/SimplePermissions
     
  5. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Consolecommandsender
    If you're lazy like me :)
     
  6. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    what has that have to do with this thread?
     
    jasonwynn10 likes this.
  7. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Use it to set a player permission... in a lazy fashion
     
  8. dktapps

    dktapps Administrator Staff Member PMMP Team

    Messages:
    774
    GitHub:
    dktapps
    if you managed to figure this out on your own I'd be very impressed. it's very confusing and misleading. thank bukkit stupidity for that.
     
    Primus and jasonwynn10 like this.
  9. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    and how would that work?
     
    jasonwynn10 likes this.
  10. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Server::getInstance()->dispatchCommand(new ConsoleCommandSender(), "setuperm ".$player->getName()." ".$permission);
     
  11. KielKing

    KielKing Zombie

    Messages:
    245
    GitHub:
    kielking
    he isn't using PurePerms
     
    jasonwynn10 likes this.
  12. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    SEEEEEEEE LIKE THIS THIS IS STILL "CODE"
     
    minijaham likes this.
  13. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Also he never specified what he was using... he just asked "how do i set a permission with code"
     
    jasonwynn10 likes 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.