diff --git a/src/Server.php b/src/Server.php index ddcb05027..0f496ee80 100644 --- a/src/Server.php +++ b/src/Server.php @@ -500,7 +500,7 @@ class Server{ $result = $this->getPlayerExact($name); if($result === null){ - $result = new OfflinePlayer($this, $name); + $result = new OfflinePlayer($name, $this->getOfflinePlayerData($name)); } return $result; diff --git a/src/player/IPlayer.php b/src/player/IPlayer.php index 43af6d3af..4fa30141e 100644 --- a/src/player/IPlayer.php +++ b/src/player/IPlayer.php @@ -25,8 +25,6 @@ namespace pocketmine\player; interface IPlayer{ - public function isOnline() : bool; - public function getName() : string; public function getFirstPlayed() : ?int; diff --git a/src/player/OfflinePlayer.php b/src/player/OfflinePlayer.php index a91ae8742..a90047b5d 100644 --- a/src/player/OfflinePlayer.php +++ b/src/player/OfflinePlayer.php @@ -25,35 +25,23 @@ namespace pocketmine\player; use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\tag\LongTag; -use pocketmine\Server; class OfflinePlayer implements IPlayer{ /** @var string */ private $name; - /** @var Server */ - private $server; /** @var CompoundTag|null */ - private $namedtag = null; + private $namedtag; - public function __construct(Server $server, string $name){ - $this->server = $server; + public function __construct(string $name, ?CompoundTag $namedtag){ $this->name = $name; - $this->namedtag = $this->server->getOfflinePlayerData($this->name); - } - - public function isOnline() : bool{ - return $this->getPlayer() !== null; + $this->namedtag = $namedtag; } public function getName() : string{ return $this->name; } - public function getPlayer() : ?Player{ - return $this->server->getPlayerExact($this->name); - } - public function getFirstPlayed() : ?int{ return ($this->namedtag !== null and ($firstPlayedTag = $this->namedtag->getTag("firstPlayed")) instanceof LongTag) ? $firstPlayedTag->getValue() : null; }