mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
fixed a bunch of NBT-related phpstan level 8 errors
This commit is contained in:
parent
68c408268c
commit
0188323d74
@ -93,10 +93,11 @@ class JavaWorldData extends BaseNbtWorldData{
|
||||
throw new CorruptedWorldException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
if(!$worldData->hasTag("Data", CompoundTag::class)){
|
||||
$dataTag = $worldData->getTag("Data");
|
||||
if(!($dataTag instanceof CompoundTag)){
|
||||
throw new CorruptedWorldException("Missing 'Data' key or wrong type");
|
||||
}
|
||||
return $worldData->getCompoundTag("Data");
|
||||
return $dataTag;
|
||||
}
|
||||
|
||||
protected function fix() : void{
|
||||
|
@ -65,12 +65,11 @@ trait LegacyAnvilChunkTrait{
|
||||
}catch(NbtDataException $e){
|
||||
throw new CorruptedChunkException($e->getMessage(), 0, $e);
|
||||
}
|
||||
if(!$chunk->hasTag("Level")){
|
||||
$chunk = $chunk->getTag("Level");
|
||||
if(!($chunk instanceof CompoundTag)){
|
||||
throw new CorruptedChunkException("'Level' key is missing from chunk NBT");
|
||||
}
|
||||
|
||||
$chunk = $chunk->getCompoundTag("Level");
|
||||
|
||||
$subChunks = [];
|
||||
$subChunksTag = $chunk->getListTag("Sections") ?? [];
|
||||
foreach($subChunksTag as $subChunk){
|
||||
@ -97,8 +96,8 @@ trait LegacyAnvilChunkTrait{
|
||||
$chunk->getInt("xPos"),
|
||||
$chunk->getInt("zPos"),
|
||||
$subChunks,
|
||||
$chunk->hasTag("Entities", ListTag::class) ? self::getCompoundList("Entities", $chunk->getListTag("Entities")) : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? self::getCompoundList("TileEntities", $chunk->getListTag("TileEntities")) : [],
|
||||
($entitiesTag = $chunk->getTag("Entities")) instanceof ListTag ? self::getCompoundList("Entities", $entitiesTag) : [],
|
||||
($tilesTag = $chunk->getTag("TileEntities")) instanceof ListTag ? self::getCompoundList("TileEntities", $tilesTag) : [],
|
||||
$biomeArray
|
||||
);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
|
@ -27,6 +27,7 @@ use pocketmine\block\BlockLegacyIds;
|
||||
use pocketmine\nbt\BigEndianNbtSerializer;
|
||||
use pocketmine\nbt\NbtDataException;
|
||||
use pocketmine\nbt\tag\ByteArrayTag;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntArrayTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\world\format\BiomeArray;
|
||||
@ -61,12 +62,11 @@ class McRegion extends RegionWorldProvider{
|
||||
}catch(NbtDataException $e){
|
||||
throw new CorruptedChunkException($e->getMessage(), 0, $e);
|
||||
}
|
||||
if(!$chunk->hasTag("Level")){
|
||||
$chunk = $chunk->getTag("Level");
|
||||
if(!($chunk instanceof CompoundTag)){
|
||||
throw new CorruptedChunkException("'Level' key is missing from chunk NBT");
|
||||
}
|
||||
|
||||
$chunk = $chunk->getCompoundTag("Level");
|
||||
|
||||
$subChunks = [];
|
||||
$fullIds = $chunk->hasTag("Blocks", ByteArrayTag::class) ? $chunk->getByteArray("Blocks") : str_repeat("\x00", 32768);
|
||||
$fullData = $chunk->hasTag("Data", ByteArrayTag::class) ? $chunk->getByteArray("Data") : str_repeat("\x00", 16384);
|
||||
@ -93,8 +93,8 @@ class McRegion extends RegionWorldProvider{
|
||||
$chunk->getInt("xPos"),
|
||||
$chunk->getInt("zPos"),
|
||||
$subChunks,
|
||||
$chunk->hasTag("Entities", ListTag::class) ? self::getCompoundList("Entities", $chunk->getListTag("Entities")) : [],
|
||||
$chunk->hasTag("TileEntities", ListTag::class) ? self::getCompoundList("TileEntities", $chunk->getListTag("TileEntities")) : [],
|
||||
($entitiesTag = $chunk->getTag("Entities")) instanceof ListTag ? self::getCompoundList("Entities", $entitiesTag) : [],
|
||||
($tilesTag = $chunk->getTag("TileEntities")) instanceof ListTag ? self::getCompoundList("TileEntities", $tilesTag) : [],
|
||||
$biomeIds
|
||||
);
|
||||
$result->setPopulated($chunk->getByte("TerrainPopulated", 0) !== 0);
|
||||
|
@ -785,116 +785,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/world/format/HeightArray.php
|
||||
|
||||
-
|
||||
message: "#^Method pocketmine\\\\world\\\\format\\\\io\\\\data\\\\JavaWorldData\\:\\:load\\(\\) should return pocketmine\\\\nbt\\\\tag\\\\CompoundTag but returns pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/data/JavaWorldData.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getListTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 3
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method hasTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 4
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getIntArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByteArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getInt\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$list of static method pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionWorldProvider\\:\\:getCompoundList\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\ListTag, pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null given\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByte\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/Anvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getListTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 3
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method hasTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 4
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getIntArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByteArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getInt\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$list of static method pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionWorldProvider\\:\\:getCompoundList\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\ListTag, pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null given\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByte\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/PMAnvil.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByteArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 3
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method hasTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 6
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getIntArray\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getInt\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getListTag\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#2 \\$list of static method pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionWorldProvider\\:\\:getCompoundList\\(\\) expects pocketmine\\\\nbt\\\\tag\\\\ListTag, pocketmine\\\\nbt\\\\tag\\\\ListTag\\|null given\\.$#"
|
||||
count: 2
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method getByte\\(\\) on pocketmine\\\\nbt\\\\tag\\\\CompoundTag\\|null\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/world/format/io/region/McRegion.php
|
||||
|
||||
-
|
||||
message: "#^Cannot call method readChunk\\(\\) on pocketmine\\\\world\\\\format\\\\io\\\\region\\\\RegionLoader\\|null\\.$#"
|
||||
count: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user