mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-07 10:31:51 +00:00
Server: added API method hasOfflinePlayerData()
This commit is contained in:
parent
3bb22f9778
commit
9d8898a4ed
@ -35,7 +35,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
|||||||
/** @var Server */
|
/** @var Server */
|
||||||
private $server;
|
private $server;
|
||||||
/** @var CompoundTag|null */
|
/** @var CompoundTag|null */
|
||||||
private $namedtag;
|
private $namedtag = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Server $server
|
* @param Server $server
|
||||||
@ -44,10 +44,8 @@ class OfflinePlayer implements IPlayer, Metadatable{
|
|||||||
public function __construct(Server $server, string $name){
|
public function __construct(Server $server, string $name){
|
||||||
$this->server = $server;
|
$this->server = $server;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
if(file_exists($this->server->getDataPath() . "players/" . strtolower($this->name) . ".dat")){
|
if($this->server->hasOfflinePlayerData($this->name)){
|
||||||
$this->namedtag = $this->server->getOfflinePlayerData($this->name);
|
$this->namedtag = $this->server->getOfflinePlayerData($this->name);
|
||||||
}else{
|
|
||||||
$this->namedtag = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,6 +735,17 @@ class Server{
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether the server has stored any saved data for this player.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasOfflinePlayerData(string $name) : bool{
|
||||||
|
return file_exists($this->getDataPath() . "players/$name.dat");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user