mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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 */
|
/** @var ServerHandler */
|
||||||
private $interface;
|
private $interface;
|
||||||
|
|
||||||
private $tickTask;
|
|
||||||
|
|
||||||
private $upload = 0;
|
private $upload = 0;
|
||||||
private $download = 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());
|
$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->interface = new ServerHandler($server, $this);
|
||||||
$this->setName($this->server->getMotd());
|
$this->setName($this->server->getMotd());
|
||||||
$this->tickTask = $this->server->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "doTick"]), 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doTick(){
|
public function doTick(){
|
||||||
@ -124,6 +121,8 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->doTick();
|
||||||
|
|
||||||
return $work;
|
return $work;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,12 +146,10 @@ class RakLibInterface implements ServerInstance, SourceInterface{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function shutdown(){
|
public function shutdown(){
|
||||||
$this->tickTask->cancel();
|
|
||||||
$this->interface->shutdown();
|
$this->interface->shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function emergencyShutdown(){
|
public function emergencyShutdown(){
|
||||||
$this->tickTask->cancel();
|
|
||||||
$this->interface->emergencyShutdown();
|
$this->interface->emergencyShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +122,12 @@ class PermissionAttachment{
|
|||||||
*/
|
*/
|
||||||
public function setPermission($name, $value){
|
public function setPermission($name, $value){
|
||||||
$name = $name instanceof Permission ? $name->getName() : $name;
|
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||||
|
if(isset($this->permissions[$name])){
|
||||||
|
if($this->permissions[$name] === $value){
|
||||||
|
return;
|
||||||
|
}
|
||||||
unset($this->permissions[$name]); //Fixes children getting overwritten
|
unset($this->permissions[$name]); //Fixes children getting overwritten
|
||||||
|
}
|
||||||
$this->permissions[$name] = $value;
|
$this->permissions[$name] = $value;
|
||||||
$this->permissible->recalculatePermissions();
|
$this->permissible->recalculatePermissions();
|
||||||
}
|
}
|
||||||
@ -131,9 +136,12 @@ class PermissionAttachment{
|
|||||||
* @param string|Permission $name
|
* @param string|Permission $name
|
||||||
*/
|
*/
|
||||||
public function unsetPermission($name){
|
public function unsetPermission($name){
|
||||||
unset($this->permissions[$name instanceof Permission ? $name->getName() : $name]);
|
$name = $name instanceof Permission ? $name->getName() : $name;
|
||||||
|
if(isset($this->permissions[$name])){
|
||||||
|
unset($this->permissions[$name]);
|
||||||
$this->permissible->recalculatePermissions();
|
$this->permissible->recalculatePermissions();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return void
|
* @return void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user