level/format/io: populate missing return type information

This commit is contained in:
Dylan K. Taylor 2020-01-19 19:35:45 +00:00
parent 2c11742f9e
commit 82e9072223
6 changed files with 36 additions and 3 deletions

View File

@ -150,6 +150,9 @@ abstract class BaseLevelProvider implements LevelProvider{
return $this->levelData;
}
/**
* @return void
*/
public function saveLevelData(){
$nbt = new BigEndianNBTStream();
$buffer = $nbt->writeCompressed(new CompoundTag("", [

View File

@ -72,6 +72,8 @@ interface LevelProvider{
* @param int $seed
* @param string $generator
* @param array $options
*
* @return void
*/
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []);
@ -119,6 +121,8 @@ interface LevelProvider{
/**
* @param int $value
*
* @return void
*/
public function setTime(int $value);
@ -129,6 +133,8 @@ interface LevelProvider{
/**
* @param int $value
*
* @return void
*/
public function setSeed(int $value);
@ -139,6 +145,8 @@ interface LevelProvider{
/**
* @param Vector3 $pos
*
* @return void
*/
public function setSpawn(Vector3 $pos);
@ -152,16 +160,22 @@ interface LevelProvider{
* Sets the world difficulty.
*
* @param int $difficulty
*
* @return void
*/
public function setDifficulty(int $difficulty);
/**
* Performs garbage collection in the level provider, such as cleaning up regions in Region-based worlds.
*
* @return void
*/
public function doGarbageCollection();
/**
* Performs cleanups necessary when the level provider is closed and no longer needed.
*
* @return void
*/
public function close();

View File

@ -44,6 +44,7 @@ abstract class LevelProviderManager{
/**
* @param string $class
*
* @return void
* @throws \InvalidArgumentException
*/
public static function addProvider(string $class){

View File

@ -102,7 +102,7 @@ class LevelDB extends BaseLevelProvider{
/** @var \LevelDB */
protected $db;
private static function checkForLevelDBExtension(){
private static function checkForLevelDBExtension() : void{
if(!extension_loaded('leveldb')){
throw new LevelException("The leveldb PHP extension is required to use this world format");
}
@ -523,7 +523,7 @@ class LevelDB extends BaseLevelProvider{
* @param CompoundTag[] $targets
* @param string $index
*/
private function writeTags(array $targets, string $index){
private function writeTags(array $targets, string $index) : void{
if(count($targets) > 0){
$nbt = new LittleEndianNBTStream();
$this->db->put($index, $nbt->write($targets));

View File

@ -333,6 +333,8 @@ class McRegion extends BaseLevelProvider{
* @param int $chunkZ
* @param int $regionX reference parameter
* @param int $regionZ reference parameter
*
* @return void
*/
public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ){
$regionX = $chunkX >> 5;
@ -364,6 +366,8 @@ class McRegion extends BaseLevelProvider{
/**
* @param int $regionX
* @param int $regionZ
*
* @return void
*/
protected function loadRegion(int $regionX, int $regionZ){
if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){

View File

@ -87,6 +87,7 @@ class RegionLoader{
}
/**
* @return void
* @throws CorruptedRegionException
*/
public function open(){
@ -188,6 +189,7 @@ class RegionLoader{
* @param int $z
* @param string $chunkData
*
* @return void
* @throws ChunkException
* @throws \InvalidArgumentException
*/
@ -220,6 +222,7 @@ class RegionLoader{
* @param int $x
* @param int $z
*
* @return void
* @throws \InvalidArgumentException
*/
public function removeChunk(int $x, int $z){
@ -256,6 +259,8 @@ class RegionLoader{
* Writes the region header and closes the file
*
* @param bool $writeHeader
*
* @return void
*/
public function close(bool $writeHeader = true){
if(is_resource($this->filePointer)){
@ -268,6 +273,7 @@ class RegionLoader{
}
/**
* @return void
* @throws CorruptedRegionException
*/
protected function loadLocationTable(){
@ -329,7 +335,7 @@ class RegionLoader{
}
}
private function writeLocationTable(){
private function writeLocationTable() : void{
$write = [];
for($i = 0; $i < 1024; ++$i){
@ -344,6 +350,8 @@ class RegionLoader{
/**
* @param int $index
*
* @return void
*/
protected function writeLocationIndex($index){
fseek($this->filePointer, $index << 2);
@ -352,6 +360,9 @@ class RegionLoader{
fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index]->getTimestamp()), 4);
}
/**
* @return void
*/
protected function createBlank(){
fseek($this->filePointer, 0);
ftruncate($this->filePointer, 8192); // this fills the file with the null byte