mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 02:21:46 +00:00
sync with latest codegen changes
This commit is contained in:
parent
ffb0ed80a2
commit
a3dea09e2a
@ -27,7 +27,7 @@ use pocketmine\utils\Binary;
|
|||||||
use pocketmine\utils\BinaryDataException;
|
use pocketmine\utils\BinaryDataException;
|
||||||
|
|
||||||
class PacketPool{
|
class PacketPool{
|
||||||
/** @var \SplFixedArray<DataPacket> */
|
/** @var \SplFixedArray<Packet> */
|
||||||
protected static $pool = null;
|
protected static $pool = null;
|
||||||
|
|
||||||
public static function init() : void{
|
public static function init() : void{
|
||||||
@ -159,28 +159,28 @@ class PacketPool{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DataPacket $packet
|
* @param Packet $packet
|
||||||
*/
|
*/
|
||||||
public static function registerPacket(DataPacket $packet) : void{
|
public static function registerPacket(Packet $packet) : void{
|
||||||
static::$pool[$packet->pid()] = clone $packet;
|
static::$pool[$packet->pid()] = clone $packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $pid
|
* @param int $pid
|
||||||
*
|
*
|
||||||
* @return DataPacket
|
* @return Packet
|
||||||
*/
|
*/
|
||||||
public static function getPacketById(int $pid) : DataPacket{
|
public static function getPacketById(int $pid) : Packet{
|
||||||
return isset(static::$pool[$pid]) ? clone static::$pool[$pid] : new UnknownPacket();
|
return isset(static::$pool[$pid]) ? clone static::$pool[$pid] : new UnknownPacket();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $buffer
|
* @param string $buffer
|
||||||
*
|
*
|
||||||
* @return DataPacket
|
* @return Packet
|
||||||
* @throws BinaryDataException
|
* @throws BinaryDataException
|
||||||
*/
|
*/
|
||||||
public static function getPacket(string $buffer) : DataPacket{
|
public static function getPacket(string $buffer) : Packet{
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
|
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
|
||||||
$pk->setBuffer($buffer, $offset);
|
$pk->setBuffer($buffer, $offset);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user