mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Permission & interface optimization
This commit is contained in:
parent
78b4223795
commit
7ef2708fca
@ -97,8 +97,6 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
||||
/** @var ServerHandler */
|
||||
private $interface;
|
||||
|
||||
private $tickTask;
|
||||
|
||||
private $upload = 0;
|
||||
private $download = 0;
|
||||
|
||||
@ -109,7 +107,6 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
||||
$server = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp());
|
||||
$this->interface = new ServerHandler($server, $this);
|
||||
$this->setName($this->server->getMotd());
|
||||
$this->tickTask = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "doTick"]), 1);
|
||||
}
|
||||
|
||||
public function doTick(){
|
||||
@ -124,6 +121,8 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
||||
}
|
||||
}
|
||||
|
||||
$this->doTick();
|
||||
|
||||
return $work;
|
||||
}
|
||||
|
||||
@ -147,12 +146,10 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
||||
}
|
||||
|
||||
public function shutdown(){
|
||||
$this->tickTask->cancel();
|
||||
$this->interface->shutdown();
|
||||
}
|
||||
|
||||
public function emergencyShutdown(){
|
||||
$this->tickTask->cancel();
|
||||
$this->interface->emergencyShutdown();
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,12 @@ class PermissionAttachment{
|
||||
*/
|
||||
public function setPermission($name, $value){
|
||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||
unset($this->permissions[$name]); //Fixes children getting overwritten
|
||||
if(isset($this->permissions[$name])){
|
||||
if($this->permissions[$name] === $value){
|
||||
return;
|
||||
}
|
||||
unset($this->permissions[$name]); //Fixes children getting overwritten
|
||||
}
|
||||
$this->permissions[$name] = $value;
|
||||
$this->permissible->recalculatePermissions();
|
||||
}
|
||||
@ -131,8 +136,11 @@ class PermissionAttachment{
|
||||
* @param string|Permission $name
|
||||
*/
|
||||
public function unsetPermission($name){
|
||||
unset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
|
||||
$this->permissible->recalculatePermissions();
|
||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||
if(isset($this->permissions[$name])){
|
||||
unset($this->permissions[$name]);
|
||||
$this->permissible->recalculatePermissions();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user