mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-12 14:35:35 +00:00
Merge pull request #14 from pmmp/disable-player-dat
Added options to disable saving <player>.dat
This commit is contained in:
commit
beabc5a85c
@ -668,6 +668,10 @@ class Server{
|
||||
$this->craftingManager->registerRecipe($recipe);
|
||||
}
|
||||
|
||||
public function shouldSavePlayerData() : bool{
|
||||
return (bool) $this->getProperty("player.save-player-data", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
@ -692,6 +696,7 @@ class Server{
|
||||
public function getOfflinePlayerData($name){
|
||||
$name = strtolower($name);
|
||||
$path = $this->getDataPath() . "players/";
|
||||
if($this->shouldSavePlayerData()){
|
||||
if(file_exists($path . "$name.dat")){
|
||||
try{
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
@ -705,6 +710,7 @@ class Server{
|
||||
}else{
|
||||
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
|
||||
}
|
||||
}
|
||||
$spawn = $this->getDefaultLevel()->getSafeSpawn();
|
||||
$nbt = new CompoundTag("", [
|
||||
new LongTag("firstPlayed", floor(microtime(true) * 1000)),
|
||||
@ -806,6 +812,7 @@ class Server{
|
||||
* @param bool $async
|
||||
*/
|
||||
public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
|
||||
if($this->shouldSavePlayerData()){
|
||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||
try{
|
||||
$nbt->setData($nbtTag);
|
||||
@ -820,6 +827,7 @@ class Server{
|
||||
$this->logger->logException($e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
|
@ -90,6 +90,10 @@ debug:
|
||||
#Enables /status, /gc
|
||||
commands: false
|
||||
|
||||
player:
|
||||
#Choose whether to enable player data saving.
|
||||
save-player-data: true
|
||||
|
||||
level-settings:
|
||||
#The default format that levels will use when created
|
||||
default-format: mcregion
|
||||
|
Loading…
x
Reference in New Issue
Block a user