mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-12 16:59:44 +00:00
SetDifficultyPacket: added create()
This commit is contained in:
parent
ec25a71396
commit
6bbae4b2df
@ -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{
|
||||
|
Loading…
x
Reference in New Issue
Block a user