35 use GetTypeIdFromConstTrait;
37 public const ID = DataStoreOperationType::UPDATE;
39 public function __construct(
41 private string $property,
44 private int $updateCount,
45 private int $pathUpdateCount,
48 public function getName() :
string{
return $this->name; }
50 public function getProperty() :
string{
return $this->property; }
52 public function getPath() :
string{
return $this->path; }
56 public function getUpdateCount() :
int{
return $this->updateCount; }
58 public function getPathUpdateCount() :
int{
return $this->pathUpdateCount; }
60 public static function read(ByteBufferReader $in) :
self{
61 $name = CommonTypes::getString($in);
62 $property = CommonTypes::getString($in);
63 $path = CommonTypes::getString($in);
65 $data = match(VarInt::readUnsignedInt($in)){
66 DataStoreUpdateValueType::DOUBLE => DoubleDataStoreUpdateValue::read($in),
67 DataStoreUpdateValueType::BOOL => BoolDataStoreUpdateValue::read($in),
68 DataStoreUpdateValueType::STRING => StringDataStoreUpdateValue::read($in),
72 $updateCount = LE::readUnsignedInt($in);
73 $pathUpdateCount = LE::readUnsignedInt($in);
85 public function write(ByteBufferWriter $out) :
void{
86 CommonTypes::putString($out, $this->name);
87 CommonTypes::putString($out, $this->property);
88 CommonTypes::putString($out, $this->path);
89 VarInt::writeUnsignedInt($out, $this->data->getTypeId());
90 $this->data->write($out);
91 LE::writeUnsignedInt($out, $this->updateCount);
92 LE::writeUnsignedInt($out, $this->pathUpdateCount);