Removed a condition that's been useless almost since the beginning of PocketMine

This condition has been useless since before NBT was introduced to PocketMine.
If there was a use for it, it should have been placed BEFORE anything attempted to read from the NBT.

However, Server now handles bad data automatically now, so Server->getOfflinePlayerData() will never _not_ return a CompoundTag. Hence I've added a CompoundTag type-hint.
This commit is contained in:
Dylan K. Taylor 2017-03-26 13:20:46 +01:00
parent 4245274aec
commit dda8c6cc8f
2 changed files with 2 additions and 7 deletions

View File

@ -1751,6 +1751,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
$nbt = $this->server->getOfflinePlayerData($this->username);
$this->playedBefore = ($nbt["lastPlayed"] - $nbt["firstPlayed"]) > 1; // microtime(true) - microtime(true) may have less than one millisecond difference
if(!isset($nbt->NameTag)){
$nbt->NameTag = new StringTag("NameTag", $this->username);
@ -1775,12 +1776,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->setLevel($level);
}
if(!($nbt instanceof CompoundTag)){
$this->close($this->getLeaveMessage(), "Invalid data");
return;
}
$this->achievements = [];
/** @var ByteTag $achievement */

View File

@ -701,7 +701,7 @@ class Server{
*
* @return CompoundTag
*/
public function getOfflinePlayerData($name){
public function getOfflinePlayerData($name) : CompoundTag{
$name = strtolower($name);
$path = $this->getDataPath() . "players/";
if($this->shouldSavePlayerData()){