mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-10-16 11:58:00 +00:00
World: relocate packet stuff for time and difficulty behind NetworkSession API
This commit is contained in:
@@ -54,8 +54,6 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundPacket;
|
||||
use pocketmine\network\mcpe\protocol\LevelEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetDifficultyPacket;
|
||||
use pocketmine\network\mcpe\protocol\SetTimePacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\Server;
|
||||
@@ -644,12 +642,8 @@ class World implements ChunkManager{
|
||||
* @param Player ...$targets If empty, will send to all players in the world.
|
||||
*/
|
||||
public function sendTime(Player ...$targets) : void{
|
||||
$pk = SetTimePacket::create($this->time);
|
||||
|
||||
if(count($targets) === 0){
|
||||
$this->broadcastGlobalPacket($pk);
|
||||
}else{
|
||||
$this->server->broadcastPackets($targets, [$pk]);
|
||||
foreach($targets as $player){
|
||||
$player->getNetworkSession()->syncWorldTime($this->time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2362,18 +2356,8 @@ class World implements ChunkManager{
|
||||
}
|
||||
$this->provider->getWorldData()->setDifficulty($difficulty);
|
||||
|
||||
$this->sendDifficulty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player ...$targets
|
||||
*/
|
||||
public function sendDifficulty(Player ...$targets) : void{
|
||||
$pk = SetDifficultyPacket::create($this->getDifficulty());
|
||||
if(count($targets) === 0){
|
||||
$this->broadcastGlobalPacket($pk);
|
||||
}else{
|
||||
$this->server->broadcastPackets($targets, [$pk]);
|
||||
foreach($this->players as $player){
|
||||
$player->getNetworkSession()->syncWorldDifficulty($this->getDifficulty());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user