Permission & interface optimization

This commit is contained in:
Shoghi Cervantes 2014-09-11 16:43:11 +02:00
parent 78b4223795
commit 7ef2708fca
2 changed files with 13 additions and 8 deletions

View File

@ -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();
}

View File

@ -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();
}
}
/**