populate remaining missing return types, using native returns where possible

this is done separately to stable so that stable changes can be integrated easily using an empty merge.
This commit is contained in:
Dylan K. Taylor 2020-01-19 10:26:35 +00:00
parent 3cf0b50b4a
commit 3ee6887792
17 changed files with 97 additions and 85 deletions

View File

@ -1744,7 +1744,7 @@ class Server{
exit(1);
}
public function __debugInfo(){
public function __debugInfo() : array{
return [];
}

View File

@ -136,7 +136,7 @@ class Chest extends Spawnable implements Container, Nameable{
return $this->inventory;
}
protected function checkPairing(){
protected function checkPairing() : void{
if($this->isPaired() and !$this->pos->getWorld()->isInLoadedTerrain(new Vector3($this->pairX, $this->pos->y, $this->pairZ))){
//paired to a tile in an unloaded chunk
$this->doubleInventory = null;
@ -170,7 +170,7 @@ class Chest extends Spawnable implements Container, Nameable{
return "Chest";
}
public function isPaired(){
public function isPaired() : bool{
return $this->pairX !== null and $this->pairZ !== null;
}
@ -188,7 +188,7 @@ class Chest extends Spawnable implements Container, Nameable{
return null;
}
public function pairWith(Chest $tile){
public function pairWith(Chest $tile) : bool{
if($this->isPaired() or $tile->isPaired()){
return false;
}
@ -202,7 +202,7 @@ class Chest extends Spawnable implements Container, Nameable{
return true;
}
private function createPair(Chest $tile){
private function createPair(Chest $tile) : void{
$this->pairX = $tile->getPos()->x;
$this->pairZ = $tile->getPos()->z;
@ -210,7 +210,7 @@ class Chest extends Spawnable implements Container, Nameable{
$tile->pairZ = $this->getPos()->z;
}
public function unpair(){
public function unpair() : bool{
if(!$this->isPaired()){
return false;
}

View File

@ -120,7 +120,7 @@ class Furnace extends Spawnable implements Container, Nameable{
return $this->getInventory();
}
protected function checkFuel(Item $fuel){
protected function checkFuel(Item $fuel) : void{
$ev = new FurnaceBurnEvent($this, $fuel, $fuel->getFuelTime());
$ev->call();
if($ev->isCancelled()){

View File

@ -72,7 +72,7 @@ class PluginCommand extends Command implements PluginIdentifiableCommand{
/**
* @param CommandExecutor $executor
*/
public function setExecutor(CommandExecutor $executor){
public function setExecutor(CommandExecutor $executor) : void{
$this->executor = $executor;
}

View File

@ -38,7 +38,7 @@ final class CreativeInventory{
//NOOP
}
public static function init(){
public static function init() : void{
self::clear();
$creativeItems = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "vanilla" . DIRECTORY_SEPARATOR . "creativeitems.json"), true);
@ -56,7 +56,7 @@ final class CreativeInventory{
* Removes all previously added items from the creative menu.
* Note: Players who are already online when this is called will not see this change.
*/
public static function clear(){
public static function clear() : void{
self::$creative = [];
}
@ -92,7 +92,7 @@ final class CreativeInventory{
*
* @param Item $item
*/
public static function add(Item $item){
public static function add(Item $item) : void{
self::$creative[] = clone $item;
}
@ -102,7 +102,7 @@ final class CreativeInventory{
*
* @param Item $item
*/
public static function remove(Item $item){
public static function remove(Item $item) : void{
$index = self::getItemIndex($item);
if($index !== -1){
unset(self::$creative[$index]);

View File

@ -140,7 +140,7 @@ class Language{
return $baseText;
}
public function translate(TextContainer $c){
public function translate(TextContainer $c) : string{
if($c instanceof TranslationContainer){
$baseText = $this->internalGet($c->getText());
$baseText = $this->parseTranslation($baseText ?? $c->getText());

View File

@ -104,7 +104,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
*/
abstract protected function encodePayload() : void;
public function __debugInfo(){
public function __debugInfo() : array{
$data = [];
foreach((array) $this as $k => $v){
if($v === $this->getBuffer()){
@ -121,6 +121,8 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
/**
* @param string $name
*
* @return mixed
*/
public function __get($name){
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
@ -130,7 +132,7 @@ abstract class DataPacket extends NetworkBinaryStream implements Packet{
* @param string $name
* @param mixed $value
*/
public function __set($name, $value){
public function __set($name, $value) : void{
throw new \Error("Undefined property: " . get_class($this) . "::\$" . $name);
}
}

View File

@ -43,7 +43,7 @@ abstract class DefaultPermissions{
return PermissionManager::getInstance()->getPermission($perm->getName());
}
public static function registerCorePermissions(){
public static function registerCorePermissions() : void{
$parent = self::registerPermission(new Permission(self::ROOT, "Allows using all PocketMine commands and utilities"));
$broadcasts = self::registerPermission(new Permission(self::ROOT . ".broadcast", "Allows the user to receive all broadcast messages"), $parent);

View File

@ -54,7 +54,7 @@ class OfflinePlayer implements IPlayer{
return $this->name;
}
public function getServer(){
public function getServer() : Server{
return $this->server;
}

View File

@ -464,7 +464,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->lastPlayed - $this->firstPlayed > 1; // microtime(true) - microtime(true) may have less than one millisecond difference
}
public function setAllowFlight(bool $value){
public function setAllowFlight(bool $value) : void{
$this->allowFlight = $value;
$this->networkSession->syncAdventureSettings($this);
}
@ -473,7 +473,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->allowFlight;
}
public function setFlying(bool $value){
public function setFlying(bool $value) : void{
if($this->flying !== $value){
$this->flying = $value;
$this->resetFallDistance();
@ -485,7 +485,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->flying;
}
public function setAutoJump(bool $value){
public function setAutoJump(bool $value) : void{
$this->autoJump = $value;
$this->networkSession->syncAdventureSettings($this);
}
@ -520,7 +520,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param bool $remove
*/
public function setRemoveFormat(bool $remove = true){
public function setRemoveFormat(bool $remove = true) : void{
$this->removeFormat = $remove;
}
@ -547,7 +547,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param Player $player
*/
public function hidePlayer(Player $player){
public function hidePlayer(Player $player) : void{
if($player === $this){
return;
}
@ -558,7 +558,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param Player $player
*/
public function showPlayer(Player $player){
public function showPlayer(Player $player) : void{
if($player === $this){
return;
}
@ -585,7 +585,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->viewDistance;
}
public function setViewDistance(int $distance){
public function setViewDistance(int $distance) : void{
$this->viewDistance = $this->server->getAllowedViewDistance($distance);
$this->spawnThreshold = (int) (min($this->viewDistance, $this->server->getProperty("chunk-sending.spawn-radius", 4)) ** 2 * M_PI);
@ -685,7 +685,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param string $name
*/
public function setDisplayName(string $name){
public function setDisplayName(string $name) : void{
$this->displayName = $name;
}
@ -738,7 +738,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->startAction > -1;
}
public function setUsingItem(bool $value){
public function setUsingItem(bool $value) : void{
$this->startAction = $value ? $this->server->getTick() : -1;
}
@ -805,7 +805,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return false;
}
protected function unloadChunk(int $x, int $z, ?World $world = null){
protected function unloadChunk(int $x, int $z, ?World $world = null) : void{
$world = $world ?? $this->getWorld();
$index = World::chunkHash($x, $z);
if(isset($this->usedChunks[$index])){
@ -830,7 +830,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
}
protected function requestChunks(){
protected function requestChunks() : void{
if(!$this->isConnected()){
return;
}
@ -883,7 +883,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
Timings::$playerChunkSendTimer->stopTiming();
}
public function doFirstSpawn(){
public function doFirstSpawn() : void{
if($this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
PermissionManager::getInstance()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS, $this);
}
@ -986,7 +986,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return isset($this->usedChunks[World::chunkHash($chunkX, $chunkZ)]);
}
public function doChunkRequests(){
public function doChunkRequests() : void{
if($this->nextChunkOrderRun !== PHP_INT_MAX and $this->nextChunkOrderRun-- <= 0){
$this->nextChunkOrderRun = PHP_INT_MAX;
$this->orderChunks();
@ -1023,7 +1023,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @param Vector3|Position $pos
*/
public function setSpawn(Vector3 $pos){
public function setSpawn(Vector3 $pos) : void{
if(!($pos instanceof Position)){
$world = $this->getWorld();
}else{
@ -1068,7 +1068,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return true;
}
public function stopSleep(){
public function stopSleep() : void{
if($this->sleeping instanceof Vector3){
$b = $this->getWorld()->getBlock($this->sleeping);
if($b instanceof Bed){
@ -1218,7 +1218,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return false; //currently has no server-side movement
}
protected function checkNearEntities(){
protected function checkNearEntities() : void{
foreach($this->getWorld()->getNearbyEntities($this->boundingBox->expandedCopy(1, 0.5, 1), $this) as $entity){
$entity->scheduleUpdate();
@ -1274,7 +1274,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->inAirTicks;
}
protected function processMovement(int $tickDiff){
protected function processMovement(int $tickDiff) : void{
if($this->newPosition === null or $this->isSleeping()){
return;
}
@ -1923,14 +1923,14 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* Removes the title from the client's screen.
*/
public function removeTitles(){
public function removeTitles() : void{
$this->networkSession->onClearTitle();
}
/**
* Resets the title duration settings to defaults and removes any existing titles.
*/
public function resetTitles(){
public function resetTitles() : void{
$this->networkSession->onResetTitleOptions();
}
@ -1941,7 +1941,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* @param int $stay Title stay time in ticks.
* @param int $fadeOut Title fade-out time in ticks.
*/
public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut){
public function setTitleDuration(int $fadeIn, int $stay, int $fadeOut) : void{
if($fadeIn >= 0 and $stay >= 0 and $fadeOut >= 0){
$this->networkSession->onTitleDuration($fadeIn, $stay, $fadeOut);
}
@ -1968,7 +1968,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* @param string $message
* @param string[] $parameters
*/
public function sendTranslation(string $message, array $parameters = []){
public function sendTranslation(string $message, array $parameters = []) : void{
if(!$this->server->isLanguageForced()){
foreach($parameters as $i => $p){
$parameters[$i] = $this->server->getLanguage()->translateString($p, [], "pocketmine.");
@ -1986,11 +1986,11 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @param string $message
*/
public function sendPopup(string $message){
public function sendPopup(string $message) : void{
$this->networkSession->onPopup($message);
}
public function sendTip(string $message){
public function sendTip(string $message) : void{
$this->networkSession->onTip($message);
}
@ -2160,7 +2160,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
parent::destroyCycles();
}
public function __debugInfo(){
public function __debugInfo() : array{
return [];
}
@ -2182,7 +2182,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @throws \InvalidStateException if the player is closed
*/
public function save(){
public function save() : void{
if($this->closed){
throw new \InvalidStateException("Tried to save closed player");
}
@ -2353,7 +2353,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
* @param float|null $pitch
* @param int $mode
*/
public function sendPosition(Vector3 $pos, ?float $yaw = null, ?float $pitch = null, int $mode = MovePlayerPacket::MODE_NORMAL){
public function sendPosition(Vector3 $pos, ?float $yaw = null, ?float $pitch = null, int $mode = MovePlayerPacket::MODE_NORMAL) : void{
$this->networkSession->syncMovement($pos, $yaw, $pitch, $mode);
//TODO: get rid of this
@ -2390,7 +2390,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return false;
}
protected function addDefaultWindows(){
protected function addDefaultWindows() : void{
$this->cursorInventory = new PlayerCursorInventory($this);
$this->craftingGrid = new CraftingGrid($this, CraftingGrid::SIZE_SMALL);

View File

@ -100,6 +100,8 @@ abstract class PluginBase implements Plugin, CommandExecutor{
/**
* Called when the plugin is loaded, before calling onEnable()
*
* @return void
*/
protected function onLoad()/* : void /* TODO: uncomment this for next major version */{
@ -107,6 +109,8 @@ abstract class PluginBase implements Plugin, CommandExecutor{
/**
* Called when the plugin is enabled
*
* @return void
*/
protected function onEnable()/* : void /* TODO: uncomment this for next major version */{
@ -115,6 +119,8 @@ abstract class PluginBase implements Plugin, CommandExecutor{
/**
* Called when the plugin is disabled
* Use this to free open things and finish actions
*
* @return void
*/
protected function onDisable()/* : void /* TODO: uncomment this for next major version */{
@ -320,7 +326,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
return $this->config;
}
public function saveConfig(){
public function saveConfig() : void{
$this->getConfig()->save();
}
@ -331,7 +337,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
return false;
}
public function reloadConfig(){
public function reloadConfig() : void{
$this->saveDefaultConfig();
$this->config = new Config($this->configFile);
}

View File

@ -72,6 +72,8 @@ abstract class Task{
/**
* Actions to execute if the Task is cancelled
*
* @return void
*/
public function onCancel(){

View File

@ -35,7 +35,7 @@ trait CommonThreadPartsTrait{
/** @var bool */
protected $isKilled = false;
public function getClassLoader(){
public function getClassLoader() : ?\ClassLoader{
return $this->classLoader;
}

View File

@ -319,7 +319,7 @@ class Config{
* @param string $k
* @param mixed $v
*/
public function __set($k, $v){
public function __set($k, $v) : void{
$this->set($k, $v);
}

View File

@ -151,6 +151,8 @@ class MainLogger extends \AttachableThreadedLogger{
/**
* @param \Throwable $e
* @param array|null $trace
*
* @return void
*/
public function logException(\Throwable $e, $trace = null){
if($trace === null){

View File

@ -386,7 +386,7 @@ class World implements ChunkManager{
$this->server->getAsyncPool()->submitTaskToWorker(new GeneratorRegisterTask($this, $this->generator, $this->provider->getWorldData()->getGeneratorOptions()), $worker);
}
public function unregisterGenerator(){
public function unregisterGenerator() : void{
$pool = $this->server->getAsyncPool();
foreach($pool->getRunningWorkers() as $i){
if(isset($this->generatorRegisteredWorkers[$i])){
@ -422,7 +422,7 @@ class World implements ChunkManager{
/**
* @internal
*/
public function close(){
public function close() : void{
if($this->closed){
throw new \InvalidStateException("Tried to close a world which is already closed");
}
@ -443,7 +443,7 @@ class World implements ChunkManager{
$this->closed = true;
}
public function addSound(Vector3 $pos, Sound $sound, ?array $players = null){
public function addSound(Vector3 $pos, Sound $sound, ?array $players = null) : void{
$pk = $sound->encode($pos);
if(!is_array($pk)){
$pk = [$pk];
@ -459,7 +459,7 @@ class World implements ChunkManager{
}
}
public function addParticle(Vector3 $pos, Particle $particle, ?array $players = null){
public function addParticle(Vector3 $pos, Particle $particle, ?array $players = null) : void{
$pk = $particle->encode($pos);
if(!is_array($pk)){
$pk = [$pk];
@ -482,7 +482,7 @@ class World implements ChunkManager{
* @param int $evid
* @param int $data
*/
public function broadcastLevelEvent(?Vector3 $pos, int $evid, int $data = 0){
public function broadcastLevelEvent(?Vector3 $pos, int $evid, int $data = 0) : void{
$pk = LevelEventPacket::create($evid, $data, $pos);
if($pos !== null){
$this->broadcastPacketToViewers($pos, $pk);
@ -495,7 +495,7 @@ class World implements ChunkManager{
return $this->autoSave;
}
public function setAutoSave(bool $value){
public function setAutoSave(bool $value) : void{
$this->autoSave = $value;
}
@ -544,7 +544,7 @@ class World implements ChunkManager{
* @param int $chunkZ
* @param ClientboundPacket $packet
*/
public function addChunkPacket(int $chunkX, int $chunkZ, ClientboundPacket $packet){
public function addChunkPacket(int $chunkX, int $chunkZ, ClientboundPacket $packet) : void{
if(!isset($this->chunkPackets[$index = World::chunkHash($chunkX, $chunkZ)])){
$this->chunkPackets[$index] = [$packet];
}else{
@ -571,7 +571,7 @@ class World implements ChunkManager{
$this->globalPackets[] = $packet;
}
public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){
public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true) : void{
$loaderId = spl_object_id($loader);
if(!isset($this->chunkLoaders[$chunkHash = World::chunkHash($chunkX, $chunkZ)])){
@ -600,7 +600,7 @@ class World implements ChunkManager{
}
}
public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){
public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ) : void{
$chunkHash = World::chunkHash($chunkX, $chunkZ);
$loaderId = spl_object_id($loader);
if(isset($this->chunkLoaders[$chunkHash][$loaderId])){
@ -689,7 +689,7 @@ class World implements ChunkManager{
*
* @param Player ...$targets If empty, will send to all players in the world.
*/
public function sendTime(Player ...$targets){
public function sendTime(Player ...$targets) : void{
$pk = SetTimePacket::create($this->time);
if(empty($targets)){
@ -709,7 +709,7 @@ class World implements ChunkManager{
* @param int $currentTick
*
*/
public function doTick(int $currentTick){
public function doTick(int $currentTick) : void{
if($this->closed){
throw new \InvalidStateException("Attempted to tick a world which has been closed");
}
@ -852,7 +852,7 @@ class World implements ChunkManager{
$this->chunkPackets = [];
}
public function checkSleep(){
public function checkSleep() : void{
if(count($this->players) === 0){
return;
}
@ -886,7 +886,7 @@ class World implements ChunkManager{
* @param Player[] $target
* @param Vector3[] $blocks
*/
public function sendBlocks(array $target, array $blocks){
public function sendBlocks(array $target, array $blocks) : void{
$packets = [];
foreach($blocks as $b){
@ -906,7 +906,7 @@ class World implements ChunkManager{
$this->server->broadcastPackets($target, $packets);
}
public function clearCache(bool $force = false){
public function clearCache(bool $force = false) : void{
if($force){
$this->blockCache = [];
}else{
@ -928,18 +928,18 @@ class World implements ChunkManager{
return $this->randomTickBlocks;
}
public function addRandomTickedBlock(Block $block){
public function addRandomTickedBlock(Block $block) : void{
if($block instanceof UnknownBlock){
throw new \InvalidArgumentException("Cannot do random-tick on unknown block");
}
$this->randomTickBlocks[$block->getFullId()] = true;
}
public function removeRandomTickedBlock(Block $block){
public function removeRandomTickedBlock(Block $block) : void{
unset($this->randomTickBlocks[$block->getFullId()]);
}
private function tickChunks(){
private function tickChunks() : void{
if($this->chunksPerTick <= 0 or count($this->loaders) === 0){
return;
}
@ -1029,7 +1029,7 @@ class World implements ChunkManager{
return true;
}
public function saveChunks(){
public function saveChunks() : void{
$this->timings->syncChunkSaveTimer->startTiming();
try{
foreach($this->chunks as $chunk){
@ -1050,7 +1050,7 @@ class World implements ChunkManager{
* @param Vector3 $pos
* @param int $delay
*/
public function scheduleDelayedBlockUpdate(Vector3 $pos, int $delay){
public function scheduleDelayedBlockUpdate(Vector3 $pos, int $delay) : void{
if(
!$this->isInWorld($pos->x, $pos->y, $pos->z) or
(isset($this->scheduledBlockUpdateQueueIndex[$index = World::blockHash($pos->x, $pos->y, $pos->z)]) and $this->scheduledBlockUpdateQueueIndex[$index] <= $delay)
@ -1994,7 +1994,7 @@ class World implements ChunkManager{
* @param int $z
* @param int $biomeId
*/
public function setBiomeId(int $x, int $z, int $biomeId){
public function setBiomeId(int $x, int $z, int $biomeId) : void{
$this->getChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId);
}
@ -2076,7 +2076,7 @@ class World implements ChunkManager{
return isset($this->chunkLock[World::chunkHash($chunkX, $chunkZ)]);
}
public function generateChunkCallback(int $x, int $z, ?Chunk $chunk){
public function generateChunkCallback(int $x, int $z, ?Chunk $chunk) : void{
Timings::$generationCallbackTimer->startTiming();
if(isset($this->chunkPopulationQueue[$index = World::chunkHash($x, $z)])){
for($xx = -1; $xx <= 1; ++$xx){
@ -2234,7 +2234,7 @@ class World implements ChunkManager{
*
* @param Vector3 $pos
*/
public function setSpawnLocation(Vector3 $pos){
public function setSpawnLocation(Vector3 $pos) : void{
$previousSpawn = $this->getSpawnLocation();
$this->provider->getWorldData()->setSpawn($pos);
(new SpawnChangeEvent($this, $previousSpawn))->call();
@ -2245,7 +2245,7 @@ class World implements ChunkManager{
*
* @throws \InvalidArgumentException
*/
public function addEntity(Entity $entity){
public function addEntity(Entity $entity) : void{
if($entity->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Entity to world");
}
@ -2266,7 +2266,7 @@ class World implements ChunkManager{
*
* @throws \InvalidArgumentException
*/
public function removeEntity(Entity $entity){
public function removeEntity(Entity $entity) : void{
if($entity->getWorld() !== $this){
throw new \InvalidArgumentException("Invalid Entity world");
}
@ -2285,7 +2285,7 @@ class World implements ChunkManager{
*
* @throws \InvalidArgumentException
*/
public function addTile(Tile $tile){
public function addTile(Tile $tile) : void{
if($tile->isClosed()){
throw new \InvalidArgumentException("Attempted to add a garbage closed Tile to world");
}
@ -2312,7 +2312,7 @@ class World implements ChunkManager{
*
* @throws \InvalidArgumentException
*/
public function removeTile(Tile $tile){
public function removeTile(Tile $tile) : void{
$pos = $tile->getPos();
if($pos->getWorld() !== $this){
throw new \InvalidArgumentException("Invalid Tile world");
@ -2404,11 +2404,11 @@ class World implements ChunkManager{
return true;
}
private function queueUnloadChunk(int $x, int $z){
private function queueUnloadChunk(int $x, int $z) : void{
$this->unloadQueue[World::chunkHash($x, $z)] = microtime(true);
}
public function unloadChunkRequest(int $x, int $z, bool $safe = true){
public function unloadChunkRequest(int $x, int $z, bool $safe = true) : bool{
if(($safe and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){
return false;
}
@ -2418,7 +2418,7 @@ class World implements ChunkManager{
return true;
}
public function cancelUnloadChunkRequest(int $x, int $z){
public function cancelUnloadChunkRequest(int $x, int $z) : void{
unset($this->unloadQueue[World::chunkHash($x, $z)]);
}
@ -2574,7 +2574,7 @@ class World implements ChunkManager{
*
* @param int $time
*/
public function setTime(int $time){
public function setTime(int $time) : void{
$this->time = $time;
$this->sendTime();
}
@ -2582,7 +2582,7 @@ class World implements ChunkManager{
/**
* Stops the time for the world, will not save the lock state to disk
*/
public function stopTime(){
public function stopTime() : void{
$this->stopTime = true;
$this->sendTime();
}
@ -2590,7 +2590,7 @@ class World implements ChunkManager{
/**
* Start the time again, if it was stopped
*/
public function startTime(){
public function startTime() : void{
$this->stopTime = false;
$this->sendTime();
}
@ -2618,7 +2618,7 @@ class World implements ChunkManager{
/**
* @param int $difficulty
*/
public function setDifficulty(int $difficulty){
public function setDifficulty(int $difficulty) : void{
if($difficulty < 0 or $difficulty > 3){
throw new \InvalidArgumentException("Invalid difficulty level $difficulty");
}
@ -2630,7 +2630,7 @@ class World implements ChunkManager{
/**
* @param Player ...$targets
*/
public function sendDifficulty(Player ...$targets){
public function sendDifficulty(Player ...$targets) : void{
$pk = SetDifficultyPacket::create($this->getDifficulty());
if(empty($targets)){
$this->broadcastGlobalPacket($pk);
@ -2676,7 +2676,7 @@ class World implements ChunkManager{
return true;
}
public function doChunkGarbageCollection(){
public function doChunkGarbageCollection() : void{
$this->timings->doChunkGC->startTiming();
foreach($this->chunks as $index => $chunk){
@ -2694,7 +2694,7 @@ class World implements ChunkManager{
$this->timings->doChunkGC->stopTiming();
}
public function unloadChunks(bool $force = false){
public function unloadChunks(bool $force = false) : void{
if(count($this->unloadQueue) > 0){
$maxUnload = 96;
$now = microtime(true);

View File

@ -111,7 +111,7 @@ class SubChunk implements SubChunkInterface{
$this->blockLight = $data;
}
public function __debugInfo(){
public function __debugInfo() : array{
return [];
}