From 2a07638af3a76555ad292d688a12af80e1647366 Mon Sep 17 00:00:00 2001 From: SOF3 Date: Fri, 7 Oct 2016 17:52:25 +0800 Subject: [PATCH] Do not show playerNotFound notice if player data should not be saved --- src/pocketmine/Server.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index f127107f4..cc75168cc 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -696,18 +696,20 @@ class Server{ public function getOfflinePlayerData($name){ $name = strtolower($name); $path = $this->getDataPath() . "players/"; - if($this->shouldSavePlayerData() and file_exists($path . "$name.dat")){ - try{ - $nbt = new NBT(NBT::BIG_ENDIAN); - $nbt->readCompressed(file_get_contents($path . "$name.dat")); + if($this->shouldSavePlayerData()){ + if(file_exists($path . "$name.dat")){ + try{ + $nbt = new NBT(NBT::BIG_ENDIAN); + $nbt->readCompressed(file_get_contents($path . "$name.dat")); - return $nbt->getData(); - }catch(\Throwable $e){ //zlib decode error / corrupt data - rename($path . "$name.dat", $path . "$name.dat.bak"); - $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name])); + return $nbt->getData(); + }catch(\Throwable $e){ //zlib decode error / corrupt data + rename($path . "$name.dat", $path . "$name.dat.bak"); + $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name])); + } + }else{ + $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name])); } - }else{ - $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name])); } $spawn = $this->getDefaultLevel()->getSafeSpawn(); $nbt = new CompoundTag("", [