mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 02:08:21 +00:00
Server: fixed getOfflinePlayerData() trying to load terrain (?!?!?!?), closes #2725
getOfflinePlayerData() will now return NULL if there is no stored data for a given player. The responsibility of checking the spawn point is now delegated to the Player, after it registers a chunk loader on its spawn chunk.
This commit is contained in:
@ -648,31 +648,21 @@ class Server{
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
* @return CompoundTag
|
||||
* @return CompoundTag|null
|
||||
*/
|
||||
public function getOfflinePlayerData(string $name) : CompoundTag{
|
||||
public function getOfflinePlayerData(string $name) : ?CompoundTag{
|
||||
$name = strtolower($name);
|
||||
$path = $this->getDataPath() . "players/";
|
||||
if($this->shouldSavePlayerData()){
|
||||
if(file_exists($path . "$name.dat")){
|
||||
try{
|
||||
return (new BigEndianNbtSerializer())->readCompressed(file_get_contents($path . "$name.dat"));
|
||||
}catch(NbtDataException $e){ //zlib decode error / corrupt data
|
||||
rename($path . "$name.dat", $path . "$name.dat.bak");
|
||||
$this->logger->error($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
|
||||
}
|
||||
|
||||
if(file_exists($path . "$name.dat")){
|
||||
try{
|
||||
return (new BigEndianNbtSerializer())->readCompressed(file_get_contents($path . "$name.dat"));
|
||||
}catch(NbtDataException $e){ //zlib decode error / corrupt data
|
||||
rename($path . "$name.dat", $path . "$name.dat.bak");
|
||||
$this->logger->error($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
|
||||
}
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
|
||||
}
|
||||
$spawn = $this->levelManager->getDefaultLevel()->getSafeSpawn();
|
||||
|
||||
$nbt = EntityFactory::createBaseNBT($spawn);
|
||||
|
||||
$nbt->setString("Level", $this->levelManager->getDefaultLevel()->getFolderName());
|
||||
$nbt->setByte("OnGround", 1); //TODO: this hack is needed for new players in-air ticks - they don't get detected as on-ground until they move
|
||||
//TODO: old code had a TODO for SpawnForced
|
||||
|
||||
return $nbt;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user