import io import struct class Packet(io.BytesIO): def put_byte(self, val) -> None: self.write(struct.pack(' int: return struct.unpack(' None: for byte in b: self.write(struct.pack(' bytes: return bytes(struct.unpack('<'+str(num)+'B', self.read(num))) def put_short(self, val) -> None: self.write(struct.pack(' int: return struct.unpack(' None: self.write(struct.pack(' None: self.write(struct.pack(' int: return struct.unpack(' int: return struct.unpack(' None: self.write(struct.pack(' int: return struct.unpack(' None: self.write(struct.pack(' float: return struct.unpack(' None: self.write(val + b'\x00') def put_string_size(self, val, size) -> None: self.write(val.encode("utf8") + b"\x00" * (size - len(val))) def get_string_until_none(self) -> str: s = "" c = self.get_byte() while c != 0x00: s += chr(c) c = self.get_byte() return s def get_string(self, size) -> str: return self.get_bytes(size).decode("utf8").replace("\x00", "") def get_3bytes_int(self) -> int: return struct.unpack(" None: self.write(struct.pack("