From 6bbae4b2df5a526ad216f479dd9ac2aa83a114bc Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 25 Jun 2019 18:34:12 +0100 Subject: [PATCH] SetDifficultyPacket: added create() --- .../network/mcpe/protocol/SetDifficultyPacket.php | 6 ++++++ src/pocketmine/world/World.php | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php index cec01b77d..9aa2df4f4 100644 --- a/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php +++ b/src/pocketmine/network/mcpe/protocol/SetDifficultyPacket.php @@ -34,6 +34,12 @@ class SetDifficultyPacket extends DataPacket implements ClientboundPacket, Serve /** @var int */ public $difficulty; + public static function create(int $difficulty) : self{ + $result = new self; + $result->difficulty = $difficulty; + return $result; + } + protected function decodePayload() : void{ $this->difficulty = $this->getUnsignedVarInt(); } diff --git a/src/pocketmine/world/World.php b/src/pocketmine/world/World.php index 1f83e08ba..215882257 100644 --- a/src/pocketmine/world/World.php +++ b/src/pocketmine/world/World.php @@ -2772,8 +2772,7 @@ class World implements ChunkManager, Metadatable{ * @param Player ...$targets */ public function sendDifficulty(Player ...$targets){ - $pk = new SetDifficultyPacket(); - $pk->difficulty = $this->getDifficulty(); + $pk = SetDifficultyPacket::create($this->getDifficulty()); if(empty($targets)){ $this->broadcastGlobalPacket($pk); }else{