33
33
use pocketmine \network \mcpe \protocol \types \CacheableNbt ;
34
34
use pocketmine \utils \Filesystem ;
35
35
use pocketmine \utils \SingletonTrait ;
36
+ use pocketmine \utils \Utils ;
36
37
use pocketmine \world \biome \model \BiomeDefinitionEntryData ;
37
38
use function count ;
38
39
use function get_debug_type ;
@@ -54,18 +55,19 @@ private static function loadCompoundFromFile(string $filePath) : CacheableNbt{
54
55
* @return list<BiomeDefinitionEntry>
55
56
*/
56
57
private static function loadBiomeDefinitionModel (string $ filePath ) : array {
57
- $ biomeEntries = json_decode (Filesystem::fileGetContents ($ filePath ), false );
58
+ $ biomeEntries = json_decode (Filesystem::fileGetContents ($ filePath ), associative: true );
58
59
if (!is_array ($ biomeEntries )){
59
60
throw new SavedDataLoadingException ("$ filePath root should be an array, got " . get_debug_type ($ biomeEntries ));
60
61
}
61
62
62
63
$ jsonMapper = new \JsonMapper ();
63
64
$ jsonMapper ->bExceptionOnMissingData = true ;
64
65
$ jsonMapper ->bStrictObjectTypeChecking = true ;
66
+ $ jsonMapper ->bEnforceMapType = false ;
65
67
66
68
$ entries = [];
67
- foreach ($ biomeEntries as $ biomeName => $ entry ){
68
- if (!is_object ($ entry )){
69
+ foreach (Utils:: promoteKeys ( $ biomeEntries) as $ biomeName => $ entry ){
70
+ if (!is_array ($ entry )){
69
71
throw new SavedDataLoadingException ("$ filePath should be an array of objects, got " . get_debug_type ($ entry ));
70
72
}
71
73
@@ -74,7 +76,7 @@ private static function loadBiomeDefinitionModel(string $filePath) : array{
74
76
75
77
$ mapWaterColour = $ biomeDefinition ->mapWaterColour ;
76
78
$ entries [] = new BiomeDefinitionEntry (
77
- $ biomeName ,
79
+ ( string ) $ biomeName ,
78
80
$ biomeDefinition ->id ,
79
81
$ biomeDefinition ->temperature ,
80
82
$ biomeDefinition ->downfall ,
0 commit comments