Updating for latest PocketMine-NBT changes

This commit is contained in:
Dylan K. Taylor
2019-03-21 15:58:22 +00:00
parent 1ac255f955
commit 8c536c248d
24 changed files with 237 additions and 266 deletions

View File

@ -61,6 +61,7 @@ use pocketmine\metadata\PlayerMetadataStore;
use pocketmine\nbt\BigEndianNbtSerializer;
use pocketmine\nbt\NbtDataException;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\TreeRoot;
use pocketmine\network\AdvancedNetworkInterface;
use pocketmine\network\mcpe\CompressBatchPromise;
use pocketmine\network\mcpe\CompressBatchTask;
@ -645,7 +646,7 @@ class Server{
if(file_exists($path . "$name.dat")){
try{
return (new BigEndianNbtSerializer())->readCompressed(file_get_contents($path . "$name.dat"));
return (new BigEndianNbtSerializer())->readCompressed(file_get_contents($path . "$name.dat"))->getTag();
}catch(NbtDataException $e){ //zlib decode error / corrupt data
rename($path . "$name.dat", $path . "$name.dat.bak");
$this->logger->error($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name]));
@ -667,7 +668,7 @@ class Server{
if(!$ev->isCancelled()){
$nbt = new BigEndianNbtSerializer();
try{
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed($ev->getSaveData()));
file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed(new TreeRoot($ev->getSaveData())));
}catch(\ErrorException $e){
$this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()]));
$this->logger->logException($e);