mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-18 20:14:31 +00:00
Toss ServerOperator; PermissibleBase now tracks its own op status
as well as being simpler, this also allows some nice features, such as granting memory-only op state that goes away when the player quits the server.
This commit is contained in:
@@ -25,7 +25,11 @@ namespace pocketmine\permission;
|
||||
|
||||
use pocketmine\plugin\Plugin;
|
||||
|
||||
interface Permissible extends ServerOperator{
|
||||
interface Permissible{
|
||||
|
||||
public function isOp() : bool;
|
||||
|
||||
public function onOpStatusChange(bool $value) : void;
|
||||
|
||||
/**
|
||||
* Checks if this instance has a permission overridden
|
||||
|
@@ -29,11 +29,11 @@ use pocketmine\timings\Timings;
|
||||
use function spl_object_id;
|
||||
|
||||
class PermissibleBase implements Permissible{
|
||||
/** @var ServerOperator */
|
||||
private $opable;
|
||||
/** @var bool */
|
||||
private $op;
|
||||
|
||||
/** @var Permissible|null */
|
||||
private $parent = null;
|
||||
private $parent;
|
||||
|
||||
/** @var PermissionAttachment[] */
|
||||
private $attachments = [];
|
||||
@@ -41,19 +41,19 @@ class PermissibleBase implements Permissible{
|
||||
/** @var PermissionAttachmentInfo[] */
|
||||
private $permissions = [];
|
||||
|
||||
public function __construct(ServerOperator $opable){
|
||||
$this->opable = $opable;
|
||||
if($opable instanceof Permissible){
|
||||
$this->parent = $opable;
|
||||
}
|
||||
public function __construct(?Permissible $permissible, bool $isOp){
|
||||
$this->parent = $permissible;
|
||||
$this->op = $isOp;
|
||||
//TODO: permissions need to be recalculated here, or inherited permissions won't work
|
||||
}
|
||||
|
||||
public function isOp() : bool{
|
||||
return $this->opable->isOp();
|
||||
return $this->op;
|
||||
}
|
||||
|
||||
public function setOp(bool $value) : void{
|
||||
$this->opable->setOp($value);
|
||||
public function onOpStatusChange(bool $value) : void{
|
||||
$this->op = $value;
|
||||
$this->recalculatePermissions();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,6 +30,14 @@ trait PermissibleDelegateTrait{
|
||||
/** @var PermissibleBase */
|
||||
private $perm;
|
||||
|
||||
public function isOp() : bool{
|
||||
return $this->perm->isOp();
|
||||
}
|
||||
|
||||
public function onOpStatusChange(bool $value) : void{
|
||||
$this->perm->onOpStatusChange($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Permission|string $name
|
||||
*/
|
||||
|
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\permission;
|
||||
|
||||
interface ServerOperator{
|
||||
/**
|
||||
* Checks if the current object has operator permissions
|
||||
*/
|
||||
public function isOp() : bool;
|
||||
|
||||
/**
|
||||
* Sets the operator permission for the current object
|
||||
*/
|
||||
public function setOp(bool $value) : void;
|
||||
}
|
Reference in New Issue
Block a user