diff --git a/src/matcracker/BedcoreProtect/tasks/async/BlocksQueryGeneratorTask.php b/src/matcracker/BedcoreProtect/tasks/async/BlocksQueryGeneratorTask.php index abf0d480..501018fa 100644 --- a/src/matcracker/BedcoreProtect/tasks/async/BlocksQueryGeneratorTask.php +++ b/src/matcracker/BedcoreProtect/tasks/async/BlocksQueryGeneratorTask.php @@ -26,8 +26,6 @@ use function count; use function is_array; use function mb_substr; -use function serialize; -use function unserialize; final class BlocksQueryGeneratorTask extends QueryGeneratorTask { @@ -46,8 +44,8 @@ final class BlocksQueryGeneratorTask extends QueryGeneratorTask public function __construct(int $firstInsertedId, array $oldBlocks, $newBlocks, ?callable $onComplete) { parent::__construct($firstInsertedId, $onComplete); - $this->oldBlocks = serialize($oldBlocks); - $this->newBlocks = serialize($newBlocks); + $this->oldBlocks = $oldBlocks; + $this->newBlocks = $newBlocks; } public function onRun(): void @@ -55,17 +53,12 @@ public function onRun(): void $query = /**@lang text */ "INSERT INTO blocks_log(history_id, old_id, old_meta, old_nbt, new_id, new_meta, new_nbt) VALUES"; - /** @var SerializableBlock[] $oldBlocks */ - $oldBlocks = unserialize($this->oldBlocks); - /** @var SerializableBlock[]|SerializableBlock $newBlocks */ - $newBlocks = unserialize($this->newBlocks); + if (!is_array($this->newBlocks)) { + $newId = $this->newBlocks->getId(); + $newMeta = $this->newBlocks->getMeta(); + $newNBT = $this->newBlocks->getSerializedNbt(); - if (!is_array($newBlocks)) { - $newId = $newBlocks->getId(); - $newMeta = $newBlocks->getMeta(); - $newNBT = $newBlocks->getSerializedNbt(); - - foreach ($oldBlocks as $oldBlock) { + foreach ($this->oldBlocks as $oldBlock) { $oldId = $oldBlock->getId(); $oldMeta = $oldBlock->getMeta(); $oldNBT = $oldBlock->getSerializedNbt(); @@ -73,12 +66,12 @@ public function onRun(): void $this->logId++; } } else { - if (count($oldBlocks) !== count($newBlocks)) { + if (count($this->oldBlocks) !== count($this->newBlocks)) { throw new ArrayOutOfBoundsException('The number of old blocks must be the same as new blocks, or vice-versa'); } - foreach ($oldBlocks as $key => $oldBlock) { - $newBlock = $newBlocks[$key]; + foreach ($this->oldBlocks as $key => $oldBlock) { + $newBlock = $this->newBlocks[$key]; $oldId = $oldBlock->getId(); $oldMeta = $oldBlock->getMeta(); $oldNBT = $oldBlock->getSerializedNbt();