More nullable and void typehints

This commit is contained in:
Dylan K. Taylor 2019-03-02 10:29:11 +00:00
parent 1f5c901f29
commit 6c8fa8ae28
108 changed files with 392 additions and 384 deletions

View File

@ -118,7 +118,7 @@ class CrashDump{
return $this->path;
}
public function getEncodedData(){
public function getEncodedData() : string{
return $this->encodedData;
}
@ -126,7 +126,7 @@ class CrashDump{
return $this->data;
}
private function encodeData(){
private function encodeData() : void{
$this->addLine();
$this->addLine("----------------------REPORT THE DATA BELOW THIS LINE-----------------------");
$this->addLine();
@ -142,7 +142,7 @@ class CrashDump{
$this->addLine("===END CRASH DUMP===");
}
private function pluginsData(){
private function pluginsData() : void{
if($this->server->getPluginManager() instanceof PluginManager){
$this->addLine();
$this->addLine("Loaded plugins:");
@ -166,7 +166,7 @@ class CrashDump{
}
}
private function extraData(){
private function extraData() : void{
global $argv;
if($this->server->getProperty("auto-report.send-settings", true) !== false){
@ -192,7 +192,7 @@ class CrashDump{
}
}
private function baseCrash(){
private function baseCrash() : void{
global $lastExceptionError, $lastError;
if(isset($lastExceptionError)){
@ -287,7 +287,7 @@ class CrashDump{
return false;
}
private function generalData(){
private function generalData() : void{
$version = new VersionString(\pocketmine\BASE_VERSION, \pocketmine\IS_DEVELOPMENT_BUILD, \pocketmine\BUILD_NUMBER);
$this->data["general"] = [];
$this->data["general"]["name"] = $this->server->getName();
@ -310,11 +310,11 @@ class CrashDump{
$this->addLine("OS : " . PHP_OS . ", " . Utils::getOS());
}
public function addLine($line = ""){
public function addLine($line = "") : void{
fwrite($this->fp, $line . PHP_EOL);
}
public function add($str){
public function add($str) : void{
fwrite($this->fp, $str);
}
}

View File

@ -45,7 +45,7 @@ interface IPlayer extends ServerOperator{
/**
* @param bool $banned
*/
public function setBanned(bool $banned);
public function setBanned(bool $banned) : void;
/**
* @return bool
@ -55,22 +55,22 @@ interface IPlayer extends ServerOperator{
/**
* @param bool $value
*/
public function setWhitelisted(bool $value);
public function setWhitelisted(bool $value) : void;
/**
* @return Player|null
*/
public function getPlayer();
public function getPlayer() : ?Player;
/**
* @return int|null
*/
public function getFirstPlayed();
public function getFirstPlayed() : ?int;
/**
* @return int|null
*/
public function getLastPlayed();
public function getLastPlayed() : ?int;
/**
* @return bool

View File

@ -115,7 +115,7 @@ class MemoryManager{
$this->init();
}
private function init(){
private function init() : void{
$this->memoryLimit = ((int) $this->server->getProperty("memory.main-limit", 0)) * 1024 * 1024;
$defaultMemory = 1024;
@ -202,7 +202,7 @@ class MemoryManager{
* @param bool $global
* @param int $triggerCount
*/
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0){
public function trigger(int $memory, int $limit, bool $global = false, int $triggerCount = 0) : void{
$this->server->getLogger()->debug(sprintf("[Memory Manager] %sLow memory triggered, limit %gMB, using %gMB",
$global ? "Global " : "", round(($limit / 1024) / 1024, 2), round(($memory / 1024) / 1024, 2)));
if($this->lowMemClearWorldCache){
@ -231,7 +231,7 @@ class MemoryManager{
/**
* Called every tick to update the memory manager state.
*/
public function check(){
public function check() : void{
Timings::$memoryManagerTimer->startTiming();
if(($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate){
@ -298,7 +298,7 @@ class MemoryManager{
* @param int $maxNesting
* @param int $maxStringSize
*/
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize){
public function dumpServerMemory(string $outputFolder, int $maxNesting, int $maxStringSize) : void{
$this->server->getLogger()->notice("[Dump] After the memory dump is done, the server might crash");
self::dumpMemory($this->server, $outputFolder, $maxNesting, $maxStringSize, $this->server->getLogger());
@ -321,7 +321,7 @@ class MemoryManager{
*
* @throws \ReflectionException
*/
public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger){
public static function dumpMemory($startingObject, string $outputFolder, int $maxNesting, int $maxStringSize, \Logger $logger) : void{
$hardLimit = ini_get('memory_limit');
ini_set('memory_limit', '-1');
gc_disable();
@ -479,7 +479,7 @@ class MemoryManager{
* @param int $maxNesting
* @param int $maxStringSize
*/
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize){
private static function continueDump($from, &$data, array &$objects, array &$refCounts, int $recursion, int $maxNesting, int $maxStringSize) : void{
if($maxNesting <= 0){
$data = "(error) NESTING LIMIT REACHED";
return;

View File

@ -64,7 +64,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server->isOp($this->name);
}
public function setOp(bool $value){
public function setOp(bool $value) : void{
if($value === $this->isOp()){
return;
}
@ -80,8 +80,8 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server->getNameBans()->isBanned($this->name);
}
public function setBanned(bool $value){
if($value){
public function setBanned(bool $banned) : void{
if($banned){
$this->server->getNameBans()->addBan($this->name, null, null, null);
}else{
$this->server->getNameBans()->remove($this->name);
@ -92,7 +92,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server->isWhitelisted($this->name);
}
public function setWhitelisted(bool $value){
public function setWhitelisted(bool $value) : void{
if($value){
$this->server->addWhitelist($this->name);
}else{
@ -100,15 +100,15 @@ class OfflinePlayer implements IPlayer, Metadatable{
}
}
public function getPlayer(){
public function getPlayer() : ?Player{
return $this->server->getPlayerExact($this->name);
}
public function getFirstPlayed(){
public function getFirstPlayed() : ?int{
return ($this->namedtag !== null and $this->namedtag->hasTag("firstPlayed", LongTag::class)) ? $this->namedtag->getInt("firstPlayed") : null;
}
public function getLastPlayed(){
public function getLastPlayed() : ?int{
return ($this->namedtag !== null and $this->namedtag->hasTag("lastPlayed", LongTag::class)) ? $this->namedtag->getLong("lastPlayed") : null;
}
@ -116,7 +116,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->namedtag !== null;
}
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
@ -128,7 +128,7 @@ class OfflinePlayer implements IPlayer, Metadatable{
return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}
}

View File

@ -325,8 +325,8 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->server->getNameBans()->isBanned($this->username);
}
public function setBanned(bool $value){
if($value){
public function setBanned(bool $banned) : void{
if($banned){
$this->server->getNameBans()->addBan($this->getName(), null, null, null);
$this->kick("You have been banned");
}else{
@ -338,7 +338,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->server->isWhitelisted($this->username);
}
public function setWhitelisted(bool $value){
public function setWhitelisted(bool $value) : void{
if($value){
$this->server->addWhitelist($this->username);
}else{
@ -381,15 +381,23 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return parent::getUniqueId();
}
public function getPlayer(){
public function getPlayer() : ?Player{
return $this;
}
public function getFirstPlayed(){
/**
* TODO: not sure this should be nullable
* @return int|null
*/
public function getFirstPlayed() : ?int{
return $this->firstPlayed;
}
public function getLastPlayed(){
/**
* TODO: not sure this should be nullable
* @return int|null
*/
public function getLastPlayed() : ?int{
return $this->lastPlayed;
}
@ -447,7 +455,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @return Server
*/
public function getServer(){
public function getServer() : Server{
return $this->server;
}
@ -469,7 +477,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->lineHeight ?? 7;
}
public function setScreenLineHeight(?int $height){
public function setScreenLineHeight(?int $height) : void{
if($height !== null and $height < 1){
throw new \InvalidArgumentException("Line height must be at least 1");
}
@ -557,7 +565,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param bool $value
*/
public function setOp(bool $value){
public function setOp(bool $value) : void{
if($value === $this->isOp()){
return;
}
@ -608,11 +616,11 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
/**
* @param PermissionAttachment $attachment
*/
public function removeAttachment(PermissionAttachment $attachment){
public function removeAttachment(PermissionAttachment $attachment) : void{
$this->perm->removeAttachment($attachment);
}
public function recalculatePermissions(){
public function recalculatePermissions() : void{
$permManager = PermissionManager::getInstance();
$permManager->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
$permManager->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this);
@ -2678,7 +2686,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @param TextContainer|string $message
*/
public function sendMessage($message){
public function sendMessage($message) : void{
if($message instanceof TextContainer){
if($message instanceof TranslationContainer){
$this->sendTranslation($message->getText(), $message->getParameters());
@ -3215,7 +3223,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
*
* @return Inventory|null
*/
public function getWindow(int $windowId){
public function getWindow(int $windowId) : ?Inventory{
return $this->windowIndex[$windowId] ?? null;
}
@ -3309,7 +3317,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
}
}
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
@ -3321,30 +3329,30 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}
public function onChunkChanged(Chunk $chunk){
public function onChunkChanged(Chunk $chunk) : void{
if(isset($this->usedChunks[$hash = Level::chunkHash($chunk->getX(), $chunk->getZ())])){
$this->usedChunks[$hash] = false;
$this->nextChunkOrderRun = 0;
}
}
public function onChunkLoaded(Chunk $chunk){
public function onChunkLoaded(Chunk $chunk) : void{
}
public function onChunkPopulated(Chunk $chunk){
public function onChunkPopulated(Chunk $chunk) : void{
}
public function onChunkUnloaded(Chunk $chunk){
public function onChunkUnloaded(Chunk $chunk) : void{
}
public function onBlockChanged(Vector3 $block){
public function onBlockChanged(Vector3 $block) : void{
}
}

View File

@ -668,7 +668,7 @@ class Server{
* @param string $name
* @param CompoundTag $nbtTag
*/
public function saveOfflinePlayerData(string $name, CompoundTag $nbtTag){
public function saveOfflinePlayerData(string $name, CompoundTag $nbtTag) : void{
$ev = new PlayerDataSaveEvent($nbtTag, $name);
$ev->setCancelled(!$this->shouldSavePlayerData());
@ -690,7 +690,7 @@ class Server{
*
* @return Player|null
*/
public function getPlayer(string $name){
public function getPlayer(string $name) : ?Player{
$found = null;
$name = strtolower($name);
$delta = PHP_INT_MAX;
@ -715,7 +715,7 @@ class Server{
*
* @return Player|null
*/
public function getPlayerExact(string $name){
public function getPlayerExact(string $name) : ?Player{
$name = strtolower($name);
foreach($this->getOnlinePlayers() as $player){
if($player->getLowerCaseName() === $name){
@ -806,7 +806,7 @@ class Server{
* @param string $variable
* @param string $value
*/
public function setConfigString(string $variable, string $value){
public function setConfigString(string $variable, string $value) : void{
$this->properties->set($variable, $value);
}
@ -829,7 +829,7 @@ class Server{
* @param string $variable
* @param int $value
*/
public function setConfigInt(string $variable, int $value){
public function setConfigInt(string $variable, int $value) : void{
$this->properties->set($variable, $value);
}
@ -865,7 +865,7 @@ class Server{
* @param string $variable
* @param bool $value
*/
public function setConfigBool(string $variable, bool $value){
public function setConfigBool(string $variable, bool $value) : void{
$this->properties->set($variable, $value ? "1" : "0");
}
@ -899,7 +899,7 @@ class Server{
/**
* @param string $name
*/
public function addOp(string $name){
public function addOp(string $name) : void{
$this->operators->set(strtolower($name), true);
if(($player = $this->getPlayerExact($name)) !== null){
@ -911,7 +911,7 @@ class Server{
/**
* @param string $name
*/
public function removeOp(string $name){
public function removeOp(string $name) : void{
$this->operators->remove(strtolower($name));
if(($player = $this->getPlayerExact($name)) !== null){
@ -923,7 +923,7 @@ class Server{
/**
* @param string $name
*/
public function addWhitelist(string $name){
public function addWhitelist(string $name) : void{
$this->whitelist->set(strtolower($name), true);
$this->whitelist->save();
}
@ -931,7 +931,7 @@ class Server{
/**
* @param string $name
*/
public function removeWhitelist(string $name){
public function removeWhitelist(string $name) : void{
$this->whitelist->remove(strtolower($name));
$this->whitelist->save();
}
@ -968,7 +968,7 @@ class Server{
return $this->operators;
}
public function reloadWhitelist(){
public function reloadWhitelist() : void{
$this->whitelist->reload();
}
@ -1533,7 +1533,7 @@ class Server{
/**
* @param int $type
*/
public function enablePlugins(int $type){
public function enablePlugins(int $type) : void{
foreach($this->pluginManager->getPlugins() as $plugin){
if(!$plugin->isEnabled() and $plugin->getDescription()->getOrder() === $type){
$this->pluginManager->enablePlugin($plugin);
@ -1576,7 +1576,7 @@ class Server{
return false;
}
public function reload(){
public function reload() : void{
$this->logger->info("Saving worlds...");
foreach($this->levelManager->getLevels() as $level){
@ -1616,11 +1616,11 @@ class Server{
/**
* Shuts the server down correctly
*/
public function shutdown(){
public function shutdown() : void{
$this->isRunning = false;
}
public function forceShutdown(){
public function forceShutdown() : void{
if($this->hasStopped){
return;
}
@ -1703,7 +1703,7 @@ class Server{
/**
* Starts the PocketMine-MP server and starts processing ticks and packets
*/
private function start(){
private function start() : void{
if($this->getConfigBool("enable-query", true)){
$this->queryHandler = new QueryHandler();
}
@ -1741,7 +1741,7 @@ class Server{
* @param \Throwable $e
* @param array|null $trace
*/
public function exceptionHandler(\Throwable $e, $trace = null){
public function exceptionHandler(\Throwable $e, $trace = null) : void{
global $lastError;
if($trace === null){
@ -1772,7 +1772,7 @@ class Server{
$this->crashDump();
}
public function crashDump(){
public function crashDump() : void{
if(!$this->isRunning){
return;
}
@ -1860,7 +1860,7 @@ class Server{
return $this->tickSleeper;
}
private function tickProcessor(){
private function tickProcessor() : void{
$this->nextTick = microtime(true);
while($this->isRunning){
@ -1871,7 +1871,7 @@ class Server{
}
}
public function onPlayerLogin(Player $player){
public function onPlayerLogin(Player $player) : void{
if($this->sendUsageTicker > 0){
$this->uniquePlayers[$player->getRawUniqueId()] = $player->getRawUniqueId();
}
@ -1879,28 +1879,28 @@ class Server{
$this->loggedInPlayers[$player->getRawUniqueId()] = $player;
}
public function onPlayerLogout(Player $player){
public function onPlayerLogout(Player $player) : void{
unset($this->loggedInPlayers[$player->getRawUniqueId()]);
}
public function addPlayer(Player $player){
public function addPlayer(Player $player) : void{
$this->players[spl_object_id($player)] = $player;
}
/**
* @param Player $player
*/
public function removePlayer(Player $player){
public function removePlayer(Player $player) : void{
unset($this->players[spl_object_id($player)]);
}
public function addOnlinePlayer(Player $player){
public function addOnlinePlayer(Player $player) : void{
$this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkin(), $player->getXuid());
$this->playerList[$player->getRawUniqueId()] = $player;
}
public function removeOnlinePlayer(Player $player){
public function removeOnlinePlayer(Player $player) : void{
if(isset($this->playerList[$player->getRawUniqueId()])){
unset($this->playerList[$player->getRawUniqueId()]);
@ -1916,7 +1916,7 @@ class Server{
* @param string $xboxUserId
* @param Player[]|null $players
*/
public function updatePlayerListData(UUID $uuid, int $entityId, string $name, Skin $skin, string $xboxUserId = "", ?array $players = null){
public function updatePlayerListData(UUID $uuid, int $entityId, string $name, Skin $skin, string $xboxUserId = "", ?array $players = null) : void{
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
@ -1929,7 +1929,7 @@ class Server{
* @param UUID $uuid
* @param Player[]|null $players
*/
public function removePlayerListData(UUID $uuid, ?array $players = null){
public function removePlayerListData(UUID $uuid, ?array $players = null) : void{
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_REMOVE;
$pk->entries[] = PlayerListEntry::createRemovalEntry($uuid);
@ -1939,7 +1939,7 @@ class Server{
/**
* @param Player $p
*/
public function sendFullPlayerListData(Player $p){
public function sendFullPlayerListData(Player $p) : void{
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
foreach($this->playerList as $player){
@ -1949,7 +1949,7 @@ class Server{
$p->sendDataPacket($pk);
}
public function sendUsage($type = SendUsageTask::TYPE_STATUS){
public function sendUsage(int $type = SendUsageTask::TYPE_STATUS) : void{
if((bool) $this->getProperty("anonymous-statistics.enabled", true)){
$this->asyncPool->submitTask(new SendUsageTask($this, $type, $this->uniquePlayers));
}
@ -1985,7 +1985,7 @@ class Server{
return $this->memoryManager;
}
private function titleTick(){
private function titleTick() : void{
Timings::$titleTickTimer->startTiming();
$d = Utils::getRealMemoryUsage();
@ -2016,7 +2016,7 @@ class Server{
*
* TODO: move this to Network
*/
public function handlePacket(AdvancedNetworkInterface $interface, string $address, int $port, string $payload){
public function handlePacket(AdvancedNetworkInterface $interface, string $address, int $port, string $payload) : void{
if($this->queryHandler === null or !$this->queryHandler->handle($interface, $address, $port, $payload)){
$this->logger->debug("Unhandled raw packet from $address $port: " . bin2hex($payload));
}

View File

@ -39,7 +39,7 @@ abstract class Thread extends \Thread{
return $this->classLoader;
}
public function setClassLoader(?\ClassLoader $loader = null){
public function setClassLoader(?\ClassLoader $loader = null) : void{
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
if($loader === null){
@ -55,7 +55,7 @@ abstract class Thread extends \Thread{
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
public function registerClassLoader() : void{
if($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
@ -64,7 +64,7 @@ abstract class Thread extends \Thread{
}
}
public function start(?int $options = \PTHREADS_INHERIT_ALL){
public function start(?int $options = \PTHREADS_INHERIT_ALL) : bool{
ThreadManager::getInstance()->add($this);
if($this->getClassLoader() === null){
@ -76,7 +76,7 @@ abstract class Thread extends \Thread{
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
public function quit() : void{
$this->isKilled = true;
if(!$this->isJoined()){

View File

@ -30,21 +30,21 @@ class ThreadManager extends \Volatile{
/** @var ThreadManager */
private static $instance = null;
public static function init(){
public static function init() : void{
self::$instance = new ThreadManager();
}
/**
* @return ThreadManager
*/
public static function getInstance(){
public static function getInstance() : ThreadManager{
return self::$instance;
}
/**
* @param Worker|Thread $thread
*/
public function add($thread){
public function add($thread) : void{
if($thread instanceof Thread or $thread instanceof Worker){
$this->{spl_object_id($thread)} = $thread;
}
@ -53,7 +53,7 @@ class ThreadManager extends \Volatile{
/**
* @param Worker|Thread $thread
*/
public function remove($thread){
public function remove($thread) : void{
if($thread instanceof Thread or $thread instanceof Worker){
unset($this->{spl_object_id($thread)});
}

View File

@ -39,7 +39,7 @@ abstract class Worker extends \Worker{
return $this->classLoader;
}
public function setClassLoader(?\ClassLoader $loader = null){
public function setClassLoader(?\ClassLoader $loader = null) : void{
$this->composerAutoloaderPath = \pocketmine\COMPOSER_AUTOLOADER_PATH;
if($loader === null){
@ -55,7 +55,7 @@ abstract class Worker extends \Worker{
* If you do not do this, you will not be able to use new classes that were not loaded when the thread was started
* (unless you are using a custom autoloader).
*/
public function registerClassLoader(){
public function registerClassLoader() : void{
if($this->composerAutoloaderPath !== null){
require $this->composerAutoloaderPath;
}
@ -64,7 +64,7 @@ abstract class Worker extends \Worker{
}
}
public function start(?int $options = \PTHREADS_INHERIT_ALL){
public function start(?int $options = \PTHREADS_INHERIT_ALL) : bool{
ThreadManager::getInstance()->add($this);
if($this->getClassLoader() === null){
@ -76,7 +76,7 @@ abstract class Worker extends \Worker{
/**
* Stops the thread using the best way possible. Try to stop it yourself before calling this.
*/
public function quit(){
public function quit() : void{
$this->isKilled = true;
if($this->isRunning()){

View File

@ -109,7 +109,7 @@ class Bed extends Transparent{
return $this->occupied;
}
public function setOccupied(bool $occupied = true){
public function setOccupied(bool $occupied = true) : void{
$this->occupied = $occupied;
$this->level->setBlock($this, $this, false);

View File

@ -800,7 +800,7 @@ class Block extends Position implements BlockIds, Metadatable{
return $currentHit;
}
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
if($this->isValid()){
$this->level->getBlockMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
@ -822,7 +822,7 @@ class Block extends Position implements BlockIds, Metadatable{
return false;
}
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
if($this->isValid()){
$this->level->getBlockMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}

View File

@ -52,7 +52,7 @@ class Lava extends Liquid{
return 2; //TODO: this is 1 in the nether
}
protected function checkForHarden(){
protected function checkForHarden() : void{
$colliding = null;
foreach(Facing::ALL as $side){
if($side === Facing::DOWN){

View File

@ -471,7 +471,7 @@ abstract class Liquid extends Transparent{
return ($decay >= 0 && $blockDecay >= $decay) ? $decay : $blockDecay;
}
protected function checkForHarden(){
protected function checkForHarden() : void{
}

View File

@ -66,7 +66,7 @@ class TNT extends Solid{
}
}
public function ignite(int $fuse = 80){
public function ignite(int $fuse = 80) : void{
$this->getLevel()->setBlock($this, BlockFactory::get(Block::AIR));
$mot = (new Random())->nextSignedFloat() * M_PI * 2;

View File

@ -107,7 +107,7 @@ abstract class Command{
/**
* @return string|null
*/
public function getPermission(){
public function getPermission() : ?string{
return $this->permission;
}
@ -115,7 +115,7 @@ abstract class Command{
/**
* @param string|null $permission
*/
public function setPermission(?string $permission){
public function setPermission(?string $permission) : void{
$this->permission = $permission;
}
@ -260,7 +260,7 @@ abstract class Command{
/**
* @param string[] $aliases
*/
public function setAliases(array $aliases){
public function setAliases(array $aliases) : void{
$this->aliases = $aliases;
if(!$this->isRegistered()){
$this->activeAliases = $aliases;
@ -270,21 +270,21 @@ abstract class Command{
/**
* @param string $description
*/
public function setDescription(string $description){
public function setDescription(string $description) : void{
$this->description = $description;
}
/**
* @param string $permissionMessage
*/
public function setPermissionMessage(string $permissionMessage){
public function setPermissionMessage(string $permissionMessage) : void{
$this->permissionMessage = $permissionMessage;
}
/**
* @param string $usage
*/
public function setUsage(string $usage){
public function setUsage(string $usage) : void{
$this->usageMessage = $usage;
}
@ -293,7 +293,7 @@ abstract class Command{
* @param TextContainer|string $message
* @param bool $sendToSource
*/
public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true){
public static function broadcastCommandMessage(CommandSender $source, $message, bool $sendToSource = true) : void{
if($message instanceof TextContainer){
$m = clone $message;
$result = "[" . $source->getName() . ": " . ($source->getServer()->getLanguage()->get($m->getText()) !== $m->getText() ? "%" : "") . $m->getText() . "]";

View File

@ -30,7 +30,7 @@ interface CommandMap{
* @param string $fallbackPrefix
* @param Command[] $commands
*/
public function registerAll(string $fallbackPrefix, array $commands);
public function registerAll(string $fallbackPrefix, array $commands) : void;
/**
* @param string $fallbackPrefix
@ -52,14 +52,14 @@ interface CommandMap{
/**
* @return void
*/
public function clearCommands();
public function clearCommands() : void;
/**
* @param string $name
*
* @return Command|null
*/
public function getCommand(string $name);
public function getCommand(string $name) : ?Command;
}

View File

@ -71,11 +71,11 @@ class CommandReader extends Thread{
}
}
public function shutdown(){
public function shutdown() : void{
$this->shutdown = true;
}
public function quit(){
public function quit() : void{
$wait = microtime(true) + 0.5;
while(microtime(true) < $wait){
if($this->isRunning()){
@ -94,7 +94,7 @@ class CommandReader extends Thread{
throw new \ThreadException($message);
}
private function initStdin(){
private function initStdin() : void{
if(is_resource(self::$stdin)){
fclose(self::$stdin);
}
@ -176,7 +176,7 @@ class CommandReader extends Thread{
*
* @return string|null
*/
public function getLine(){
public function getLine() : ?string{
if($this->buffer->count() !== 0){
return (string) $this->buffer->shift();
}
@ -184,7 +184,7 @@ class CommandReader extends Thread{
return null;
}
public function run(){
public function run() : void{
$this->registerClassLoader();
if($this->type !== self::TYPE_READLINE){

View File

@ -32,12 +32,12 @@ interface CommandSender extends Permissible{
/**
* @param TextContainer|string $message
*/
public function sendMessage($message);
public function sendMessage($message) : void;
/**
* @return Server
*/
public function getServer();
public function getServer() : Server;
/**
* @return string
@ -57,5 +57,5 @@ interface CommandSender extends Permissible{
*
* @param int|null $height
*/
public function setScreenLineHeight(?int $height);
public function setScreenLineHeight(?int $height) : void;
}

View File

@ -80,11 +80,11 @@ class ConsoleCommandSender implements CommandSender{
*
* @return void
*/
public function removeAttachment(PermissionAttachment $attachment){
public function removeAttachment(PermissionAttachment $attachment) : void{
$this->perm->removeAttachment($attachment);
}
public function recalculatePermissions(){
public function recalculatePermissions() : void{
$this->perm->recalculatePermissions();
}
@ -98,14 +98,14 @@ class ConsoleCommandSender implements CommandSender{
/**
* @return Server
*/
public function getServer(){
public function getServer() : Server{
return Server::getInstance();
}
/**
* @param TextContainer|string $message
*/
public function sendMessage($message){
public function sendMessage($message) : void{
if($message instanceof TextContainer){
$message = $this->getServer()->getLanguage()->translate($message);
}else{
@ -134,7 +134,7 @@ class ConsoleCommandSender implements CommandSender{
/**
* @param bool $value
*/
public function setOp(bool $value){
public function setOp(bool $value) : void{
}
@ -142,7 +142,7 @@ class ConsoleCommandSender implements CommandSender{
return $this->lineHeight ?? PHP_INT_MAX;
}
public function setScreenLineHeight(?int $height){
public function setScreenLineHeight(?int $height) : void{
if($height !== null and $height < 1){
throw new \InvalidArgumentException("Line height must be at least 1");
}

View File

@ -92,7 +92,7 @@ class SimpleCommandMap implements CommandMap{
$this->setDefaultCommands();
}
private function setDefaultCommands(){
private function setDefaultCommands() : void{
$this->registerAll("pocketmine", [
new BanCommand("ban"),
new BanIpCommand("ban-ip"),
@ -138,7 +138,7 @@ class SimpleCommandMap implements CommandMap{
}
public function registerAll(string $fallbackPrefix, array $commands){
public function registerAll(string $fallbackPrefix, array $commands) : void{
foreach($commands as $command){
$this->register($fallbackPrefix, $command);
}
@ -231,7 +231,7 @@ class SimpleCommandMap implements CommandMap{
*
* @return Command|null
*/
public function matchCommand(string &$commandName, array &$args){
public function matchCommand(string &$commandName, array &$args) : ?Command{
$count = min(count($args), 255);
for($i = 0; $i < $count; ++$i){
@ -277,7 +277,7 @@ class SimpleCommandMap implements CommandMap{
return true;
}
public function clearCommands(){
public function clearCommands() : void{
foreach($this->knownCommands as $command){
$command->unregister($this);
}
@ -285,7 +285,7 @@ class SimpleCommandMap implements CommandMap{
$this->setDefaultCommands();
}
public function getCommand(string $name){
public function getCommand(string $name) : ?Command{
return $this->knownCommands[$name] ?? null;
}
@ -300,7 +300,7 @@ class SimpleCommandMap implements CommandMap{
/**
* @return void
*/
public function registerServerAliases(){
public function registerServerAliases() : void{
$values = $this->server->getCommandAliases();
foreach($values as $alias => $commandStrings){

View File

@ -76,7 +76,7 @@ class BanIpCommand extends VanillaCommand{
return true;
}
private function processIPBan(string $ip, CommandSender $sender, string $reason){
private function processIPBan(string $ip, CommandSender $sender, string $reason) : void{
$sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
foreach($sender->getServer()->getOnlinePlayers() as $player){

View File

@ -141,7 +141,7 @@ class ParticleCommand extends VanillaCommand{
*
* @return Particle|null
*/
private function getParticle(string $name, ?int $data = null){
private function getParticle(string $name, ?int $data = null) : ?Particle{
switch($name){
case "explode":
return new ExplodeParticle();

View File

@ -84,7 +84,7 @@ class VersionCommand extends VanillaCommand{
return true;
}
private function describeToSender(Plugin $plugin, CommandSender $sender){
private function describeToSender(Plugin $plugin, CommandSender $sender) : void{
$desc = $plugin->getDescription();
$sender->sendMessage(TextFormat::DARK_GREEN . $desc->getName() . TextFormat::WHITE . " version " . TextFormat::DARK_GREEN . $desc->getVersion());

View File

@ -1982,7 +1982,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->close();
}
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->server->getEntityMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
@ -1994,7 +1994,7 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
return $this->server->getEntityMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
$this->server->getEntityMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}

View File

@ -26,5 +26,5 @@ namespace pocketmine\entity;
interface Explosive{
public function explode();
public function explode() : void;
}

View File

@ -36,5 +36,5 @@ interface Cancellable{
/**
* @param bool $value
*/
public function setCancelled(bool $value = true);
public function setCancelled(bool $value = true) : void;
}

View File

@ -88,7 +88,7 @@ class PlayerCreationEvent extends Event{
/**
* @param Player::class $class
*/
public function setBaseClass($class){
public function setBaseClass($class) : void{
if(!is_a($class, $this->baseClass, true)){
throw new \RuntimeException("Base class $class must extend " . $this->baseClass);
}
@ -106,7 +106,7 @@ class PlayerCreationEvent extends Event{
/**
* @param Player::class $class
*/
public function setPlayerClass($class){
public function setPlayerClass($class) : void{
if(!is_a($class, $this->baseClass, true)){
throw new \RuntimeException("Class $class must extend " . $this->baseClass);
}

View File

@ -72,7 +72,7 @@ abstract class BaseInventory implements Inventory{
*
* @param int $size
*/
public function setSize(int $size){
public function setSize(int $size) : void{
$this->slots->setSize($size);
}

View File

@ -61,7 +61,7 @@ class CraftingGrid extends BaseInventory{
return $this->getGridWidth() ** 2;
}
public function setSize(int $size){
public function setSize(int $size) : void{
throw new \BadMethodCallException("Cannot change the size of a crafting grid");
}

View File

@ -137,7 +137,7 @@ class CraftingManager{
*
* @return int
*/
public static function sort(Item $i1, Item $i2){
public static function sort(Item $i1, Item $i2) : int{
//Use spaceship operator to compare each property, then try the next one if they are equivalent.
($retval = $i1->getId() <=> $i2->getId()) === 0 && ($retval = $i1->getMeta() <=> $i2->getMeta()) === 0 && ($retval = $i1->getCount() <=> $i2->getCount());

View File

@ -50,7 +50,7 @@ class EnderChestInventory extends ChestInventory{
*
* @param EnderChest $enderChest
*/
public function setHolderPosition(EnderChest $enderChest){
public function setHolderPosition(EnderChest $enderChest) : void{
$this->holder->setComponents($enderChest->getFloorX(), $enderChest->getFloorY(), $enderChest->getFloorZ());
$this->holder->setLevel($enderChest->getLevel());
}

View File

@ -45,7 +45,7 @@ class FurnaceRecipe{
/**
* @param Item $item
*/
public function setInput(Item $item){
public function setInput(Item $item) : void{
$this->ingredient = clone $item;
}

View File

@ -38,7 +38,7 @@ class PlayerCursorInventory extends BaseInventory{
return 1;
}
public function setSize(int $size){
public function setSize(int $size) : void{
throw new \BadMethodCallException("Cursor can only carry one item at a time");
}

View File

@ -61,7 +61,7 @@ class PlayerInventory extends BaseInventory{
*
* @throws \InvalidArgumentException
*/
private function throwIfNotHotbarSlot(int $slot){
private function throwIfNotHotbarSlot(int $slot) : void{
if(!$this->isHotbarSlot($slot)){
throw new \InvalidArgumentException("$slot is not a valid hotbar slot index (expected 0 - " . ($this->getHotbarSize() - 1) . ")");
}
@ -98,7 +98,7 @@ class PlayerInventory extends BaseInventory{
*
* @throws \InvalidArgumentException if the hotbar slot is out of range
*/
public function setHeldItemIndex(int $hotbarSlot, bool $send = true){
public function setHeldItemIndex(int $hotbarSlot, bool $send = true) : void{
$this->throwIfNotHotbarSlot($hotbarSlot);
$this->itemInHandIndex = $hotbarSlot;
@ -140,7 +140,7 @@ class PlayerInventory extends BaseInventory{
*
* @param Player|Player[] $target
*/
public function sendHeldItem($target){
public function sendHeldItem($target) : void{
$item = $this->getItemInHand();
$pk = new MobEquipmentPacket();
@ -170,7 +170,7 @@ class PlayerInventory extends BaseInventory{
return 9;
}
public function sendCreativeContents(){
public function sendCreativeContents() : void{
//TODO: this mess shouldn't be in here
$holder = $this->getHolder();
if(!($holder instanceof Player)){

View File

@ -49,7 +49,7 @@ class ChorusFruit extends Food{
return false;
}
public function onConsume(Living $consumer){
public function onConsume(Living $consumer) : void{
$level = $consumer->getLevel();
assert($level !== null);

View File

@ -50,5 +50,5 @@ interface Consumable{
*
* @param Living $consumer
*/
public function onConsume(Living $consumer);
public function onConsume(Living $consumer) : void;
}

View File

@ -50,7 +50,7 @@ abstract class Durable extends Item{
*
* @param bool $value
*/
public function setUnbreakable(bool $value = true){
public function setUnbreakable(bool $value = true) : void{
$this->setNamedTagEntry(new ByteTag("Unbreakable", $value ? 1 : 0));
}

View File

@ -41,7 +41,7 @@ abstract class Food extends Item implements FoodSource{
return [];
}
public function onConsume(Living $consumer){
public function onConsume(Living $consumer) : void{
}
}

View File

@ -163,7 +163,7 @@ class Item implements ItemIds, \JsonSerializable{
*
* @return Item|null
*/
public static function getCreativeItem(int $index){
public static function getCreativeItem(int $index) : ?Item{
return Item::$creative[$index] ?? null;
}

View File

@ -50,7 +50,7 @@ class ItemFactory{
/** @var Item|null */
private static $air = null;
public static function init(){
public static function init() : void{
self::$list = []; //in case of re-initializing
self::register(new Apple());
@ -328,7 +328,7 @@ class ItemFactory{
* @throws \RuntimeException if something attempted to override an already-registered item without specifying the
* $override parameter.
*/
public static function register(Item $item, bool $override = false){
public static function register(Item $item, bool $override = false) : void{
$id = $item->getId();
$variant = $item->getMeta();

View File

@ -39,7 +39,7 @@ class MilkBucket extends Item implements Consumable{
return [];
}
public function onConsume(Living $consumer){
public function onConsume(Living $consumer) : void{
$consumer->removeAllEffects();
}
}

View File

@ -263,7 +263,7 @@ class Potion extends Item implements Consumable{
return 1;
}
public function onConsume(Living $consumer){
public function onConsume(Living $consumer) : void{
}

View File

@ -160,7 +160,7 @@ class Language{
*
* @return string|null
*/
protected function internalGet(string $id){
protected function internalGet(string $id) : ?string{
return $this->lang[$id] ?? $this->fallbackLang[$id] ?? null;
}

View File

@ -38,7 +38,7 @@ class TextContainer{
/**
* @param string $text
*/
public function setText(string $text){
public function setText(string $text) : void{
$this->text = $text;
}

View File

@ -52,7 +52,7 @@ class TranslationContainer extends TextContainer{
*
* @return string|null
*/
public function getParameter(int $i){
public function getParameter(int $i) : ?string{
return $this->params[$i] ?? null;
}
@ -60,7 +60,7 @@ class TranslationContainer extends TextContainer{
* @param int $i
* @param string $str
*/
public function setParameter(int $i, string $str){
public function setParameter(int $i, string $str) : void{
if($i < 0 or $i > count($this->params)){ //Intended, allow to set the last
throw new \InvalidArgumentException("Invalid index $i, have " . count($this->params));
}
@ -71,7 +71,7 @@ class TranslationContainer extends TextContainer{
/**
* @param string[] $params
*/
public function setParameters(array $params){
public function setParameters(array $params) : void{
$i = 0;
foreach($params as $str){
$this->params[$i] = (string) $str;

View File

@ -46,14 +46,14 @@ interface ChunkListener{
*
* @param Chunk $chunk
*/
public function onChunkChanged(Chunk $chunk);
public function onChunkChanged(Chunk $chunk) : void;
/**
* This method will be called when a registered chunk is loaded
*
* @param Chunk $chunk
*/
public function onChunkLoaded(Chunk $chunk);
public function onChunkLoaded(Chunk $chunk) : void;
/**
@ -61,7 +61,7 @@ interface ChunkListener{
*
* @param Chunk $chunk
*/
public function onChunkUnloaded(Chunk $chunk);
public function onChunkUnloaded(Chunk $chunk) : void;
/**
* This method will be called when a registered chunk is populated
@ -69,12 +69,12 @@ interface ChunkListener{
*
* @param Chunk $chunk
*/
public function onChunkPopulated(Chunk $chunk);
public function onChunkPopulated(Chunk $chunk) : void;
/**
* This method will be called when a block changes in a registered chunk
*
* @param Block|Vector3 $block
*/
public function onBlockChanged(Vector3 $block);
public function onBlockChanged(Vector3 $block) : void;
}

View File

@ -70,7 +70,7 @@ interface ChunkManager{
* @param int $z
* @param int $level
*/
public function setBlockLightAt(int $x, int $y, int $z, int $level);
public function setBlockLightAt(int $x, int $y, int $z, int $level) : void;
/**
* Returns the highest amount of sky light can reach the specified coordinates.
@ -91,7 +91,7 @@ interface ChunkManager{
* @param int $z
* @param int $level
*/
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level);
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level) : void;
/**
* @param int $chunkX
@ -99,14 +99,14 @@ interface ChunkManager{
*
* @return Chunk|null
*/
public function getChunk(int $chunkX, int $chunkZ);
public function getChunk(int $chunkX, int $chunkZ) : ?Chunk;
/**
* @param int $chunkX
* @param int $chunkZ
* @param Chunk|null $chunk
*/
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk);
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk) : void;
/**
* Returns the height of the world

View File

@ -1639,7 +1639,7 @@ class Level implements ChunkManager, Metadatable{
*
* @return ItemEntity|null
*/
public function dropItem(Vector3 $source, Item $item, ?Vector3 $motion = null, int $delay = 10){
public function dropItem(Vector3 $source, Item $item, ?Vector3 $motion = null, int $delay = 10) : ?ItemEntity{
$motion = $motion ?? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1);
$itemTag = $item->nbtSerialize();
$itemTag->setName("Item");
@ -1920,7 +1920,7 @@ class Level implements ChunkManager, Metadatable{
*
* @return Entity|null
*/
public function getEntity(int $entityId){
public function getEntity(int $entityId) : ?Entity{
return $this->entities[$entityId] ?? null;
}
@ -2123,7 +2123,7 @@ class Level implements ChunkManager, Metadatable{
* @param int $z
* @param int $level 0-15
*/
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level) : void{
$this->getChunk($x >> 4, $z >> 4, true)->setBlockSkyLight($x & 0x0f, $y, $z & 0x0f, $level & 0x0f);
}
@ -2148,7 +2148,7 @@ class Level implements ChunkManager, Metadatable{
* @param int $z
* @param int $level 0-15
*/
public function setBlockLightAt(int $x, int $y, int $z, int $level){
public function setBlockLightAt(int $x, int $y, int $z, int $level) : void{
$this->getChunk($x >> 4, $z >> 4, true)->setBlockLight($x & 0x0f, $y, $z & 0x0f, $level & 0x0f);
}
@ -2211,16 +2211,16 @@ class Level implements ChunkManager, Metadatable{
* Returns the chunk at the specified X/Z coordinates. If the chunk is not loaded, attempts to (synchronously!!!)
* load it.
*
* @param int $x
* @param int $z
* @param int $chunkX
* @param int $chunkZ
* @param bool $create Whether to create an empty chunk as a placeholder if the chunk does not exist
*
* @return Chunk|null
*/
public function getChunk(int $x, int $z, bool $create = false){
if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){
public function getChunk(int $chunkX, int $chunkZ, bool $create = false) : ?Chunk{
if(isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)])){
return $this->chunks[$index];
}elseif($this->loadChunk($x, $z, $create)){
}elseif($this->loadChunk($chunkX, $chunkZ, $create)){
return $this->chunks[$index];
}
@ -2316,7 +2316,7 @@ class Level implements ChunkManager, Metadatable{
* @param Chunk|null $chunk
* @param bool $deleteEntitiesAndTiles Whether to delete entities and tiles on the old chunk, or transfer them to the new one
*/
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk, bool $deleteEntitiesAndTiles = true){
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk, bool $deleteEntitiesAndTiles = true) : void{
if($chunk === null){
return;
}
@ -3000,7 +3000,7 @@ class Level implements ChunkManager, Metadatable{
}
}
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->server->getLevelMetadata()->setMetadata($this, $metadataKey, $newMetadataValue);
}
@ -3012,7 +3012,7 @@ class Level implements ChunkManager, Metadatable{
return $this->server->getLevelMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata(string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void{
$this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $owningPlugin);
}
}

View File

@ -342,7 +342,7 @@ class LevelManager{
*
* @return Entity|null
*/
public function findEntity(int $entityId){
public function findEntity(int $entityId) : ?Entity{
foreach($this->levels as $level){
assert(!$level->isClosed());
if(($entity = $level->getEntity($entityId)) instanceof Entity){
@ -413,7 +413,7 @@ class LevelManager{
/**
* @param bool $value
*/
public function setAutoSave(bool $value){
public function setAutoSave(bool $value) : void{
$this->autoSave = $value;
foreach($this->levels as $level){
$level->setAutoSave($this->autoSave);

View File

@ -40,7 +40,7 @@ class Location extends Position{
* @param float $pitch
* @param Level $level
*/
public function __construct($x = 0, $y = 0, $z = 0, $yaw = 0.0, $pitch = 0.0, ?Level $level = null){
public function __construct($x = 0, $y = 0, $z = 0, float $yaw = 0.0, float $pitch = 0.0, ?Level $level = null){
$this->yaw = $yaw;
$this->pitch = $pitch;
parent::__construct($x, $y, $z, $level);
@ -49,12 +49,12 @@ class Location extends Position{
/**
* @param Vector3 $pos
* @param Level|null $level default null
* @param float $yaw default 0.0
* @param float $yaw default 0.0
* @param float $pitch default 0.0
*
* @return Location
*/
public static function fromObject(Vector3 $pos, ?Level $level = null, $yaw = 0.0, $pitch = 0.0) : Location{
public static function fromObject(Vector3 $pos, ?Level $level = null, float $yaw = 0.0, float $pitch = 0.0){
return new Location($pos->x, $pos->y, $pos->z, $yaw, $pitch, $level ?? (($pos instanceof Position) ? $pos->level : null));
}
@ -67,11 +67,11 @@ class Location extends Position{
return new Location($this->x, $this->y, $this->z, $this->yaw, $this->pitch, $this->level);
}
public function getYaw(){
public function getYaw() : float{
return $this->yaw;
}
public function getPitch(){
public function getPitch() : float{
return $this->pitch;
}

View File

@ -67,7 +67,7 @@ class SimpleChunkManager implements ChunkManager{
return 0;
}
public function setBlockLightAt(int $x, int $y, int $z, int $level){
public function setBlockLightAt(int $x, int $y, int $z, int $level) : void{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockLight($x & 0xf, $y, $z & 0xf, $level);
}
@ -81,7 +81,7 @@ class SimpleChunkManager implements ChunkManager{
return 0;
}
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){
public function setBlockSkyLightAt(int $x, int $y, int $z, int $level) : void{
if($chunk = $this->getChunk($x >> 4, $z >> 4)){
$chunk->setBlockSkyLight($x & 0xf, $y, $z & 0xf, $level);
}
@ -93,7 +93,7 @@ class SimpleChunkManager implements ChunkManager{
*
* @return Chunk|null
*/
public function getChunk(int $chunkX, int $chunkZ){
public function getChunk(int $chunkX, int $chunkZ) : ?Chunk{
return $this->chunks[Level::chunkHash($chunkX, $chunkZ)] ?? null;
}
@ -102,7 +102,7 @@ class SimpleChunkManager implements ChunkManager{
* @param int $chunkZ
* @param Chunk|null $chunk
*/
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk){
public function setChunk(int $chunkX, int $chunkZ, ?Chunk $chunk) : void{
if($chunk === null){
unset($this->chunks[Level::chunkHash($chunkX, $chunkZ)]);
return;
@ -110,7 +110,7 @@ class SimpleChunkManager implements ChunkManager{
$this->chunks[Level::chunkHash($chunkX, $chunkZ)] = $chunk;
}
public function cleanChunks(){
public function cleanChunks() : void{
$this->chunks = [];
}

View File

@ -77,12 +77,12 @@ abstract class Biome{
/** @var float */
protected $temperature = 0.5;
protected static function register(int $id, Biome $biome){
protected static function register(int $id, Biome $biome) : void{
self::$biomes[$id] = $biome;
$biome->setId($id);
}
public static function init(){
public static function init() : void{
self::$biomes = new \SplFixedArray(self::MAX_BIOMES);
self::register(self::OCEAN, new OceanBiome());
@ -114,11 +114,11 @@ abstract class Biome{
return self::$biomes[$id];
}
public function clearPopulators(){
public function clearPopulators() : void{
$this->populators = [];
}
public function addPopulator(Populator $populator){
public function addPopulator(Populator $populator) : void{
$this->populators[] = $populator;
}
@ -128,7 +128,7 @@ abstract class Biome{
* @param int $chunkZ
* @param Random $random
*/
public function populateChunk(ChunkManager $level, int $chunkX, int $chunkZ, Random $random){
public function populateChunk(ChunkManager $level, int $chunkX, int $chunkZ, Random $random) : void{
foreach($this->populators as $populator){
$populator->populate($level, $chunkX, $chunkZ, $random);
}
@ -141,7 +141,7 @@ abstract class Biome{
return $this->populators;
}
public function setId(int $id){
public function setId(int $id) : void{
if(!$this->registered){
$this->registered = true;
$this->id = $id;
@ -162,7 +162,7 @@ abstract class Biome{
return $this->maxElevation;
}
public function setElevation(int $min, int $max){
public function setElevation(int $min, int $max) : void{
$this->minElevation = $min;
$this->maxElevation = $max;
}
@ -177,7 +177,7 @@ abstract class Biome{
/**
* @param Block[] $covers
*/
public function setGroundCover(array $covers){
public function setGroundCover(array $covers) : void{
$this->groundCover = $covers;
}

View File

@ -152,14 +152,14 @@ class Chunk{
return $this->z;
}
public function setX(int $x){
public function setX(int $x) : void{
$this->x = $x;
}
/**
* @param int $z
*/
public function setZ(int $z){
public function setZ(int $z) : void{
$this->z = $z;
}
@ -251,7 +251,7 @@ class Chunk{
* @param int $z 0-15
* @param int $level 0-15
*/
public function setBlockSkyLight(int $x, int $y, int $z, int $level){
public function setBlockSkyLight(int $x, int $y, int $z, int $level) : void{
if($this->getSubChunk($y >> 4, true)->setBlockSkyLight($x, $y & 0x0f, $z, $level)){
$this->hasChanged = true;
}
@ -260,7 +260,7 @@ class Chunk{
/**
* @param int $level
*/
public function setAllBlockSkyLight(int $level){
public function setAllBlockSkyLight(int $level) : void{
$char = chr(($level & 0x0f) | ($level << 4));
$data = str_repeat($char, 2048);
for($y = $this->getHighestSubChunkIndex(); $y >= 0; --$y){
@ -289,7 +289,7 @@ class Chunk{
* @param int $z 0-15
* @param int $level 0-15
*/
public function setBlockLight(int $x, int $y, int $z, int $level){
public function setBlockLight(int $x, int $y, int $z, int $level) : void{
if($this->getSubChunk($y >> 4, true)->setBlockLight($x, $y & 0x0f, $z, $level)){
$this->hasChanged = true;
}
@ -298,7 +298,7 @@ class Chunk{
/**
* @param int $level
*/
public function setAllBlockLight(int $level){
public function setAllBlockLight(int $level) : void{
$char = chr(($level & 0x0f) | ($level << 4));
$data = str_repeat($char, 2048);
for($y = $this->getHighestSubChunkIndex(); $y >= 0; --$y){
@ -353,14 +353,14 @@ class Chunk{
* @param int $z 0-15
* @param int $value
*/
public function setHeightMap(int $x, int $z, int $value){
public function setHeightMap(int $x, int $z, int $value) : void{
$this->heightMap[($z << 4) | $x] = $value;
}
/**
* Recalculates the heightmap for the whole chunk.
*/
public function recalculateHeightMap(){
public function recalculateHeightMap() : void{
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$this->recalculateHeightMapColumn($x, $z);
@ -395,7 +395,7 @@ class Chunk{
*
* TODO: fast adjacent light spread
*/
public function populateSkyLight(){
public function populateSkyLight() : void{
$maxY = $this->getMaxY();
$this->setAllBlockSkyLight(0);
@ -441,7 +441,7 @@ class Chunk{
* @param int $z 0-15
* @param int $biomeId 0-255
*/
public function setBiomeId(int $x, int $z, int $biomeId){
public function setBiomeId(int $x, int $z, int $biomeId) : void{
$this->hasChanged = true;
$this->biomeIds{($z << 4) | $x} = chr($biomeId & 0xff);
}
@ -456,7 +456,7 @@ class Chunk{
/**
* @param bool $value
*/
public function setLightPopulated(bool $value = true){
public function setLightPopulated(bool $value = true) : void{
$this->lightPopulated = $value;
}
@ -470,7 +470,7 @@ class Chunk{
/**
* @param bool $value
*/
public function setPopulated(bool $value = true){
public function setPopulated(bool $value = true) : void{
$this->terrainPopulated = $value;
}
@ -484,14 +484,14 @@ class Chunk{
/**
* @param bool $value
*/
public function setGenerated(bool $value = true){
public function setGenerated(bool $value = true) : void{
$this->terrainGenerated = $value;
}
/**
* @param Entity $entity
*/
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 a chunk");
}
@ -504,7 +504,7 @@ class Chunk{
/**
* @param Entity $entity
*/
public function removeEntity(Entity $entity){
public function removeEntity(Entity $entity) : void{
unset($this->entities[$entity->getId()]);
if(!($entity instanceof Player) and $this->isInit){
$this->hasChanged = true;
@ -514,7 +514,7 @@ class Chunk{
/**
* @param Tile $tile
*/
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 a chunk");
}
@ -531,7 +531,7 @@ class Chunk{
/**
* @param Tile $tile
*/
public function removeTile(Tile $tile){
public function removeTile(Tile $tile) : void{
unset($this->tiles[Chunk::blockHash($tile->x, $tile->y, $tile->z)]);
if($this->isInit){
$this->hasChanged = true;
@ -570,7 +570,7 @@ class Chunk{
*
* @return Tile|null
*/
public function getTile(int $x, int $y, int $z){
public function getTile(int $x, int $y, int $z) : ?Tile{
return $this->tiles[Chunk::blockHash($x, $y, $z)] ?? null;
}
@ -595,7 +595,7 @@ class Chunk{
*
* @param Level $level
*/
public function initChunk(Level $level){
public function initChunk(Level $level) : void{
if(!$this->isInit){
$changed = false;
if($this->NBTentities !== null){
@ -665,7 +665,7 @@ class Chunk{
/**
* @param bool $value
*/
public function setChanged(bool $value = true){
public function setChanged(bool $value = true) : void{
$this->hasChanged = $value;
}

View File

@ -89,7 +89,7 @@ class EmptySubChunk implements SubChunkInterface{
return str_repeat("\x00", 2048);
}
public function setBlockLightArray(string $data){
public function setBlockLightArray(string $data) : void{
}
@ -97,7 +97,7 @@ class EmptySubChunk implements SubChunkInterface{
return str_repeat("\xff", 2048);
}
public function setBlockSkyLightArray(string $data){
public function setBlockSkyLightArray(string $data) : void{
}

View File

@ -42,7 +42,7 @@ class SubChunk implements SubChunkInterface{
protected $blockLight;
protected $skyLight;
private static function assignData(&$target, string $data, int $length, string $value = "\x00"){
private static function assignData(&$target, string $data, int $length, string $value = "\x00") : void{
if(strlen($data) !== $length){
assert($data === "", "Invalid non-zero length given, expected $length, got " . strlen($data));
$target = str_repeat($value, $length);
@ -159,7 +159,7 @@ class SubChunk implements SubChunkInterface{
return $this->skyLight;
}
public function setBlockSkyLightArray(string $data){
public function setBlockSkyLightArray(string $data) : void{
assert(strlen($data) === 2048, "Wrong length of skylight array, expecting 2048 bytes, got " . strlen($data));
$this->skyLight = $data;
}
@ -169,7 +169,7 @@ class SubChunk implements SubChunkInterface{
return $this->blockLight;
}
public function setBlockLightArray(string $data){
public function setBlockLightArray(string $data) : void{
assert(strlen($data) === 2048, "Wrong length of light array, expecting 2048 bytes, got " . strlen($data));
$this->blockLight = $data;
}

View File

@ -134,7 +134,7 @@ interface SubChunkInterface{
/**
* @param string $data
*/
public function setBlockSkyLightArray(string $data);
public function setBlockSkyLightArray(string $data) : void;
/**
* @return string
@ -144,7 +144,7 @@ interface SubChunkInterface{
/**
* @param string $data
*/
public function setBlockLightArray(string $data);
public function setBlockLightArray(string $data) : void;
/**
* @return string

View File

@ -109,7 +109,7 @@ abstract class LevelProviderManager{
*
* @return string|null
*/
public static function getProviderByName(string $name){
public static function getProviderByName(string $name) : ?string{
return self::$providers[trim(strtolower($name))] ?? null;
}
}

View File

@ -29,7 +29,7 @@ class BlockLightUpdate extends LightUpdate{
return $this->subChunkHandler->currentSubChunk->getBlockLight($x & 0x0f, $y & 0x0f, $z & 0x0f);
}
public function setLight(int $x, int $y, int $z, int $level){
public function setLight(int $x, int $y, int $z, int $level) : void{
$this->subChunkHandler->currentSubChunk->setBlockLight($x & 0x0f, $y & 0x0f, $z & 0x0f, $level);
}
}

View File

@ -59,9 +59,9 @@ abstract class LightUpdate{
abstract protected function getLight(int $x, int $y, int $z) : int;
abstract protected function setLight(int $x, int $y, int $z, int $level);
abstract protected function setLight(int $x, int $y, int $z, int $level) : void;
public function setAndUpdateLight(int $x, int $y, int $z, int $newLevel){
public function setAndUpdateLight(int $x, int $y, int $z, int $newLevel) : void{
$this->updateNodes[Level::blockHash($x, $y, $z)] = [$x, $y, $z, $newLevel];
}
@ -84,7 +84,7 @@ abstract class LightUpdate{
}
}
public function execute(){
public function execute() : void{
$this->prepareNodes();
while(!$this->removalQueue->isEmpty()){
@ -137,7 +137,7 @@ abstract class LightUpdate{
}
}
protected function computeRemoveLight(int $x, int $y, int $z, int $oldAdjacentLevel){
protected function computeRemoveLight(int $x, int $y, int $z, int $oldAdjacentLevel) : void{
$current = $this->getLight($x, $y, $z);
if($current !== 0 and $current < $oldAdjacentLevel){
@ -157,7 +157,7 @@ abstract class LightUpdate{
}
}
protected function computeSpreadLight(int $x, int $y, int $z, int $newAdjacentLevel){
protected function computeSpreadLight(int $x, int $y, int $z, int $newAdjacentLevel) : void{
$current = $this->getLight($x, $y, $z);
$potentialLight = $newAdjacentLevel - BlockFactory::$lightFilter[$this->subChunkHandler->currentSubChunk->getFullBlock($x & 0x0f, $y & 0x0f, $z & 0x0f)];

View File

@ -29,7 +29,7 @@ class SkyLightUpdate extends LightUpdate{
return $this->subChunkHandler->currentSubChunk->getBlockSkyLight($x & 0x0f, $y & 0x0f, $z & 0x0f);
}
public function setLight(int $x, int $y, int $z, int $level){
public function setLight(int $x, int $y, int $z, int $level) : void{
$this->subChunkHandler->currentSubChunk->setBlockSkyLight($x & 0x0f, $y & 0x0f, $z & 0x0f, $level);
}
}

View File

@ -50,11 +50,11 @@ class BlockMetadataStore extends MetadataStore{
return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function removeMetadata(Block $subject, string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(Block $subject, string $metadataKey, Plugin $owningPlugin) : void{
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(Block $subject, string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(Block $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}

View File

@ -40,11 +40,11 @@ class EntityMetadataStore extends MetadataStore{
return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function removeMetadata(Entity $subject, string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(Entity $subject, string $metadataKey, Plugin $owningPlugin) : void{
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(Entity $subject, string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(Entity $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}

View File

@ -41,11 +41,11 @@ class LevelMetadataStore extends MetadataStore{
return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function removeMetadata(Level $subject, string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(Level $subject, string $metadataKey, Plugin $owningPlugin) : void{
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(Level $subject, string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(Level $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}

View File

@ -38,7 +38,7 @@ abstract class MetadataStore{
* @param string $key
* @param MetadataValue $newMetadataValue
*/
protected function setMetadataInternal(string $key, MetadataValue $newMetadataValue){
protected function setMetadataInternal(string $key, MetadataValue $newMetadataValue) : void{
$owningPlugin = $newMetadataValue->getOwningPlugin();
if(!isset($this->metadataMap[$key])){
@ -83,7 +83,7 @@ abstract class MetadataStore{
* @param string $key
* @param Plugin $owningPlugin
*/
protected function removeMetadataInternal(string $key, Plugin $owningPlugin){
protected function removeMetadataInternal(string $key, Plugin $owningPlugin) : void{
if(isset($this->metadataMap[$key])){
unset($this->metadataMap[$key][$owningPlugin]);
if($this->metadataMap[$key]->count() === 0){
@ -99,7 +99,7 @@ abstract class MetadataStore{
*
* @param Plugin $owningPlugin
*/
public function invalidateAll(Plugin $owningPlugin){
public function invalidateAll(Plugin $owningPlugin) : void{
/** @var MetadataValue[] $values */
foreach($this->metadataMap as $values){
if(isset($values[$owningPlugin])){

View File

@ -36,7 +36,7 @@ abstract class MetadataValue{
/**
* @return Plugin
*/
public function getOwningPlugin(){
public function getOwningPlugin() : Plugin{
return $this->owningPlugin;
}
@ -51,5 +51,5 @@ abstract class MetadataValue{
* Invalidates this metadata item, forcing it to recompute when next
* accessed.
*/
abstract public function invalidate();
abstract public function invalidate() : void;
}

View File

@ -33,7 +33,7 @@ interface Metadatable{
* @param string $metadataKey
* @param MetadataValue $newMetadataValue
*/
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue);
public function setMetadata(string $metadataKey, MetadataValue $newMetadataValue) : void;
/**
* Returns a list of previously set metadata values from the implementing
@ -62,6 +62,6 @@ interface Metadatable{
* @param string $metadataKey
* @param Plugin $owningPlugin
*/
public function removeMetadata(string $metadataKey, Plugin $owningPlugin);
public function removeMetadata(string $metadataKey, Plugin $owningPlugin) : void;
}

View File

@ -41,11 +41,11 @@ class PlayerMetadataStore extends MetadataStore{
return $this->hasMetadataInternal($this->disambiguate($subject, $metadataKey));
}
public function removeMetadata(IPlayer $subject, string $metadataKey, Plugin $owningPlugin){
public function removeMetadata(IPlayer $subject, string $metadataKey, Plugin $owningPlugin) : void{
$this->removeMetadataInternal($this->disambiguate($subject, $metadataKey), $owningPlugin);
}
public function setMetadata(IPlayer $subject, string $metadataKey, MetadataValue $newMetadataValue){
public function setMetadata(IPlayer $subject, string $metadataKey, MetadataValue $newMetadataValue) : void{
$this->setMetadataInternal($this->disambiguate($subject, $metadataKey), $newMetadataValue);
}
}

View File

@ -66,7 +66,7 @@ class BanEntry{
*
* @throws \InvalidArgumentException
*/
public function setCreated(\DateTime $date){
public function setCreated(\DateTime $date) : void{
self::validateDate($date);
$this->creationDate = $date;
}
@ -75,14 +75,14 @@ class BanEntry{
return $this->source;
}
public function setSource(string $source){
public function setSource(string $source) : void{
$this->source = $source;
}
/**
* @return \DateTime|null
*/
public function getExpires(){
public function getExpires() : ?\DateTime{
return $this->expirationDate;
}
@ -90,7 +90,7 @@ class BanEntry{
* @param \DateTime|null $date
* @throws \InvalidArgumentException
*/
public function setExpires(?\DateTime $date){
public function setExpires(?\DateTime $date) : void{
if($date !== null){
self::validateDate($date);
}
@ -108,7 +108,7 @@ class BanEntry{
return $this->reason;
}
public function setReason(string $reason){
public function setReason(string $reason) : void{
$this->reason = $reason;
}

View File

@ -62,7 +62,7 @@ class BanList{
/**
* @param bool $flag
*/
public function setEnabled(bool $flag){
public function setEnabled(bool $flag) : void{
$this->enabled = $flag;
}
@ -105,7 +105,7 @@ class BanList{
/**
* @param BanEntry $entry
*/
public function add(BanEntry $entry){
public function add(BanEntry $entry) : void{
$this->list[$entry->getName()] = $entry;
$this->save();
}
@ -133,7 +133,7 @@ class BanList{
/**
* @param string $name
*/
public function remove(string $name){
public function remove(string $name) : void{
$name = strtolower($name);
if(isset($this->list[$name])){
unset($this->list[$name]);
@ -141,7 +141,7 @@ class BanList{
}
}
public function removeExpired(){
public function removeExpired() : void{
foreach($this->list as $name => $entry){
if($entry->hasExpired()){
unset($this->list[$name]);
@ -149,7 +149,7 @@ class BanList{
}
}
public function load(){
public function load() : void{
$this->list = [];
$fp = @fopen($this->file, "r");
if(is_resource($fp)){
@ -176,7 +176,7 @@ class BanList{
/**
* @param bool $writeHeader
*/
public function save(bool $writeHeader = true){
public function save(bool $writeHeader = true) : void{
$this->removeExpired();
$fp = @fopen($this->file, "w");
if(is_resource($fp)){

View File

@ -45,7 +45,7 @@ abstract class DefaultPermissions{
return PermissionManager::getInstance()->getPermission($perm->getName());
}
public static function registerCorePermissions(){
public static function registerCorePermissions() : void{
$manager = PermissionManager::getInstance();
foreach(PermissionParser::loadPermissions(yaml_parse(file_get_contents(\pocketmine\RESOURCE_PATH . 'default_permissions.yml'))) as $permission){
$manager->addPermission($permission);

View File

@ -59,13 +59,13 @@ interface Permissible extends ServerOperator{
*
* @return void
*/
public function removeAttachment(PermissionAttachment $attachment);
public function removeAttachment(PermissionAttachment $attachment) : void;
/**
* @return void
*/
public function recalculatePermissions();
public function recalculatePermissions() : void;
/**
* @return PermissionAttachmentInfo[]

View File

@ -65,7 +65,7 @@ class PermissibleBase implements Permissible{
/**
* @param bool $value
*/
public function setOp(bool $value){
public function setOp(bool $value) : void{
$this->opable->setOp($value);
}
@ -130,7 +130,7 @@ class PermissibleBase implements Permissible{
/**
* @param PermissionAttachment $attachment
*/
public function removeAttachment(PermissionAttachment $attachment){
public function removeAttachment(PermissionAttachment $attachment) : void{
if(isset($this->attachments[spl_object_id($attachment)])){
unset($this->attachments[spl_object_id($attachment)]);
if(($ex = $attachment->getRemovalCallback()) !== null){
@ -143,7 +143,7 @@ class PermissibleBase implements Permissible{
}
public function recalculatePermissions(){
public function recalculatePermissions() : void{
Timings::$permissibleCalculationTimer->startTiming();
$this->clearPermissions();
@ -165,7 +165,7 @@ class PermissibleBase implements Permissible{
Timings::$permissibleCalculationTimer->stopTiming();
}
public function clearPermissions(){
public function clearPermissions() : void{
$permManager = PermissionManager::getInstance();
$permManager->unsubscribeFromAllPermissions($this->parent ?? $this);
@ -180,7 +180,7 @@ class PermissibleBase implements Permissible{
* @param bool $invert
* @param PermissionAttachment|null $attachment
*/
private function calculateChildPermissions(array $children, bool $invert, ?PermissionAttachment $attachment){
private function calculateChildPermissions(array $children, bool $invert, ?PermissionAttachment $attachment) : void{
$permManager = PermissionManager::getInstance();
foreach($children as $name => $v){
$perm = $permManager->getPermission($name);

View File

@ -93,7 +93,7 @@ class Permission{
/**
* @param string $value
*/
public function setDefault(string $value){
public function setDefault(string $value) : void{
if($value !== $this->defaultValue){
$this->defaultValue = $value;
$this->recalculatePermissibles();
@ -110,7 +110,7 @@ class Permission{
/**
* @param string $value
*/
public function setDescription(string $value){
public function setDescription(string $value) : void{
$this->description = $value;
}
@ -121,7 +121,7 @@ class Permission{
return PermissionManager::getInstance()->getPermissionSubscriptions($this->name);
}
public function recalculatePermissibles(){
public function recalculatePermissibles() : void{
$perms = $this->getPermissibles();
PermissionManager::getInstance()->recalculatePermissionDefaults($this);
@ -138,7 +138,7 @@ class Permission{
*
* @return Permission|null Permission if $name is a string, null if it's a Permission
*/
public function addParent($name, bool $value){
public function addParent($name, bool $value) : ?Permission{
if($name instanceof Permission){
$name->getChildren()[$this->getName()] = $value;
$name->recalculatePermissibles();

View File

@ -66,14 +66,14 @@ class PermissionAttachment{
/**
* @param PermissionRemovedExecutor $ex
*/
public function setRemovalCallback(PermissionRemovedExecutor $ex){
public function setRemovalCallback(PermissionRemovedExecutor $ex) : void{
$this->removed = $ex;
}
/**
* @return PermissionRemovedExecutor|null
*/
public function getRemovalCallback(){
public function getRemovalCallback() : ?PermissionRemovedExecutor{
return $this->removed;
}
@ -91,7 +91,7 @@ class PermissionAttachment{
return $this->permissions;
}
public function clearPermissions(){
public function clearPermissions() : void{
$this->permissions = [];
$this->permissible->recalculatePermissions();
}
@ -99,7 +99,7 @@ class PermissionAttachment{
/**
* @param bool[] $permissions
*/
public function setPermissions(array $permissions){
public function setPermissions(array $permissions) : void{
foreach($permissions as $key => $value){
$this->permissions[$key] = (bool) $value;
}
@ -109,7 +109,7 @@ class PermissionAttachment{
/**
* @param string[] $permissions
*/
public function unsetPermissions(array $permissions){
public function unsetPermissions(array $permissions) : void{
foreach($permissions as $node){
unset($this->permissions[$node]);
}
@ -120,7 +120,7 @@ class PermissionAttachment{
* @param string|Permission $name
* @param bool $value
*/
public function setPermission($name, bool $value){
public function setPermission($name, bool $value) : void{
$name = $name instanceof Permission ? $name->getName() : $name;
if(isset($this->permissions[$name])){
if($this->permissions[$name] === $value){
@ -135,7 +135,7 @@ class PermissionAttachment{
/**
* @param string|Permission $name
*/
public function unsetPermission($name){
public function unsetPermission($name) : void{
$name = $name instanceof Permission ? $name->getName() : $name;
if(isset($this->permissions[$name])){
unset($this->permissions[$name]);
@ -146,7 +146,7 @@ class PermissionAttachment{
/**
* @return void
*/
public function remove(){
public function remove() : void{
$this->permissible->removeAttachment($this);
}
}

View File

@ -69,7 +69,7 @@ class PermissionAttachmentInfo{
/**
* @return PermissionAttachment|null
*/
public function getAttachment(){
public function getAttachment() : ?PermissionAttachment{
return $this->attachment;
}

View File

@ -57,7 +57,7 @@ class PermissionManager{
*
* @return null|Permission
*/
public function getPermission(string $name){
public function getPermission(string $name) : ?Permission{
return $this->permissions[$name] ?? null;
}
@ -80,7 +80,7 @@ class PermissionManager{
/**
* @param string|Permission $permission
*/
public function removePermission($permission){
public function removePermission($permission) : void{
if($permission instanceof Permission){
unset($this->permissions[$permission->getName()]);
}else{
@ -104,7 +104,7 @@ class PermissionManager{
/**
* @param Permission $permission
*/
public function recalculatePermissionDefaults(Permission $permission){
public function recalculatePermissionDefaults(Permission $permission) : void{
if(isset($this->permissions[$permission->getName()])){
unset($this->defaultPermsOp[$permission->getName()]);
unset($this->defaultPerms[$permission->getName()]);
@ -115,7 +115,7 @@ class PermissionManager{
/**
* @param Permission $permission
*/
private function calculatePermissionDefault(Permission $permission){
private function calculatePermissionDefault(Permission $permission) : void{
Timings::$permissionDefaultTimer->startTiming();
if($permission->getDefault() === Permission::DEFAULT_OP or $permission->getDefault() === Permission::DEFAULT_TRUE){
$this->defaultPermsOp[$permission->getName()] = $permission;
@ -132,7 +132,7 @@ class PermissionManager{
/**
* @param bool $op
*/
private function dirtyPermissibles(bool $op){
private function dirtyPermissibles(bool $op) : void{
foreach($this->getDefaultPermSubscriptions($op) as $p){
$p->recalculatePermissions();
}
@ -142,7 +142,7 @@ class PermissionManager{
* @param string $permission
* @param Permissible $permissible
*/
public function subscribeToPermission(string $permission, Permissible $permissible){
public function subscribeToPermission(string $permission, Permissible $permissible) : void{
if(!isset($this->permSubs[$permission])){
$this->permSubs[$permission] = [];
}
@ -153,7 +153,7 @@ class PermissionManager{
* @param string $permission
* @param Permissible $permissible
*/
public function unsubscribeFromPermission(string $permission, Permissible $permissible){
public function unsubscribeFromPermission(string $permission, Permissible $permissible) : void{
if(isset($this->permSubs[$permission])){
unset($this->permSubs[$permission][spl_object_id($permissible)]);
if(count($this->permSubs[$permission]) === 0){
@ -187,7 +187,7 @@ class PermissionManager{
* @param bool $op
* @param Permissible $permissible
*/
public function subscribeToDefaultPerms(bool $op, Permissible $permissible){
public function subscribeToDefaultPerms(bool $op, Permissible $permissible) : void{
if($op){
$this->defSubsOp[spl_object_id($permissible)] = $permissible;
}else{
@ -199,7 +199,7 @@ class PermissionManager{
* @param bool $op
* @param Permissible $permissible
*/
public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible){
public function unsubscribeFromDefaultPerms(bool $op, Permissible $permissible) : void{
if($op){
unset($this->defSubsOp[spl_object_id($permissible)]);
}else{

View File

@ -31,5 +31,5 @@ interface PermissionRemovedExecutor{
*
* @return void
*/
public function attachmentRemoved(PermissionAttachment $attachment);
public function attachmentRemoved(PermissionAttachment $attachment) : void;
}

View File

@ -37,5 +37,5 @@ interface ServerOperator{
*
* @param bool $value
*/
public function setOp(bool $value);
public function setOp(bool $value) : void;
}

View File

@ -88,7 +88,7 @@ interface Plugin{
/**
* @return PluginLoader
*/
public function getPluginLoader();
public function getPluginLoader() : PluginLoader;
/**
* @return TaskScheduler

View File

@ -387,7 +387,7 @@ abstract class PluginBase implements Plugin, CommandExecutor{
/**
* @return PluginLoader
*/
public function getPluginLoader(){
public function getPluginLoader() : PluginLoader{
return $this->loader;
}

View File

@ -82,7 +82,7 @@ class PluginDescription{
*
* @throws PluginException
*/
private function loadMap(array $plugin){
private function loadMap(array $plugin) : void{
$this->map = $plugin;
$this->name = $plugin["name"];
@ -205,7 +205,7 @@ class PluginDescription{
*
* @throws PluginException if there are required extensions missing or have incompatible version, or if the version constraint cannot be parsed
*/
public function checkRequiredExtensions(){
public function checkRequiredExtensions() : void{
foreach($this->extensions as $name => $versionConstrs){
if(!extension_loaded($name)){
throw new PluginException("Required extension $name not loaded");

View File

@ -102,7 +102,7 @@ class PluginManager{
*
* @return null|Plugin
*/
public function getPlugin(string $name){
public function getPlugin(string $name) : ?Plugin{
if(isset($this->plugins[$name])){
return $this->plugins[$name];
}
@ -193,7 +193,7 @@ class PluginManager{
*
* @return Plugin[]
*/
public function loadPlugins(string $directory, ?array $newLoaders = null){
public function loadPlugins(string $directory, ?array $newLoaders = null) : array{
if(!is_dir($directory)){
return [];
}
@ -408,7 +408,7 @@ class PluginManager{
/**
* @param Plugin $plugin
*/
public function enablePlugin(Plugin $plugin){
public function enablePlugin(Plugin $plugin) : void{
if(!$plugin->isEnabled()){
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.enable", [$plugin->getDescription()->getFullName()]));
@ -425,7 +425,7 @@ class PluginManager{
}
}
public function disablePlugins(){
public function disablePlugins() : void{
foreach($this->getPlugins() as $plugin){
$this->disablePlugin($plugin);
}
@ -434,7 +434,7 @@ class PluginManager{
/**
* @param Plugin $plugin
*/
public function disablePlugin(Plugin $plugin){
public function disablePlugin(Plugin $plugin) : void{
if($plugin->isEnabled()){
$this->server->getLogger()->info($this->server->getLanguage()->translateString("pocketmine.plugin.disable", [$plugin->getDescription()->getFullName()]));
(new PluginDisableEvent($plugin))->call();
@ -457,7 +457,7 @@ class PluginManager{
}
}
public function clearPlugins(){
public function clearPlugins() : void{
$this->disablePlugins();
$this->plugins = [];
$this->enabledPlugins = [];

View File

@ -81,7 +81,7 @@ class RegisteredListener{
/**
* @param Event $event
*/
public function callEvent(Event $event){
public function callEvent(Event $event) : void{
if($event instanceof Cancellable and $event->isCancelled() and $this->isIgnoringCancelled()){
return;
}

View File

@ -151,7 +151,7 @@ class ResourcePackManager{
*
* @return ResourcePack|null
*/
public function getPackById(string $id){
public function getPackById(string $id) : ?ResourcePack{
return $this->uuidList[strtolower($id)] ?? null;
}

View File

@ -196,7 +196,7 @@ abstract class AsyncTask extends \Threaded{
*
* @param mixed $progress A value that can be safely serialize()'ed.
*/
public function publishProgress($progress){
public function publishProgress($progress) : void{
$this->progressUpdates[] = serialize($progress);
}

View File

@ -45,7 +45,7 @@ class AsyncWorker extends Worker{
$this->memoryLimit = $memoryLimit;
}
public function run(){
public function run() : void{
error_reporting(-1);
$this->registerClassLoader();
@ -73,7 +73,7 @@ class AsyncWorker extends Worker{
return $this->logger;
}
public function handleException(\Throwable $e){
public function handleException(\Throwable $e) : void{
$this->logger->logException($e);
}

View File

@ -53,7 +53,7 @@ class ClosureTask extends Task{
return Utils::getNiceClosureName($this->closure);
}
public function onRun(int $currentTick){
public function onRun(int $currentTick) : void{
($this->closure)($currentTick);
}
}

View File

@ -55,7 +55,7 @@ abstract class Task{
/**
* @param TaskHandler|null $taskHandler
*/
final public function setHandler(?TaskHandler $taskHandler){
final public function setHandler(?TaskHandler $taskHandler) : void{
if($this->taskHandler === null or $taskHandler === null){
$this->taskHandler = $taskHandler;
}

View File

@ -89,7 +89,7 @@ class TaskHandler{
/**
* @param int $ticks
*/
public function setNextRun(int $ticks){
public function setNextRun(int $ticks) : void{
$this->nextRun = $ticks;
}
@ -135,7 +135,7 @@ class TaskHandler{
return $this->period;
}
public function cancel(){
public function cancel() : void{
try{
if(!$this->isCancelled()){
$this->task->onCancel();
@ -145,7 +145,7 @@ class TaskHandler{
}
}
public function remove(){
public function remove() : void{
$this->cancelled = true;
$this->task->setHandler(null);
}
@ -153,7 +153,7 @@ class TaskHandler{
/**
* @param int $currentTick
*/
public function run(int $currentTick){
public function run(int $currentTick) : void{
$this->timings->startTiming();
try{
$this->task->onRun($currentTick);

View File

@ -65,7 +65,7 @@ class TaskScheduler{
*
* @return TaskHandler
*/
public function scheduleTask(Task $task){
public function scheduleTask(Task $task) : TaskHandler{
return $this->addTask($task, -1, -1);
}
@ -75,7 +75,7 @@ class TaskScheduler{
*
* @return TaskHandler
*/
public function scheduleDelayedTask(Task $task, int $delay){
public function scheduleDelayedTask(Task $task, int $delay) : TaskHandler{
return $this->addTask($task, $delay, -1);
}
@ -85,7 +85,7 @@ class TaskScheduler{
*
* @return TaskHandler
*/
public function scheduleRepeatingTask(Task $task, int $period){
public function scheduleRepeatingTask(Task $task, int $period) : TaskHandler{
return $this->addTask($task, -1, $period);
}
@ -96,14 +96,14 @@ class TaskScheduler{
*
* @return TaskHandler
*/
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period){
public function scheduleDelayedRepeatingTask(Task $task, int $delay, int $period) : TaskHandler{
return $this->addTask($task, $delay, $period);
}
/**
* @param int $taskId
*/
public function cancelTask(int $taskId){
public function cancelTask(int $taskId) : void{
if(isset($this->tasks[$taskId])){
try{
$this->tasks[$taskId]->cancel();
@ -113,7 +113,7 @@ class TaskScheduler{
}
}
public function cancelAllTasks(){
public function cancelAllTasks() : void{
foreach($this->tasks as $id => $task){
$this->cancelTask($id);
}
@ -142,7 +142,7 @@ class TaskScheduler{
*
* @throws \InvalidStateException
*/
private function addTask(Task $task, int $delay, int $period){
private function addTask(Task $task, int $delay, int $period) : TaskHandler{
if(!$this->enabled){
throw new \InvalidStateException("Tried to schedule task to disabled scheduler");
}
@ -186,7 +186,7 @@ class TaskScheduler{
/**
* @param int $currentTick
*/
public function mainThreadHeartbeat(int $currentTick){
public function mainThreadHeartbeat(int $currentTick) : void{
$this->currentTick = $currentTick;
while($this->isReady($this->currentTick)){
/** @var TaskHandler $task */

View File

@ -43,7 +43,7 @@ class Bed extends Spawnable{
return $this->color;
}
public function setColor(DyeColor $color){
public function setColor(DyeColor $color) : void{
$this->color = $color;
$this->onChanged();
}

View File

@ -63,7 +63,7 @@ class FlowerPot extends Spawnable{
return $this->plant !== null ? clone $this->plant : null;
}
public function setPlant(?Block $plant){
public function setPlant(?Block $plant) : void{
if($plant === null or $plant instanceof Air){
$this->plant = null;
}else{

View File

@ -72,7 +72,7 @@ class ItemFrame extends Spawnable{
return clone $this->item;
}
public function setItem(?Item $item){
public function setItem(?Item $item) : void{
if($item !== null and !$item->isNull()){
$this->item = clone $item;
}else{
@ -85,7 +85,7 @@ class ItemFrame extends Spawnable{
return $this->itemRotation;
}
public function setItemRotation(int $rotation){
public function setItemRotation(int $rotation) : void{
$this->itemRotation = $rotation;
$this->onChanged();
}
@ -94,7 +94,7 @@ class ItemFrame extends Spawnable{
return $this->itemDropChance;
}
public function setItemDropChance(float $chance){
public function setItemDropChance(float $chance) : void{
$this->itemDropChance = $chance;
$this->onChanged();
}

View File

@ -39,7 +39,7 @@ interface Nameable{
/**
* @param string $str
*/
public function setName(string $str);
public function setName(string $str) : void;
/**
* @return bool

View File

@ -69,7 +69,7 @@ class Skull extends Spawnable{
$nbt->setByte(self::TAG_ROT, $this->skullRotation);
}
public function setSkullType(SkullType $type){
public function setSkullType(SkullType $type) : void{
$this->skullType = $type;
$this->onChanged();
}

View File

@ -45,7 +45,7 @@ final class TileFactory{
//NOOP
}
public static function init(){
public static function init() : void{
self::register(Banner::class, ["Banner", "minecraft:banner"]);
self::register(Bed::class, ["Bed", "minecraft:bed"]);
self::register(Chest::class, ["Chest", "minecraft:chest"]);

View File

@ -112,7 +112,7 @@ abstract class Timings{
/** @var TimingsHandler[] */
public static $pluginTaskTimingMap = [];
public static function init(){
public static function init() : void{
if(self::$serverTickTimer instanceof TimingsHandler){
return;
}

View File

@ -44,7 +44,7 @@ class TimingsHandler{
/**
* @param resource $fp
*/
public static function printTimings($fp){
public static function printTimings($fp) : void{
fwrite($fp, "Minecraft" . PHP_EOL);
foreach(self::$HANDLERS as $timings){
@ -93,7 +93,7 @@ class TimingsHandler{
return self::$timingStart;
}
public static function reload(){
public static function reload() : void{
if(self::$enabled){
foreach(self::$HANDLERS as $timings){
$timings->reset();
@ -102,7 +102,7 @@ class TimingsHandler{
}
}
public static function tick(bool $measure = true){
public static function tick(bool $measure = true) : void{
if(self::$enabled){
if($measure){
foreach(self::$HANDLERS as $timings){
@ -157,7 +157,7 @@ class TimingsHandler{
self::$HANDLERS[spl_object_id($this)] = $this;
}
public function startTiming(){
public function startTiming() : void{
if(self::$enabled and ++$this->timingDepth === 1){
$this->start = microtime(true);
if($this->parent !== null and ++$this->parent->timingDepth === 1){
@ -166,7 +166,7 @@ class TimingsHandler{
}
}
public function stopTiming(){
public function stopTiming() : void{
if(self::$enabled){
if(--$this->timingDepth !== 0 or $this->start === 0){
return;
@ -184,7 +184,7 @@ class TimingsHandler{
}
}
public function reset(){
public function reset() : void{
$this->count = 0;
$this->curCount = 0;
$this->violations = 0;
@ -194,7 +194,7 @@ class TimingsHandler{
$this->timingDepth = 0;
}
public function remove(){
public function remove() : void{
unset(self::$HANDLERS[spl_object_id($this)]);
}
}

View File

@ -68,7 +68,7 @@ class AutoUpdater{
*
* @param array $updateInfo
*/
public function checkUpdateCallback(array $updateInfo){
public function checkUpdateCallback(array $updateInfo) : void{
$this->updateInfo = $updateInfo;
$this->checkUpdate();
if($this->hasUpdate()){
@ -97,7 +97,7 @@ class AutoUpdater{
/**
* Posts a warning to the console to tell the user there is an update available
*/
public function showConsoleUpdate(){
public function showConsoleUpdate() : void{
$messages = [
"Your version of " . $this->server->getName() . " is out of date. Version " . $this->newVersion->getFullVersion(true) . " was released on " . date("D M j h:i:s Y", $this->updateInfo["date"])
];
@ -114,26 +114,26 @@ class AutoUpdater{
*
* @param Player $player
*/
public function showPlayerUpdate(Player $player){
public function showPlayerUpdate(Player $player) : void{
$player->sendMessage(TextFormat::DARK_PURPLE . "The version of " . $this->server->getName() . " that this server is running is out of date. Please consider updating to the latest version.");
$player->sendMessage(TextFormat::DARK_PURPLE . "Check the console for more details.");
}
protected function showChannelSuggestionStable(){
protected function showChannelSuggestionStable() : void{
$this->printConsoleMessage([
"It appears you're running a Stable build, when you've specified that you prefer to run " . ucfirst($this->getChannel()) . " builds.",
"If you would like to be kept informed about new Stable builds only, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'stable'."
]);
}
protected function showChannelSuggestionBeta(){
protected function showChannelSuggestionBeta() : void{
$this->printConsoleMessage([
"It appears you're running a Beta build, when you've specified that you prefer to run Stable builds.",
"If you would like to be kept informed about new Beta or Development builds, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'beta' or 'development'."
]);
}
protected function printConsoleMessage(array $lines, string $logLevel = \LogLevel::INFO){
protected function printConsoleMessage(array $lines, string $logLevel = \LogLevel::INFO) : void{
$logger = $this->server->getLogger();
$title = $this->server->getName() . ' Auto Updater';
@ -149,21 +149,21 @@ class AutoUpdater{
*
* @return array|null
*/
public function getUpdateInfo(){
public function getUpdateInfo() : ?array{
return $this->updateInfo;
}
/**
* Schedules an AsyncTask to check for an update.
*/
public function doCheck(){
public function doCheck() : void{
$this->server->getAsyncPool()->submitTask(new UpdateCheckTask($this, $this->endpoint, $this->getChannel()));
}
/**
* Checks the update information against the current server version to decide if there's an update
*/
protected function checkUpdate(){
protected function checkUpdate() : void{
if($this->updateInfo === null){
return;
}

View File

@ -58,7 +58,7 @@ class Color{
*
* @param int $a
*/
public function setA(int $a){
public function setA(int $a) : void{
$this->a = $a & 0xff;
}
@ -75,7 +75,7 @@ class Color{
*
* @param int $r
*/
public function setR(int $r){
public function setR(int $r) : void{
$this->r = $r & 0xff;
}
@ -92,7 +92,7 @@ class Color{
*
* @param int $g
*/
public function setG(int $g){
public function setG(int $g) : void{
$this->g = $g & 0xff;
}
@ -109,7 +109,7 @@ class Color{
*
* @param int $b
*/
public function setB(int $b){
public function setB(int $b) : void{
$this->b = $b & 0xff;
}
@ -145,7 +145,7 @@ class Color{
*
* @return Color
*/
public static function fromRGB(int $code){
public static function fromRGB(int $code) : Color{
return new Color(($code >> 16) & 0xff, ($code >> 8) & 0xff, $code & 0xff);
}
@ -156,7 +156,7 @@ class Color{
*
* @return Color
*/
public static function fromARGB(int $code){
public static function fromARGB(int $code) : Color{
return new Color(($code >> 16) & 0xff, ($code >> 8) & 0xff, $code & 0xff, ($code >> 24) & 0xff);
}

Some files were not shown because too many files have changed in this diff Show More