ÂBedrockWorldData: throw less confusing errors on missing version tags

This commit is contained in:
Dylan K. Taylor 2023-06-19 12:22:50 +01:00
parent ff0199cdf8
commit eb9f804781
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -43,6 +43,7 @@ use pocketmine\world\WorldCreationOptions;
use Symfony\Component\Filesystem\Path;
use function array_map;
use function file_put_contents;
use function sprintf;
use function strlen;
use function substr;
use function time;
@ -154,12 +155,18 @@ class BedrockWorldData extends BaseNbtWorldData{
}
$version = $worldData->getInt(self::TAG_STORAGE_VERSION, Limits::INT32_MAX);
if($version === Limits::INT32_MAX){
throw new CorruptedWorldException(sprintf("Missing '%s' tag in level.dat", self::TAG_STORAGE_VERSION));
}
if($version > self::CURRENT_STORAGE_VERSION){
throw new UnsupportedWorldFormatException("LevelDB world format version $version is currently unsupported");
}
//StorageVersion is rarely updated - instead, the game relies on the NetworkVersion tag, which is synced with
//the network protocol version for that version.
$protocolVersion = $worldData->getInt(self::TAG_NETWORK_VERSION, Limits::INT32_MAX);
if($protocolVersion === Limits::INT32_MAX){
throw new CorruptedWorldException(sprintf("Missing '%s' tag in level.dat", self::TAG_NETWORK_VERSION));
}
if($protocolVersion > self::CURRENT_STORAGE_NETWORK_VERSION){
throw new UnsupportedWorldFormatException("LevelDB world protocol version $protocolVersion is currently unsupported");
}