The whole point of this permissions API is to provide developers with an expendable API * that allows fine tuning of each and every specific part of PocketMine. * * Thus, it should be as abstract as possible. * * Roles and levels - Administrator / Moderator etc will be handled by plugins. * Permissions loading and file formats etc will be handled by separate plugins. * * Permission checking on events will be handled by this API * Add enable-op argument to allow disabling OP systems. OP system should override this permission system, and this API * Will determine whether that option is set or not.

*/ class PermissionsAPI{ public function __construct(){ } public function __destruct(){ } /** * @access public */ public function init(){ ServerAPI::request()->api->addHandler("player.connect", function ($player){//Use a better event than player.connect. Player.create maybe? if($permission = ServerAPI::request()->api->dhandle("permissions.request", array('player' => $player)) instanceof Permission){ $player->permissions = $permission;//This is a class with functions in it. So now plugins can call $player->permissions->isGranted(). }else{ //TODO: Give out default permission. Fall back to OP system maybe? Checking for a permissions receiver would be nice. } }, 1);//Experimental. Use Closure / Anonymous Functions to assign new functions from each API rather than hard-coding them to Player.php. } } /** * Class Permission * * Each Permission object will be given a level in integer, and it will be this permission object that will be assigned to players. * Not just an integer variable. Plugins can extend this to have their own Permissions assigned to players. */ interface Permission{ /** * @return integer */ public function getPermissionLevel(); /** * @param integer $permissionLevel Integer based value of permission. */ public function __construct($permissionLevel); /** * @param Permission $permission Permission to check the user for. Must be a an object implementing Permission class. * * @return boolean Whether the person has permissions or not. */ public static function isGranted($permission); }