public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false)
{
if ($this->shouldSavePlayerData()) {
$nbt = new NBT(NBT::BIG_ENDIAN);
try {
$nbt->setData($nbtTag);
if ($async) {
$this->getScheduler()->scheduleAsyncTask(new FileWriteTask($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()));
} else {
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed());
}
} catch (\Throwable $e) {
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
$this->logger->logException($e);
}
}
}