26 use GetTypeIdFromConstTrait;
28 public const ID = DynamicValueType::MAP;
42 public function getValue() : array{ return $this->value; }
44 protected static function readValue(ByteBufferReader $in) : self{
47 for($i = 0, $count = VarInt::readUnsignedInt($in); $i < $count; $i++){
48 $key = CommonTypes::getString($in);
50 $type = LE::readUnsignedInt($in);
51 $value[$key] = DynamicValue::read($in, $type);
54 return new self($value);
57 protected function writeValue(ByteBufferWriter $out) : void{
58 VarInt::writeUnsignedInt($out, count($this->value));
59 foreach($this->value as $key => $value){
60 CommonTypes::putString($out, (
string) $key);
61 LE::writeUnsignedInt($out, $value?->getTypeId() ?? DynamicValueType::NULL);