Merge pull request #14 from pmmp/disable-player-dat

Added options to disable saving <player>.dat
This commit is contained in:
SOFe 2016-10-07 18:47:01 +08:00 committed by GitHub
commit beabc5a85c
2 changed files with 32 additions and 20 deletions

View File

@ -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

View File

@ -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