mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-16 18:59:00 +00:00
Added auto save to PlayerQuitEvent
This commit is contained in:
parent
6ee61cce7b
commit
96f67bdadf
@ -1726,7 +1726,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
$nbt->lastPlayed = new Long(floor(microtime(true) * 1000));
|
||||
$this->server->saveOfflinePlayerData($this->username, $nbt, true);
|
||||
if($this->server->getAutoSave()){
|
||||
$this->server->saveOfflinePlayerData($this->username, $nbt, true);
|
||||
}
|
||||
parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
|
||||
$this->loggedIn = true;
|
||||
|
||||
@ -2864,8 +2866,8 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
|
||||
$this->connected = false;
|
||||
if(strlen($this->getName()) > 0){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
|
||||
if($this->server->getAutoSave() and $this->loggedIn === true){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message, true));
|
||||
if($this->loggedIn === true and $ev->getAutoSave()){
|
||||
$this->save();
|
||||
}
|
||||
}
|
||||
@ -2948,7 +2950,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
}
|
||||
|
||||
$this->namedtag["playerGameType"] = $this->gamemode;
|
||||
$this->namedtag["lastPlayed"] = floor(microtime(true) * 1000);
|
||||
$this->namedtag["lastPlayed"] = new Long(floor(microtime(true) * 1000));
|
||||
|
||||
if($this->username != "" and $this->namedtag instanceof Compound){
|
||||
$this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async);
|
||||
|
@ -31,10 +31,12 @@ class PlayerQuitEvent extends PlayerEvent{
|
||||
|
||||
/** @var string */
|
||||
protected $quitMessage;
|
||||
protected $autoSave = true;
|
||||
|
||||
public function __construct(Player $player, $quitMessage){
|
||||
public function __construct(Player $player, $quitMessage, $autoSave = true){
|
||||
$this->player = $player;
|
||||
$this->quitMessage = $quitMessage;
|
||||
$this->autoSave = true;
|
||||
}
|
||||
|
||||
public function setQuitMessage($quitMessage){
|
||||
@ -45,4 +47,12 @@ class PlayerQuitEvent extends PlayerEvent{
|
||||
return $this->quitMessage;
|
||||
}
|
||||
|
||||
public function getAutoSave(){
|
||||
|
||||
}
|
||||
|
||||
public function setAutoSave($value = true){
|
||||
$this->autoSave = (bool) $value;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user