diff --git a/plugin.yml b/plugin.yml index fd0aea6..68701ba 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,6 +1,6 @@ name: FakePlayer main: muqsit\fakeplayer\Loader -api: 4.21.1 +api: 5.0.0 version: 0.2.4 permissions: diff --git a/src/muqsit/fakeplayer/DefaultFakePlayerListener.php b/src/muqsit/fakeplayer/DefaultFakePlayerListener.php index 2b53d47..c61eec4 100644 --- a/src/muqsit/fakeplayer/DefaultFakePlayerListener.php +++ b/src/muqsit/fakeplayer/DefaultFakePlayerListener.php @@ -7,7 +7,7 @@ use muqsit\fakeplayer\listener\FakePlayerListener; use muqsit\fakeplayer\network\FakePlayerNetworkSession; use muqsit\fakeplayer\network\listener\ClosureFakePlayerPacketListener; -use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\ChangeDimensionPacket; use pocketmine\network\mcpe\protocol\ClientboundPacket; @@ -39,7 +39,7 @@ public function onPlayerAdd(Player $player) : void{ $this->plugin->getScheduler()->scheduleDelayedTask(new ClosureTask(static function() use($session, $entity_runtime_id) : void{ if($session->isConnected()){ $packet = SetLocalPlayerAsInitializedPacket::create($entity_runtime_id); - $serializer = PacketSerializer::encoder(new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary())); + $serializer = PacketSerializer::encoder(new PacketSerializerContext(TypeConverter::getInstance()->getItemTypeDictionary())); $packet->encode($serializer); $session->handleDataPacket($packet, $serializer->getBuffer()); } @@ -74,7 +74,7 @@ public function onPlayerAdd(Player $player) : void{ 0 ); - $serializer = PacketSerializer::encoder(new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary())); + $serializer = PacketSerializer::encoder(new PacketSerializerContext(TypeConverter::getInstance()->getItemTypeDictionary())); $packet->encode($serializer); $session->handleDataPacket($packet, $serializer->getBuffer()); } diff --git a/src/muqsit/fakeplayer/FakePlayerCommandExecutor.php b/src/muqsit/fakeplayer/FakePlayerCommandExecutor.php index f7a64ca..4d4f8ba 100644 --- a/src/muqsit/fakeplayer/FakePlayerCommandExecutor.php +++ b/src/muqsit/fakeplayer/FakePlayerCommandExecutor.php @@ -11,7 +11,7 @@ use pocketmine\command\CommandExecutor; use pocketmine\command\CommandSender; use pocketmine\math\Vector3; -use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\ClientboundPacket; use pocketmine\network\mcpe\protocol\ModalFormResponsePacket; @@ -31,7 +31,7 @@ public function __construct( ){} private function sendServerPacket(Player $sender, Packet $packet) : void{ - $context = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()); + $context = new PacketSerializerContext(TypeConverter::getInstance()->getItemTypeDictionary()); $serializer = PacketSerializer::encoder($context); $packet->encode($serializer); $sender->getNetworkSession()->handleDataPacket($packet, $serializer->getBuffer()); diff --git a/src/muqsit/fakeplayer/Loader.php b/src/muqsit/fakeplayer/Loader.php index e4c8f2c..3126950 100644 --- a/src/muqsit/fakeplayer/Loader.php +++ b/src/muqsit/fakeplayer/Loader.php @@ -17,7 +17,7 @@ use pocketmine\event\Listener; use pocketmine\event\player\PlayerQuitEvent; use pocketmine\network\mcpe\compression\ZlibCompressor; -use pocketmine\network\mcpe\convert\GlobalItemTypeDictionary; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\protocol\PacketPool; use pocketmine\network\mcpe\protocol\ProtocolInfo; @@ -137,9 +137,10 @@ public function getFakePlayer(Player $player) : ?FakePlayer{ public function addPlayer(FakePlayerInfo $info) : Promise{ $server = $this->getServer(); $network = $server->getNetwork(); - $packet_serializer_context = new PacketSerializerContext(GlobalItemTypeDictionary::getInstance()->getDictionary()); + $type_converter = TypeConverter::getInstance(); + $packet_serializer_context = new PacketSerializerContext($type_converter->getItemTypeDictionary()); $packet_broadcaster = new StandardPacketBroadcaster($this->getServer(), $packet_serializer_context); - $entity_event_broadcaster = new StandardEntityEventBroadcaster($packet_broadcaster); + $entity_event_broadcaster = new StandardEntityEventBroadcaster($packet_broadcaster, $type_converter); $internal_resolver = new PromiseResolver(); $session = new FakePlayerNetworkSession( @@ -151,6 +152,7 @@ public function addPlayer(FakePlayerInfo $info) : Promise{ $packet_broadcaster, $entity_event_broadcaster, ZlibCompressor::getInstance(), + $type_converter, $server->getIp(), $server->getPort(), $internal_resolver diff --git a/src/muqsit/fakeplayer/network/FakePlayerNetworkSession.php b/src/muqsit/fakeplayer/network/FakePlayerNetworkSession.php index 78c33e7..9897f95 100644 --- a/src/muqsit/fakeplayer/network/FakePlayerNetworkSession.php +++ b/src/muqsit/fakeplayer/network/FakePlayerNetworkSession.php @@ -7,6 +7,7 @@ use muqsit\fakeplayer\network\listener\FakePlayerPacketListener; use muqsit\fakeplayer\network\listener\FakePlayerSpecificPacketListener; use pocketmine\network\mcpe\compression\Compressor; +use pocketmine\network\mcpe\convert\TypeConverter; use pocketmine\network\mcpe\EntityEventBroadcaster; use pocketmine\network\mcpe\NetworkSession; use pocketmine\network\mcpe\PacketBroadcaster; @@ -53,11 +54,12 @@ public function __construct( PacketBroadcaster $broadcaster, EntityEventBroadcaster $entityEventBroadcaster, Compressor $compressor, + TypeConverter $typeConverter, string $ip, int $port, PromiseResolver $player_add_resolver ){ - parent::__construct($server, $manager, $packetPool, $packetSerializerContext, $sender, $broadcaster, $entityEventBroadcaster, $compressor, $ip, $port); + parent::__construct($server, $manager, $packetPool, $packetSerializerContext, $sender, $broadcaster, $entityEventBroadcaster, $compressor, $typeConverter, $ip, $port); $this->player_add_resolver = $player_add_resolver; // do not store the resolver eternally