mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-18 17:34:11 +00:00
Player: extract getSaveData() from save()
this allows plugins to request this data whenever they want it (e.g. to save offline any time they want, instead of being confined to the server autosave interval).
This commit is contained in:
parent
eaaed79b93
commit
a3597e195a
@ -2031,10 +2031,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
throw new \BadMethodCallException("Players can't be saved with chunks");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles player data saving
|
||||
*/
|
||||
public function save() : void{
|
||||
public function getSaveData() : CompoundTag{
|
||||
$nbt = $this->saveNBT();
|
||||
|
||||
if($this->location->isValid()){
|
||||
@ -2063,7 +2060,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
|
||||
$nbt->setLong("firstPlayed", $this->firstPlayed);
|
||||
$nbt->setLong("lastPlayed", (int) floor(microtime(true) * 1000));
|
||||
|
||||
$this->server->saveOfflinePlayerData($this->username, $nbt);
|
||||
return $nbt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles player data saving
|
||||
*/
|
||||
public function save() : void{
|
||||
$this->server->saveOfflinePlayerData($this->username, $this->getSaveData());
|
||||
}
|
||||
|
||||
protected function onDeath() : void{
|
||||
|
Loading…
x
Reference in New Issue
Block a user