mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Promote some constructors
This commit is contained in:
@ -136,11 +136,7 @@ use const SORT_NUMERIC;
|
||||
|
||||
class NetworkSession{
|
||||
private \PrefixedLogger $logger;
|
||||
private Server $server;
|
||||
private ?Player $player = null;
|
||||
private NetworkSessionManager $manager;
|
||||
private string $ip;
|
||||
private int $port;
|
||||
private ?PlayerInfo $info = null;
|
||||
private ?int $ping = null;
|
||||
|
||||
@ -163,37 +159,31 @@ class NetworkSession{
|
||||
* @phpstan-var \SplQueue<CompressBatchPromise>
|
||||
*/
|
||||
private \SplQueue $compressedQueue;
|
||||
private Compressor $compressor;
|
||||
private bool $forceAsyncCompression = true;
|
||||
|
||||
private PacketPool $packetPool;
|
||||
private PacketSerializerContext $packetSerializerContext;
|
||||
|
||||
private ?InventoryManager $invManager = null;
|
||||
|
||||
private PacketSender $sender;
|
||||
|
||||
private PacketBroadcaster $broadcaster;
|
||||
|
||||
/**
|
||||
* @var \Closure[]|ObjectSet
|
||||
* @phpstan-var ObjectSet<\Closure() : void>
|
||||
*/
|
||||
private ObjectSet $disposeHooks;
|
||||
|
||||
public function __construct(Server $server, NetworkSessionManager $manager, PacketPool $packetPool, PacketSender $sender, PacketBroadcaster $broadcaster, Compressor $compressor, string $ip, int $port){
|
||||
$this->server = $server;
|
||||
$this->manager = $manager;
|
||||
$this->sender = $sender;
|
||||
$this->broadcaster = $broadcaster;
|
||||
$this->ip = $ip;
|
||||
$this->port = $port;
|
||||
|
||||
public function __construct(
|
||||
private Server $server,
|
||||
private NetworkSessionManager $manager,
|
||||
private PacketPool $packetPool,
|
||||
private PacketSender $sender,
|
||||
private PacketBroadcaster $broadcaster,
|
||||
private Compressor $compressor,
|
||||
private string $ip,
|
||||
private int $port
|
||||
){
|
||||
$this->logger = new \PrefixedLogger($this->server->getLogger(), $this->getLogPrefix());
|
||||
|
||||
$this->compressedQueue = new \SplQueue();
|
||||
$this->compressor = $compressor;
|
||||
$this->packetPool = $packetPool;
|
||||
|
||||
//TODO: allow this to be injected
|
||||
$this->packetSerializerContext = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary());
|
||||
|
@ -56,11 +56,9 @@ final class GlobalItemTypeDictionary{
|
||||
return new self(new ItemTypeDictionary($params));
|
||||
}
|
||||
|
||||
private ItemTypeDictionary $dictionary;
|
||||
|
||||
public function __construct(ItemTypeDictionary $dictionary){
|
||||
$this->dictionary = $dictionary;
|
||||
}
|
||||
public function __construct(
|
||||
private ItemTypeDictionary $dictionary
|
||||
){}
|
||||
|
||||
public function getDictionary() : ItemTypeDictionary{ return $this->dictionary; }
|
||||
}
|
||||
|
@ -27,13 +27,10 @@ use pocketmine\snooze\SleeperNotifier;
|
||||
use raklib\server\ipc\InterThreadChannelWriter;
|
||||
|
||||
final class SnoozeAwarePthreadsChannelWriter implements InterThreadChannelWriter{
|
||||
private \Threaded $buffer;
|
||||
private SleeperNotifier $notifier;
|
||||
|
||||
public function __construct(\Threaded $buffer, SleeperNotifier $notifier){
|
||||
$this->buffer = $buffer;
|
||||
$this->notifier = $notifier;
|
||||
}
|
||||
public function __construct(
|
||||
private \Threaded $buffer,
|
||||
private SleeperNotifier $notifier
|
||||
){}
|
||||
|
||||
public function write(string $str) : void{
|
||||
$this->buffer[] = $str;
|
||||
|
Reference in New Issue
Block a user