From 207f7ec30917a5238e6b07bf0da5d424cffdb88b Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Wed, 29 Dec 2021 20:22:16 +0000 Subject: [PATCH] Player: avoid unnecessary network updates on repeated calls to setAllowFLight(), setHasBlockCollision() and setAutoJump() --- src/player/Player.php | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/player/Player.php b/src/player/Player.php index f8efbcba8..41fa7acb7 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -396,8 +396,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function setAllowFlight(bool $value) : void{ - $this->allowFlight = $value; - $this->getNetworkSession()->syncAdventureSettings($this); + if($this->allowFlight !== $value){ + $this->allowFlight = $value; + $this->getNetworkSession()->syncAdventureSettings($this); + } } public function getAllowFlight() : bool{ @@ -405,8 +407,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function setHasBlockCollision(bool $value) : void{ - $this->blockCollision = $value; - $this->getNetworkSession()->syncAdventureSettings($this); + if($this->blockCollision !== $value){ + $this->blockCollision = $value; + $this->getNetworkSession()->syncAdventureSettings($this); + } } public function hasBlockCollision() : bool{ @@ -426,8 +430,10 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } public function setAutoJump(bool $value) : void{ - $this->autoJump = $value; - $this->getNetworkSession()->syncAdventureSettings($this); + if($this->autoJump !== $value){ + $this->autoJump = $value; + $this->getNetworkSession()->syncAdventureSettings($this); + } } public function hasAutoJump() : bool{