mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 01:09:44 +00:00
level/format/io: populate missing return type information
This commit is contained in:
parent
2c11742f9e
commit
82e9072223
@ -150,6 +150,9 @@ abstract class BaseLevelProvider implements LevelProvider{
|
|||||||
return $this->levelData;
|
return $this->levelData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
public function saveLevelData(){
|
public function saveLevelData(){
|
||||||
$nbt = new BigEndianNBTStream();
|
$nbt = new BigEndianNBTStream();
|
||||||
$buffer = $nbt->writeCompressed(new CompoundTag("", [
|
$buffer = $nbt->writeCompressed(new CompoundTag("", [
|
||||||
|
@ -72,6 +72,8 @@ interface LevelProvider{
|
|||||||
* @param int $seed
|
* @param int $seed
|
||||||
* @param string $generator
|
* @param string $generator
|
||||||
* @param array $options
|
* @param array $options
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []);
|
public static function generate(string $path, string $name, int $seed, string $generator, array $options = []);
|
||||||
|
|
||||||
@ -119,6 +121,8 @@ interface LevelProvider{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $value
|
* @param int $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setTime(int $value);
|
public function setTime(int $value);
|
||||||
|
|
||||||
@ -129,6 +133,8 @@ interface LevelProvider{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $value
|
* @param int $value
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setSeed(int $value);
|
public function setSeed(int $value);
|
||||||
|
|
||||||
@ -139,6 +145,8 @@ interface LevelProvider{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Vector3 $pos
|
* @param Vector3 $pos
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setSpawn(Vector3 $pos);
|
public function setSpawn(Vector3 $pos);
|
||||||
|
|
||||||
@ -152,16 +160,22 @@ interface LevelProvider{
|
|||||||
* Sets the world difficulty.
|
* Sets the world difficulty.
|
||||||
*
|
*
|
||||||
* @param int $difficulty
|
* @param int $difficulty
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function setDifficulty(int $difficulty);
|
public function setDifficulty(int $difficulty);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs garbage collection in the level provider, such as cleaning up regions in Region-based worlds.
|
* Performs garbage collection in the level provider, such as cleaning up regions in Region-based worlds.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function doGarbageCollection();
|
public function doGarbageCollection();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Performs cleanups necessary when the level provider is closed and no longer needed.
|
* Performs cleanups necessary when the level provider is closed and no longer needed.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function close();
|
public function close();
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ abstract class LevelProviderManager{
|
|||||||
/**
|
/**
|
||||||
* @param string $class
|
* @param string $class
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public static function addProvider(string $class){
|
public static function addProvider(string $class){
|
||||||
|
@ -102,7 +102,7 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
/** @var \LevelDB */
|
/** @var \LevelDB */
|
||||||
protected $db;
|
protected $db;
|
||||||
|
|
||||||
private static function checkForLevelDBExtension(){
|
private static function checkForLevelDBExtension() : void{
|
||||||
if(!extension_loaded('leveldb')){
|
if(!extension_loaded('leveldb')){
|
||||||
throw new LevelException("The leveldb PHP extension is required to use this world format");
|
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 CompoundTag[] $targets
|
||||||
* @param string $index
|
* @param string $index
|
||||||
*/
|
*/
|
||||||
private function writeTags(array $targets, string $index){
|
private function writeTags(array $targets, string $index) : void{
|
||||||
if(count($targets) > 0){
|
if(count($targets) > 0){
|
||||||
$nbt = new LittleEndianNBTStream();
|
$nbt = new LittleEndianNBTStream();
|
||||||
$this->db->put($index, $nbt->write($targets));
|
$this->db->put($index, $nbt->write($targets));
|
||||||
|
@ -333,6 +333,8 @@ class McRegion extends BaseLevelProvider{
|
|||||||
* @param int $chunkZ
|
* @param int $chunkZ
|
||||||
* @param int $regionX reference parameter
|
* @param int $regionX reference parameter
|
||||||
* @param int $regionZ reference parameter
|
* @param int $regionZ reference parameter
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ){
|
public static function getRegionIndex(int $chunkX, int $chunkZ, &$regionX, &$regionZ){
|
||||||
$regionX = $chunkX >> 5;
|
$regionX = $chunkX >> 5;
|
||||||
@ -364,6 +366,8 @@ class McRegion extends BaseLevelProvider{
|
|||||||
/**
|
/**
|
||||||
* @param int $regionX
|
* @param int $regionX
|
||||||
* @param int $regionZ
|
* @param int $regionZ
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function loadRegion(int $regionX, int $regionZ){
|
protected function loadRegion(int $regionX, int $regionZ){
|
||||||
if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){
|
if(!isset($this->regions[$index = Level::chunkHash($regionX, $regionZ)])){
|
||||||
|
@ -87,6 +87,7 @@ class RegionLoader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @return void
|
||||||
* @throws CorruptedRegionException
|
* @throws CorruptedRegionException
|
||||||
*/
|
*/
|
||||||
public function open(){
|
public function open(){
|
||||||
@ -188,6 +189,7 @@ class RegionLoader{
|
|||||||
* @param int $z
|
* @param int $z
|
||||||
* @param string $chunkData
|
* @param string $chunkData
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @throws ChunkException
|
* @throws ChunkException
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
@ -220,6 +222,7 @@ class RegionLoader{
|
|||||||
* @param int $x
|
* @param int $x
|
||||||
* @param int $z
|
* @param int $z
|
||||||
*
|
*
|
||||||
|
* @return void
|
||||||
* @throws \InvalidArgumentException
|
* @throws \InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function removeChunk(int $x, int $z){
|
public function removeChunk(int $x, int $z){
|
||||||
@ -256,6 +259,8 @@ class RegionLoader{
|
|||||||
* Writes the region header and closes the file
|
* Writes the region header and closes the file
|
||||||
*
|
*
|
||||||
* @param bool $writeHeader
|
* @param bool $writeHeader
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function close(bool $writeHeader = true){
|
public function close(bool $writeHeader = true){
|
||||||
if(is_resource($this->filePointer)){
|
if(is_resource($this->filePointer)){
|
||||||
@ -268,6 +273,7 @@ class RegionLoader{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @return void
|
||||||
* @throws CorruptedRegionException
|
* @throws CorruptedRegionException
|
||||||
*/
|
*/
|
||||||
protected function loadLocationTable(){
|
protected function loadLocationTable(){
|
||||||
@ -329,7 +335,7 @@ class RegionLoader{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writeLocationTable(){
|
private function writeLocationTable() : void{
|
||||||
$write = [];
|
$write = [];
|
||||||
|
|
||||||
for($i = 0; $i < 1024; ++$i){
|
for($i = 0; $i < 1024; ++$i){
|
||||||
@ -344,6 +350,8 @@ class RegionLoader{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $index
|
* @param int $index
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
protected function writeLocationIndex($index){
|
protected function writeLocationIndex($index){
|
||||||
fseek($this->filePointer, $index << 2);
|
fseek($this->filePointer, $index << 2);
|
||||||
@ -352,6 +360,9 @@ class RegionLoader{
|
|||||||
fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index]->getTimestamp()), 4);
|
fwrite($this->filePointer, Binary::writeInt($this->locationTable[$index]->getTimestamp()), 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
protected function createBlank(){
|
protected function createBlank(){
|
||||||
fseek($this->filePointer, 0);
|
fseek($this->filePointer, 0);
|
||||||
ftruncate($this->filePointer, 8192); // this fills the file with the null byte
|
ftruncate($this->filePointer, 8192); // this fills the file with the null byte
|
||||||
|
Loading…
x
Reference in New Issue
Block a user