From 71a1986980b4b17ea42b4167b2406f7b2f6057f2 Mon Sep 17 00:00:00 2001 From: Michael Yoo Date: Tue, 26 Nov 2013 20:00:15 +1030 Subject: [PATCH] Add EventRestriction --- src/API/PermissionsAPI.php | 51 +++++++++++++++++++++++++++++--------- src/Player.php | 3 ++- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/API/PermissionsAPI.php b/src/API/PermissionsAPI.php index b48cdc438..e74ffe787 100644 --- a/src/API/PermissionsAPI.php +++ b/src/API/PermissionsAPI.php @@ -37,7 +37,10 @@ * Will determine whether that option is set or not.

*/ class PermissionsAPI{ - public function __construct(){ + /** + * + */ + public function __construct(){ } @@ -66,16 +69,40 @@ class PermissionsAPI{ * 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(); +//interface RoleInterface{ +// /** +// * @return integer +// */ +// public function getPermissionLevel(); +// +// /** +// * @param RoleInterface $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 function isGranted($permission); +//} - /** - * @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 function isGranted($permission); +//Thinking of doing $player->permissions[] = new EventRestriction("player.move"); +//$player->permissions->apply(new EventRestriction("player.move")); + +class EventRestriction +{ + /** + * @var string $event + */ + private $event; + + /** + * @param array $event + */ + public function __construct($event) + { + $this->event = trim($event); + } + + public function __toString() + { + return (string) $this->event; + } } \ No newline at end of file diff --git a/src/Player.php b/src/Player.php index 4bada15b9..e66b7fa83 100644 --- a/src/Player.php +++ b/src/Player.php @@ -60,7 +60,8 @@ class Player{ public $blocked = true; public $achievements = array(); public $chunksLoaded = array(); - public $permissions = array(); + /** @var mixed Permissions Object */ + public $permissions = false; private $chunksOrder = array(); private $lastMeasure = 0; private $bandwidthRaw = 0;