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:
Dylan K. Taylor
2020-11-28 18:22:59 +00:00
parent 4439781124
commit c7961bfe90
8 changed files with 32 additions and 78 deletions

View File

@ -281,7 +281,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);
$this->perm = new PermissibleBase($this, $this->server->isOp($this->username));
$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();
@ -523,24 +523,6 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return $this->isConnected();
}
public function isOp() : bool{
return $this->server->isOp($this->getName());
}
public function setOp(bool $value) : void{
if($value === $this->isOp()){
return;
}
if($value){
$this->server->addOp($this->getName());
}else{
$this->server->removeOp($this->getName());
}
$this->networkSession->syncAdventureSettings($this);
}
public function recalculatePermissions() : void{
$permManager = PermissionManager::getInstance();
$permManager->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
@ -552,6 +534,8 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
$this->delegateRecalculatePermissions();
$this->networkSession->syncAdventureSettings($this);
if($this->spawned){
if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
$permManager->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);