mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09: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 */
|
/** @var int */
|
||||||
public $difficulty;
|
public $difficulty;
|
||||||
|
|
||||||
|
public static function create(int $difficulty) : self{
|
||||||
|
$result = new self;
|
||||||
|
$result->difficulty = $difficulty;
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
protected function decodePayload() : void{
|
protected function decodePayload() : void{
|
||||||
$this->difficulty = $this->getUnsignedVarInt();
|
$this->difficulty = $this->getUnsignedVarInt();
|
||||||
}
|
}
|
||||||
|
@ -2772,8 +2772,7 @@ class World implements ChunkManager, Metadatable{
|
|||||||
* @param Player ...$targets
|
* @param Player ...$targets
|
||||||
*/
|
*/
|
||||||
public function sendDifficulty(Player ...$targets){
|
public function sendDifficulty(Player ...$targets){
|
||||||
$pk = new SetDifficultyPacket();
|
$pk = SetDifficultyPacket::create($this->getDifficulty());
|
||||||
$pk->difficulty = $this->getDifficulty();
|
|
||||||
if(empty($targets)){
|
if(empty($targets)){
|
||||||
$this->broadcastGlobalPacket($pk);
|
$this->broadcastGlobalPacket($pk);
|
||||||
}else{
|
}else{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user