mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 09:56:06 +00:00
Promote some constructors
This commit is contained in:
@ -28,13 +28,12 @@ namespace pocketmine\world\format\io;
|
||||
*/
|
||||
class ReadOnlyWorldProviderManagerEntry extends WorldProviderManagerEntry{
|
||||
|
||||
/** @phpstan-var FromPath */
|
||||
private \Closure $fromPath;
|
||||
|
||||
/** @phpstan-param FromPath $fromPath */
|
||||
public function __construct(\Closure $isValid, \Closure $fromPath){
|
||||
public function __construct(
|
||||
\Closure $isValid,
|
||||
private \Closure $fromPath
|
||||
){
|
||||
parent::__construct($isValid);
|
||||
$this->fromPath = $fromPath;
|
||||
}
|
||||
|
||||
public function fromPath(string $path) : WorldProvider{ return ($this->fromPath)($path); }
|
||||
|
@ -31,13 +31,10 @@ use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
|
||||
*/
|
||||
abstract class WorldProviderManagerEntry{
|
||||
|
||||
/** @phpstan-var IsValid */
|
||||
protected \Closure $isValid;
|
||||
|
||||
/** @phpstan-param IsValid $isValid */
|
||||
protected function __construct(\Closure $isValid){
|
||||
$this->isValid = $isValid;
|
||||
}
|
||||
protected function __construct(
|
||||
protected \Closure $isValid
|
||||
){}
|
||||
|
||||
/**
|
||||
* Tells if the path is a valid world.
|
||||
|
@ -30,19 +30,17 @@ use pocketmine\world\WorldCreationOptions;
|
||||
* @phpstan-type Generate \Closure(string $path, string $name, WorldCreationOptions $options) : void
|
||||
*/
|
||||
final class WritableWorldProviderManagerEntry extends WorldProviderManagerEntry{
|
||||
/** @phpstan-var FromPath */
|
||||
private \Closure $fromPath;
|
||||
/** @phpstan-var Generate */
|
||||
private \Closure $generate;
|
||||
|
||||
/**
|
||||
* @phpstan-param FromPath $fromPath
|
||||
* @phpstan-param Generate $generate
|
||||
*/
|
||||
public function __construct(\Closure $isValid, \Closure $fromPath, \Closure $generate){
|
||||
public function __construct(
|
||||
\Closure $isValid,
|
||||
private \Closure $fromPath,
|
||||
private \Closure $generate
|
||||
){
|
||||
parent::__construct($isValid);
|
||||
$this->fromPath = $fromPath;
|
||||
$this->generate = $generate;
|
||||
}
|
||||
|
||||
public function fromPath(string $path) : WritableWorldProvider{
|
||||
|
@ -26,13 +26,10 @@ namespace pocketmine\world\generator;
|
||||
use function exp;
|
||||
|
||||
final class Gaussian{
|
||||
public int $smoothSize;
|
||||
/** @var float[][] */
|
||||
public array $kernel = [];
|
||||
|
||||
public function __construct(int $smoothSize){
|
||||
$this->smoothSize = $smoothSize;
|
||||
|
||||
public function __construct(public int $smoothSize){
|
||||
$bellSize = 1 / $this->smoothSize;
|
||||
$bellHeight = 2 * $this->smoothSize;
|
||||
|
||||
|
@ -41,10 +41,6 @@ use function igbinary_unserialize;
|
||||
class PopulationTask extends AsyncTask{
|
||||
private const TLS_KEY_ON_COMPLETION = "onCompletion";
|
||||
|
||||
private int $worldId;
|
||||
private int $chunkX;
|
||||
private int $chunkZ;
|
||||
|
||||
private ?string $chunk;
|
||||
|
||||
private string $adjacentChunks;
|
||||
@ -54,10 +50,14 @@ class PopulationTask extends AsyncTask{
|
||||
* @phpstan-param array<int, Chunk|null> $adjacentChunks
|
||||
* @phpstan-param OnCompletion $onCompletion
|
||||
*/
|
||||
public function __construct(int $worldId, int $chunkX, int $chunkZ, ?Chunk $chunk, array $adjacentChunks, \Closure $onCompletion){
|
||||
$this->worldId = $worldId;
|
||||
$this->chunkX = $chunkX;
|
||||
$this->chunkZ = $chunkZ;
|
||||
public function __construct(
|
||||
private int $worldId,
|
||||
private int $chunkX,
|
||||
private int $chunkZ,
|
||||
?Chunk $chunk,
|
||||
array $adjacentChunks,
|
||||
\Closure $onCompletion
|
||||
){
|
||||
$this->chunk = $chunk !== null ? FastChunkSerializer::serializeTerrain($chunk) : null;
|
||||
|
||||
$this->adjacentChunks = igbinary_serialize(array_map(
|
||||
|
Reference in New Issue
Block a user