1
0
mirror of https://github.com/pmmp/PocketMine-MP.git synced 2025-07-14 22:01:59 +00:00

SetDifficultyPacket: added create()

This commit is contained in:
Dylan K. Taylor 2019-06-25 18:34:12 +01:00
parent ec25a71396
commit 6bbae4b2df
2 changed files with 7 additions and 2 deletions
src/pocketmine
network/mcpe/protocol
world

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

@ -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{