2020use pmmp \encoding \Byte ;
2121use pmmp \encoding \ByteBufferReader ;
2222use pmmp \encoding \ByteBufferWriter ;
23+ use pmmp \encoding \DataDecodeException ;
2324use pmmp \encoding \LE ;
24- use pocketmine \utils \BinaryDataException ;
25- use pocketmine \utils \BinaryStream ;
2625use raklib \utils \InternetAddress ;
2726use function assert ;
2827use function count ;
3231use function strlen ;
3332use const AF_INET6 ;
3433
35- final class PacketSerializer extends BinaryStream{
34+ final class PacketSerializer{
35+ private function __construct (){
36+ //NOOP
37+ }
3638
3739 /**
38- * @throws BinaryDataException
40+ * @throws DataDecodeException
3941 */
4042 public static function getString (ByteBufferReader $ in ) : string {
4143 return $ in ->readByteArray (BE ::readUnsignedShort ($ in ));
4244 }
4345
4446 /**
45- * @throws BinaryDataException
47+ * @throws DataDecodeException
4648 */
4749 public static function getAddress (ByteBufferReader $ in ) : InternetAddress {
4850 $ version = Byte::readUnsigned ($ in );
@@ -57,12 +59,12 @@ public static function getAddress(ByteBufferReader $in) : InternetAddress{
5759 BE ::readUnsignedInt ($ in ); //flow info
5860 $ addr = inet_ntop ($ in ->readByteArray (16 ));
5961 if ($ addr === false ){
60- throw new BinaryDataException ("Failed to parse IPv6 address " );
62+ throw new DataDecodeException ("Failed to parse IPv6 address " );
6163 }
6264 BE ::readUnsignedInt ($ in ); //scope ID
6365 return new InternetAddress ($ addr , $ port , $ version );
6466 }else {
65- throw new BinaryDataException ("Unknown IP address version $ version " );
67+ throw new DataDecodeException ("Unknown IP address version $ version " );
6668 }
6769 }
6870
0 commit comments