Player: avoid unnecessary network updates on repeated calls to setAllowFLight(), setHasBlockCollision() and setAutoJump()

This commit is contained in:
Dylan K. Taylor 2021-12-29 20:22:16 +00:00
parent e0a6bc1d4a
commit 207f7ec309
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -396,8 +396,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
} }
public function setAllowFlight(bool $value) : void{ public function setAllowFlight(bool $value) : void{
$this->allowFlight = $value; if($this->allowFlight !== $value){
$this->getNetworkSession()->syncAdventureSettings($this); $this->allowFlight = $value;
$this->getNetworkSession()->syncAdventureSettings($this);
}
} }
public function getAllowFlight() : bool{ public function getAllowFlight() : bool{
@ -405,8 +407,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
} }
public function setHasBlockCollision(bool $value) : void{ public function setHasBlockCollision(bool $value) : void{
$this->blockCollision = $value; if($this->blockCollision !== $value){
$this->getNetworkSession()->syncAdventureSettings($this); $this->blockCollision = $value;
$this->getNetworkSession()->syncAdventureSettings($this);
}
} }
public function hasBlockCollision() : bool{ public function hasBlockCollision() : bool{
@ -426,8 +430,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
} }
public function setAutoJump(bool $value) : void{ public function setAutoJump(bool $value) : void{
$this->autoJump = $value; if($this->autoJump !== $value){
$this->getNetworkSession()->syncAdventureSettings($this); $this->autoJump = $value;
$this->getNetworkSession()->syncAdventureSettings($this);
}
} }
public function hasAutoJump() : bool{ public function hasAutoJump() : bool{