Removal of permission defaults (in favour of permission cascading) (#3937)

This commit is contained in:
Dylan T
2020-12-01 17:13:54 +00:00
committed by GitHub
parent 1eabc3fe75
commit 6d8833ccd3
13 changed files with 215 additions and 241 deletions

View File

@@ -31,14 +31,6 @@ namespace pocketmine\permission;
* Represents a permission
*/
class Permission{
public const DEFAULT_OP = "op";
public const DEFAULT_NOT_OP = "notop";
public const DEFAULT_TRUE = "true";
public const DEFAULT_FALSE = "false";
/** @var string */
public static $DEFAULT_PERMISSION = self::DEFAULT_OP;
/** @var string */
private $name;
@@ -51,19 +43,15 @@ class Permission{
*/
private $children;
/** @var string */
private $defaultValue;
/**
* Creates a new Permission object to be attached to Permissible objects
*
* @param bool[] $children
* @phpstan-param array<string, bool> $children
*/
public function __construct(string $name, ?string $description = null, ?string $defaultValue = null, array $children = []){
public function __construct(string $name, ?string $description = null, array $children = []){
$this->name = $name;
$this->description = $description ?? "";
$this->defaultValue = $defaultValue ?? self::$DEFAULT_PERMISSION;
$this->children = $children;
$this->recalculatePermissibles();
@@ -81,17 +69,6 @@ class Permission{
return $this->children;
}
public function getDefault() : string{
return $this->defaultValue;
}
public function setDefault(string $value) : void{
if($value !== $this->defaultValue){
$this->defaultValue = $value;
$this->recalculatePermissibles();
}
}
public function getDescription() : string{
return $this->description;
}
@@ -110,8 +87,6 @@ class Permission{
public function recalculatePermissibles() : void{
$perms = $this->getPermissibles();
PermissionManager::getInstance()->recalculatePermissionDefaults($this);
foreach($perms as $p){
$p->recalculatePermissions();
}