mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
PermissibleBase: allow injecting more dynamic base permissions
This commit is contained in:
parent
13e8854ec0
commit
880635603c
@ -25,6 +25,7 @@ namespace pocketmine\command;
|
||||
|
||||
use pocketmine\lang\Language;
|
||||
use pocketmine\lang\TranslationContainer;
|
||||
use pocketmine\permission\DefaultPermissions;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
use pocketmine\permission\PermissibleDelegateTrait;
|
||||
use pocketmine\Server;
|
||||
@ -44,7 +45,7 @@ class ConsoleCommandSender implements CommandSender{
|
||||
|
||||
public function __construct(Server $server, Language $language){
|
||||
$this->server = $server;
|
||||
$this->perm = new PermissibleBase(true);
|
||||
$this->perm = new PermissibleBase([DefaultPermissions::ROOT_OPERATOR => true]);
|
||||
$this->language = $language;
|
||||
}
|
||||
|
||||
|
@ -51,13 +51,17 @@ class PermissibleBase implements Permissible{
|
||||
*/
|
||||
private $permissionRecalculationCallbacks;
|
||||
|
||||
public function __construct(bool $isOp){
|
||||
/**
|
||||
* @param bool[] $basePermissions
|
||||
* @phpstan-param array<string, bool> $basePermissions
|
||||
*/
|
||||
public function __construct(array $basePermissions){
|
||||
$this->permissionRecalculationCallbacks = new Set();
|
||||
|
||||
//TODO: we can't setBasePermission here directly due to bad architecture that causes recalculatePermissions to explode
|
||||
//so, this hack has to be done here to prevent permission recalculations until it's fixed...
|
||||
if($isOp){
|
||||
$this->rootPermissions[DefaultPermissions::ROOT_OPERATOR] = true;
|
||||
foreach($basePermissions as $permission => $isGranted){
|
||||
$this->rootPermissions[$permission] = $isGranted;
|
||||
}
|
||||
//TODO: permissions need to be recalculated here, or inherited permissions won't work
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataFlags;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\PlayerMetadataFlags;
|
||||
use pocketmine\permission\DefaultPermissions;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
use pocketmine\permission\PermissibleDelegateTrait;
|
||||
use pocketmine\Server;
|
||||
@ -278,7 +279,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$this->uuid = $this->playerInfo->getUuid();
|
||||
$this->xuid = $this->playerInfo instanceof XboxLivePlayerInfo ? $this->playerInfo->getXuid() : "";
|
||||
|
||||
$this->perm = new PermissibleBase($this->server->isOp($this->username));
|
||||
$this->perm = new PermissibleBase($this->server->isOp($this->username) ? [DefaultPermissions::ROOT_OPERATOR => true] : [DefaultPermissions::ROOT_USER => true]);
|
||||
$this->chunksPerTick = (int) $this->server->getConfigGroup()->getProperty("chunk-sending.per-tick", 4);
|
||||
$this->spawnThreshold = (int) (($this->server->getConfigGroup()->getProperty("chunk-sending.spawn-radius", 4) ** 2) * M_PI);
|
||||
$this->chunkSelector = new ChunkSelector();
|
||||
|
Loading…
x
Reference in New Issue
Block a user