mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-13 15:05:33 +00:00
Added options to disable saving player.dat
This commit is contained in:
parent
16c09e3610
commit
d6fd9259cf
@ -668,6 +668,10 @@ class Server{
|
|||||||
$this->craftingManager->registerRecipe($recipe);
|
$this->craftingManager->registerRecipe($recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function shouldSavePlayerData() : bool{
|
||||||
|
return (bool) $this->getProperty("player.save-player-data", true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
*
|
*
|
||||||
@ -692,7 +696,7 @@ class Server{
|
|||||||
public function getOfflinePlayerData($name){
|
public function getOfflinePlayerData($name){
|
||||||
$name = strtolower($name);
|
$name = strtolower($name);
|
||||||
$path = $this->getDataPath() . "players/";
|
$path = $this->getDataPath() . "players/";
|
||||||
if(file_exists($path . "$name.dat")){
|
if($this->shouldSavePlayerData() and file_exists($path . "$name.dat")){
|
||||||
try{
|
try{
|
||||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
|
$nbt->readCompressed(file_get_contents($path . "$name.dat"));
|
||||||
@ -806,6 +810,7 @@ class Server{
|
|||||||
* @param bool $async
|
* @param bool $async
|
||||||
*/
|
*/
|
||||||
public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
|
public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
|
||||||
|
if($this->shouldSavePlayerData()){
|
||||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||||
try{
|
try{
|
||||||
$nbt->setData($nbtTag);
|
$nbt->setData($nbtTag);
|
||||||
@ -820,6 +825,7 @@ class Server{
|
|||||||
$this->logger->logException($e);
|
$this->logger->logException($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
@ -90,6 +90,10 @@ debug:
|
|||||||
#Enables /status, /gc
|
#Enables /status, /gc
|
||||||
commands: false
|
commands: false
|
||||||
|
|
||||||
|
player:
|
||||||
|
#Choose whether to enable player data saving.
|
||||||
|
save-player-data: true
|
||||||
|
|
||||||
level-settings:
|
level-settings:
|
||||||
#The default format that levels will use when created
|
#The default format that levels will use when created
|
||||||
default-format: mcregion
|
default-format: mcregion
|
||||||
|
Loading…
x
Reference in New Issue
Block a user