Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add Permission

Comments in 'Plugin Development' started by Asidert, Jun 7, 2015.

  1. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    Hi all, how to add a Permission for a certain player ?
    Documentation read, did not find anything, if anyone knows how to - answer, please.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at PermissionAttachment and Player->addAttachnent
    RekkuzaRage likes this.
  3. Asidert
    Offline

    Asidert Active Member Plugin Developer

    Joined:
    Oct 21, 2014
    Posts:
    123
    Plugins:
    1
    Minecraft User:
    Asidert
    How it use?
    $player->addAttachment(PluginName $plugin, $PermName, $Value);
    Or $player->addAttachment($PermName); ?
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Why do you always think it must be plugin name instead of the Plugin object (your main class instance) itself?

    To manage the permission of a player (or any other permissibles), first call addAttachnent upon it with the parameter as your plugin object. It returns with a PermissionAttachment object, which you can assume it as an "editor" or a "modifier" of the player's permission. For best performance, you should only get one PermissionAttachment for each permissible instance and save it (like with a class property array, and remove it using $permissible->removeAttachment($attachment) when your plugin is disabled (or maybe it isn't needed, I am not sure, ask @64FF00), or when the player quits. Every time you want to change the permissions of the permissible, call the setPermission method upon the PermissionAttachment.
    Take a look at PurePerms for example

Share This Page

Advertisement