mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 02:09:42 +00:00
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:
parent
4245274aec
commit
dda8c6cc8f
@ -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 */
|
||||
|
@ -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()){
|
||||
|
Loading…
x
Reference in New Issue
Block a user