PocketMine-MP 5.15.1 git-ed158f8a1b0cfe334ac5f45febc0f633602014f2
Permission.php
1<?php
2
3/*
4 *
5 * ____ _ _ __ __ _ __ __ ____
6 * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
7 * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
8 * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
9 * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
10 *
11 * This program is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * @author PocketMine Team
17 * @link http://www.pocketmine.net/
18 *
19 *
20 */
21
22declare(strict_types=1);
23
28namespace pocketmine\permission;
29
31
36 private Translatable|string $description;
37
44 public function __construct(
45 private string $name,
46 Translatable|string|null $description = null,
47 private array $children = []
48 ){
49 $this->description = $description ?? ""; //TODO: wtf ????
50
51 $this->recalculatePermissibles();
52 }
53
54 public function getName() : string{
55 return $this->name;
56 }
57
62 public function getChildren() : array{
63 return $this->children;
64 }
65
66 public function getDescription() : Translatable|string{
67 return $this->description;
68 }
69
70 public function setDescription(Translatable|string $value) : void{
71 $this->description = $value;
72 }
73
77 public function getPermissibles() : array{
78 return PermissionManager::getInstance()->getPermissionSubscriptions($this->name);
79 }
80
81 public function recalculatePermissibles() : void{
82 $perms = $this->getPermissibles();
83
84 foreach($perms as $p){
85 $p->recalculatePermissions();
86 }
87 }
88
89 public function addChild(string $name, bool $value) : void{
90 $this->children[$name] = $value;
91 $this->recalculatePermissibles();
92 }
93
94 public function removeChild(string $name) : void{
95 unset($this->children[$name]);
96 $this->recalculatePermissibles();
97
98 }
99}
__construct(private string $name, Translatable|string|null $description=null, private array $children=[])
Definition: Permission.php:44