mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Added some missing typehints
This commit is contained in:
parent
89643ff9af
commit
c4c6c58615
@ -2343,7 +2343,7 @@ class Server{
|
|||||||
$p->dataPacket($pk);
|
$p->dataPacket($pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkTickUpdates($currentTick, $tickTime){
|
private function checkTickUpdates(int $currentTick, float $tickTime) : void{
|
||||||
foreach($this->players as $p){
|
foreach($this->players as $p){
|
||||||
if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){
|
if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){
|
||||||
$p->close("", "Login timeout");
|
$p->close("", "Login timeout");
|
||||||
|
@ -67,7 +67,7 @@ class Leaves extends Transparent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null) : bool{
|
protected function findLog(Block $pos, array $visited, int $distance, &$check, ?int $fromSide = null) : bool{
|
||||||
++$check;
|
++$check;
|
||||||
$index = $pos->x . "." . $pos->y . "." . $pos->z;
|
$index = $pos->x . "." . $pos->y . "." . $pos->z;
|
||||||
if(isset($visited[$index])){
|
if(isset($visited[$index])){
|
||||||
|
@ -38,7 +38,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
|
|||||||
* @param string $name
|
* @param string $name
|
||||||
* @param Plugin $owner
|
* @param Plugin $owner
|
||||||
*/
|
*/
|
||||||
public function __construct($name, Plugin $owner){
|
public function __construct(string $name, Plugin $owner){
|
||||||
parent::__construct($name);
|
parent::__construct($name);
|
||||||
$this->owningPlugin = $owner;
|
$this->owningPlugin = $owner;
|
||||||
$this->executor = $owner;
|
$this->executor = $owner;
|
||||||
|
@ -43,7 +43,7 @@ class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
|
|||||||
* @param Player $player
|
* @param Player $player
|
||||||
* @param string $message
|
* @param string $message
|
||||||
*/
|
*/
|
||||||
public function __construct(Player $player, $message){
|
public function __construct(Player $player, string $message){
|
||||||
$this->player = $player;
|
$this->player = $player;
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
}
|
}
|
||||||
|
@ -850,7 +850,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @param bool $optimizeRebuilds
|
* @param bool $optimizeRebuilds
|
||||||
*/
|
*/
|
||||||
public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){
|
public function sendBlocks(array $target, array $blocks, int $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){
|
||||||
$packets = [];
|
$packets = [];
|
||||||
if($optimizeRebuilds){
|
if($optimizeRebuilds){
|
||||||
$chunks = [];
|
$chunks = [];
|
||||||
@ -2067,7 +2067,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
*
|
*
|
||||||
* @return Entity[]
|
* @return Entity[]
|
||||||
*/
|
*/
|
||||||
public function getChunkEntities($X, $Z) : array{
|
public function getChunkEntities(int $X, int $Z) : array{
|
||||||
return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : [];
|
return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2079,7 +2079,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
*
|
*
|
||||||
* @return Tile[]
|
* @return Tile[]
|
||||||
*/
|
*/
|
||||||
public function getChunkTiles($X, $Z) : array{
|
public function getChunkTiles(int $X, int $Z) : array{
|
||||||
return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getTiles() : [];
|
return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getTiles() : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ class SimpleChunkManager implements ChunkManager{
|
|||||||
* @param int $seed
|
* @param int $seed
|
||||||
* @param int $worldHeight
|
* @param int $worldHeight
|
||||||
*/
|
*/
|
||||||
public function __construct($seed, int $worldHeight = Level::Y_MAX){
|
public function __construct(int $seed, int $worldHeight = Level::Y_MAX){
|
||||||
$this->seed = $seed;
|
$this->seed = $seed;
|
||||||
$this->worldHeight = $worldHeight;
|
$this->worldHeight = $worldHeight;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ class Chunk{
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setBlock(int $x, int $y, int $z, $blockId = null, $meta = null) : bool{
|
public function setBlock(int $x, int $y, int $z, ?int $blockId = null, ?int $meta = null) : bool{
|
||||||
if($this->getSubChunk($y >> 4, true)->setBlock($x, $y & 0x0f, $z, $blockId !== null ? ($blockId & 0xff) : null, $meta !== null ? ($meta & 0x0f) : null)){
|
if($this->getSubChunk($y >> 4, true)->setBlock($x, $y & 0x0f, $z, $blockId !== null ? ($blockId & 0xff) : null, $meta !== null ? ($meta & 0x0f) : null)){
|
||||||
$this->hasChanged = true;
|
$this->hasChanged = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -59,7 +59,7 @@ class EmptySubChunk implements SubChunkInterface{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool{
|
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class SubChunk implements SubChunkInterface{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool{
|
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool{
|
||||||
$i = ($x << 8) | ($z << 4) | $y;
|
$i = ($x << 8) | ($z << 4) | $y;
|
||||||
$changed = false;
|
$changed = false;
|
||||||
if($id !== null){
|
if($id !== null){
|
||||||
|
@ -87,7 +87,7 @@ interface SubChunkInterface{
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function setBlock(int $x, int $y, int $z, $id = null, $data = null) : bool;
|
public function setBlock(int $x, int $y, int $z, ?int $id = null, ?int $data = null) : bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param int $x
|
* @param int $x
|
||||||
|
@ -56,12 +56,12 @@ class TallGrass extends Populator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function canTallGrassStay($x, $y, $z){
|
private function canTallGrassStay(int $x, int $y, int $z) : bool{
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
return ($b === Block::AIR or $b === Block::SNOW_LAYER) and $this->level->getBlockIdAt($x, $y - 1, $z) === Block::GRASS;
|
return ($b === Block::AIR or $b === Block::SNOW_LAYER) and $this->level->getBlockIdAt($x, $y - 1, $z) === Block::GRASS;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHighestWorkableBlock($x, $z){
|
private function getHighestWorkableBlock(int $x, int $z) : int{
|
||||||
for($y = 127; $y >= 0; --$y){
|
for($y = 127; $y >= 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){
|
if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){
|
||||||
|
@ -63,7 +63,7 @@ class Tree extends Populator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getHighestWorkableBlock($x, $z){
|
private function getHighestWorkableBlock(int $x, int $z) : int{
|
||||||
for($y = 127; $y > 0; --$y){
|
for($y = 127; $y > 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if($b === Block::DIRT or $b === Block::GRASS){
|
if($b === Block::DIRT or $b === Block::GRASS){
|
||||||
|
@ -70,7 +70,7 @@ class QueryHandler{
|
|||||||
$this->token = random_bytes(16);
|
$this->token = random_bytes(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getTokenString($token, $salt){
|
public static function getTokenString(string $token, string $salt) : int{
|
||||||
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
return Binary::readInt(substr(hash("sha512", $salt . ":" . $token, true), 7, 4));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,15 +71,15 @@ class RCONInstance extends Thread{
|
|||||||
$this->start(PTHREADS_INHERIT_NONE);
|
$this->start(PTHREADS_INHERIT_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function writePacket($client, $requestID, $packetType, $payload){
|
private function writePacket($client, int $requestID, int $packetType, string $payload){
|
||||||
$pk = Binary::writeLInt((int) $requestID)
|
$pk = Binary::writeLInt($requestID)
|
||||||
. Binary::writeLInt((int) $packetType)
|
. Binary::writeLInt($packetType)
|
||||||
. $payload
|
. $payload
|
||||||
. "\x00\x00"; //Terminate payload and packet
|
. "\x00\x00"; //Terminate payload and packet
|
||||||
return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk);
|
return socket_write($client, Binary::writeLInt(strlen($pk)) . $pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function readPacket($client, &$requestID, &$packetType, &$payload){
|
private function readPacket($client, ?int &$requestID, ?int &$packetType, ?string &$payload){
|
||||||
$d = socket_read($client, 4);
|
$d = socket_read($client, 4);
|
||||||
if($this->stop){
|
if($this->stop){
|
||||||
return false;
|
return false;
|
||||||
|
@ -178,7 +178,7 @@ class Permission{
|
|||||||
*
|
*
|
||||||
* @return Permission|null Permission if $name is a string, null if it's a Permission
|
* @return Permission|null Permission if $name is a string, null if it's a Permission
|
||||||
*/
|
*/
|
||||||
public function addParent($name, $value){
|
public function addParent($name, bool $value){
|
||||||
if($name instanceof Permission){
|
if($name instanceof Permission){
|
||||||
$name->getChildren()[$this->getName()] = $value;
|
$name->getChildren()[$this->getName()] = $value;
|
||||||
$name->recalculatePermissibles();
|
$name->recalculatePermissibles();
|
||||||
|
@ -112,7 +112,7 @@ class PharPluginLoader implements PluginLoader{
|
|||||||
* @param string $dataFolder
|
* @param string $dataFolder
|
||||||
* @param string $file
|
* @param string $file
|
||||||
*/
|
*/
|
||||||
private function initPlugin(PluginBase $plugin, PluginDescription $description, $dataFolder, $file){
|
private function initPlugin(PluginBase $plugin, PluginDescription $description, string $dataFolder, string $file){
|
||||||
$plugin->init($this, $this->server, $description, $dataFolder, $file);
|
$plugin->init($this, $this->server, $description, $dataFolder, $file);
|
||||||
$plugin->onLoad();
|
$plugin->onLoad();
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ abstract class PluginBase implements Plugin{
|
|||||||
return $this->description;
|
return $this->description;
|
||||||
}
|
}
|
||||||
|
|
||||||
final public function init(PluginLoader $loader, Server $server, PluginDescription $description, $dataFolder, $file){
|
final public function init(PluginLoader $loader, Server $server, PluginDescription $description, string $dataFolder, string $file){
|
||||||
if(!$this->initialized){
|
if(!$this->initialized){
|
||||||
$this->initialized = true;
|
$this->initialized = true;
|
||||||
$this->loader = $loader;
|
$this->loader = $loader;
|
||||||
|
@ -110,13 +110,13 @@ abstract class Tile extends Position{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $className
|
* @param string $className
|
||||||
* @param array $saveNames
|
* @param array $saveNames
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
* @throws \ReflectionException
|
* @throws \ReflectionException
|
||||||
*/
|
*/
|
||||||
public static function registerTile($className, array $saveNames = []) : bool{
|
public static function registerTile(string $className, array $saveNames = []) : bool{
|
||||||
$class = new \ReflectionClass($className);
|
$class = new \ReflectionClass($className);
|
||||||
if(is_a($className, Tile::class, true) and !$class->isAbstract()){
|
if(is_a($className, Tile::class, true) and !$class->isAbstract()){
|
||||||
$shortName = $class->getShortName();
|
$shortName = $class->getShortName();
|
||||||
|
@ -569,7 +569,7 @@ class Utils{
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public static function getReferenceCount($value, $includeCurrent = true){
|
public static function getReferenceCount($value, bool $includeCurrent = true){
|
||||||
ob_start();
|
ob_start();
|
||||||
debug_zval_dump($value);
|
debug_zval_dump($value);
|
||||||
$ret = explode("\n", ob_get_contents());
|
$ret = explode("\n", ob_get_contents());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user