Strict type all the things and fix lots of assorted bugs exposed by strict types (#993)

Strict type all the things
This commit is contained in:
Dylan K. Taylor 2017-06-08 11:21:51 +01:00 committed by GitHub
commit d358e13868
863 changed files with 2033 additions and 308 deletions

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\event\TranslationContainer;
@ -108,7 +110,7 @@ abstract class Achievement{
public static function broadcast(Player $player, $achievementId){
if(isset(Achievement::$list[$achievementId])){
$translation = new TranslationContainer("chat.type.achievement", [$player->getDisplayName(), TextFormat::GREEN . Achievement::$list[$achievementId]["name"] . TextFormat::RESET]);
if(Server::getInstance()->getConfigString("announce-player-achievements", true) === true){
if(Server::getInstance()->getConfigBoolean("announce-player-achievements", true) === true){
Server::getInstance()->broadcastMessage($translation);
}else{
$player->sendMessage($translation);

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
abstract class Collectable extends \Threaded implements \Collectable{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\network\mcpe\protocol\ProtocolInfo;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\permission\ServerOperator;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\event\server\LowMemoryEvent;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\metadata\Metadatable;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
use pocketmine\block\Air;
@ -839,6 +841,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$X = null;
$Z = null;
Level::getXZ($index, $X, $Z);
assert(is_int($X) and is_int($Z));
++$count;
@ -900,7 +903,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->getDisplayName()
])
));
if(strlen(trim($ev->getJoinMessage())) > 0){
if(strlen(trim((string) $ev->getJoinMessage())) > 0){
$this->server->broadcastMessage($ev->getJoinMessage());
}
@ -1806,7 +1809,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->allowFlight = (bool) ($this->gamemode & 0x01);
if(($level = $this->server->getLevelByName($this->namedtag["Level"])) === null){
if(($level = $this->server->getLevelByName((string) $this->namedtag["Level"])) === null){
$this->setLevel($this->server->getDefaultLevel());
$this->namedtag["Level"] = $this->level->getName();
$this->namedtag["Pos"][0] = $this->level->getSpawnLocation()->x;
@ -1823,7 +1826,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
}
$this->namedtag->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
$this->namedtag->lastPlayed = new LongTag("lastPlayed", (int) floor(microtime(true) * 1000));
if($this->server->getAutoSave()){
$this->server->saveOfflinePlayerData($this->username, $this->namedtag, true);
}
@ -1842,7 +1845,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
protected function completeLoginSequence(){
parent::__construct($this->level, $this->namedtag);
if(!$this->hasValidSpawnPosition() and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){
if(!$this->hasValidSpawnPosition() and isset($this->namedtag->SpawnLevel) and ($level = $this->server->getLevelByName((string) $this->namedtag["SpawnLevel"])) instanceof Level){
$this->spawnPosition = new WeakPosition($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
}
@ -1864,12 +1867,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk->spawnX = $spawnPosition->getFloorX();
$pk->spawnY = $spawnPosition->getFloorY();
$pk->spawnZ = $spawnPosition->getFloorZ();
$pk->hasAchievementsDisabled = 1;
$pk->hasAchievementsDisabled = true;
$pk->dayCycleStopTime = -1; //TODO: implement this properly
$pk->eduMode = 0;
$pk->eduMode = false;
$pk->rainLevel = 0; //TODO: implement these properly
$pk->lightningLevel = 0;
$pk->commandsEnabled = 1;
$pk->commandsEnabled = true;
$pk->levelId = "";
$pk->worldName = $this->server->getMotd();
$this->dataPacket($pk);
@ -2598,7 +2601,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
//TODO: improve this to take stuff like swimming, ladders, enchanted tools into account, fix wrong tool break time calculations for bad tools (pmmp/PocketMine-MP#211)
$breakTime = ceil($target->getBreakTime($this->inventory->getItemInHand()) * 20);
if($breakTime > 0){
$this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_BLOCK_START_BREAK, 65535 / $breakTime);
$this->level->broadcastLevelEvent($pos, LevelEventPacket::EVENT_BLOCK_START_BREAK, (int) (65535 / $breakTime));
}
}
$this->lastBreak = microtime(true);
@ -3563,7 +3566,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
/**
* Sends a direct chat message to a player
*
* @param string|TextContainer $message
* @param TextContainer|string $message
*/
public function sendMessage($message){
if($message instanceof TextContainer){
@ -3745,7 +3748,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
$this->namedtag["playerGameType"] = $this->gamemode;
$this->namedtag["lastPlayed"] = floor(microtime(true) * 1000);
$this->namedtag["lastPlayed"] = (int) floor(microtime(true) * 1000);
if($this->username != "" and $this->namedtag instanceof CompoundTag){
$this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async);
@ -3959,6 +3962,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$pk->pitch = $pitch;
$pk->yaw = $yaw;
$pk->mode = $mode;
$pk->onGround = $this->onGround;
if($targets !== null){
$this->server->broadcastPacket($targets, $pk);

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace {
function safe_var_dump(){
static $cnt = 0;
@ -142,12 +144,12 @@ namespace pocketmine {
}
});
ini_set("allow_url_fopen", 1);
ini_set("display_errors", 1);
ini_set("display_startup_errors", 1);
ini_set("allow_url_fopen", '1');
ini_set("display_errors", '1');
ini_set("display_startup_errors", '1');
ini_set("default_charset", "utf-8");
ini_set("memory_limit", -1);
ini_set("memory_limit", '-1');
define('pocketmine\START_TIME', microtime(true));
$opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]);

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
/**
* PocketMine-MP is the Minecraft: PE multiplayer server software
* Homepage: http://www.pocketmine.net/
@ -40,6 +42,7 @@ use pocketmine\event\level\LevelLoadEvent;
use pocketmine\event\player\PlayerDataSaveEvent;
use pocketmine\event\server\QueryRegenerateEvent;
use pocketmine\event\server\ServerCommandEvent;
use pocketmine\event\TextContainer;
use pocketmine\event\Timings;
use pocketmine\event\TimingsHandler;
use pocketmine\event\TranslationContainer;
@ -264,77 +267,77 @@ class Server{
/**
* @return string
*/
public function getName(){
public function getName() : string{
return "PocketMine-MP";
}
/**
* @return bool
*/
public function isRunning(){
public function isRunning() : bool{
return $this->isRunning === true;
}
/**
* @return string
*/
public function getPocketMineVersion(){
public function getPocketMineVersion() : string{
return \pocketmine\VERSION;
}
/**
* @return string
*/
public function getCodename(){
public function getCodename() : string{
return \pocketmine\CODENAME;
}
/**
* @return string
*/
public function getVersion(){
public function getVersion() : string{
return ProtocolInfo::MINECRAFT_VERSION;
}
/**
* @return string
*/
public function getApiVersion(){
public function getApiVersion() : string{
return \pocketmine\API_VERSION;
}
/**
* @return string
*/
public function getFilePath(){
public function getFilePath() : string{
return $this->filePath;
}
/**
* @return string
*/
public function getDataPath(){
public function getDataPath() : string{
return $this->dataPath;
}
/**
* @return string
*/
public function getPluginPath(){
public function getPluginPath() : string{
return $this->pluginPath;
}
/**
* @return int
*/
public function getMaxPlayers(){
public function getMaxPlayers() : int{
return $this->maxPlayers;
}
/**
* @return int
*/
public function getPort(){
public function getPort() : int{
return $this->getConfigInt("server-port", 19132);
}
@ -359,10 +362,13 @@ class Server{
/**
* @return string
*/
public function getIp(){
public function getIp() : string{
return $this->getConfigString("server-ip", "0.0.0.0");
}
/**
* @return UUID
*/
public function getServerUniqueId(){
return $this->serverID;
}
@ -370,15 +376,15 @@ class Server{
/**
* @return bool
*/
public function getAutoSave(){
public function getAutoSave() : bool{
return $this->autoSave;
}
/**
* @param bool $value
*/
public function setAutoSave($value){
$this->autoSave = (bool) $value;
public function setAutoSave(bool $value){
$this->autoSave = $value;
foreach($this->getLevels() as $level){
$level->setAutoSave($this->autoSave);
}
@ -387,28 +393,28 @@ class Server{
/**
* @return string
*/
public function getLevelType(){
public function getLevelType() : string{
return $this->getConfigString("level-type", "DEFAULT");
}
/**
* @return bool
*/
public function getGenerateStructures(){
public function getGenerateStructures() : bool{
return $this->getConfigBoolean("generate-structures", true);
}
/**
* @return int
*/
public function getGamemode(){
public function getGamemode() : int{
return $this->getConfigInt("gamemode", 0) & 0b11;
}
/**
* @return bool
*/
public function getForceGamemode(){
public function getForceGamemode() : bool{
return $this->getConfigBoolean("force-gamemode", false);
}
@ -419,7 +425,7 @@ class Server{
*
* @return string
*/
public static function getGamemodeString($mode){
public static function getGamemodeString(int $mode) : string{
switch((int) $mode){
case Player::SURVIVAL:
return "%gameMode.survival";
@ -441,7 +447,7 @@ class Server{
*
* @return int
*/
public static function getGamemodeFromString($str){
public static function getGamemodeFromString(string $str) : int{
switch(strtolower(trim($str))){
case (string) Player::SURVIVAL:
case "survival":
@ -472,7 +478,7 @@ class Server{
*
* @return int
*/
public static function getDifficultyFromString($str){
public static function getDifficultyFromString(string $str) : int{
switch(strtolower(trim($str))){
case "0":
case "peaceful":
@ -500,49 +506,49 @@ class Server{
/**
* @return int
*/
public function getDifficulty(){
public function getDifficulty() : int{
return $this->getConfigInt("difficulty", 1);
}
/**
* @return bool
*/
public function hasWhitelist(){
public function hasWhitelist() : bool{
return $this->getConfigBoolean("white-list", false);
}
/**
* @return int
*/
public function getSpawnRadius(){
public function getSpawnRadius() : int{
return $this->getConfigInt("spawn-protection", 16);
}
/**
* @return bool
*/
public function getAllowFlight(){
public function getAllowFlight() : bool{
return $this->getConfigBoolean("allow-flight", false);
}
/**
* @return bool
*/
public function isHardcore(){
public function isHardcore() : bool{
return $this->getConfigBoolean("hardcore", false);
}
/**
* @return int
*/
public function getDefaultGamemode(){
public function getDefaultGamemode() : int{
return $this->getConfigInt("gamemode", 0) & 0b11;
}
/**
* @return string
*/
public function getMotd(){
public function getMotd() : string{
return $this->getConfigString("motd", "Minecraft: PE Server");
}
@ -619,7 +625,7 @@ class Server{
/**
* @return int
*/
public function getTick(){
public function getTick() : int{
return $this->tickCounter;
}
@ -628,7 +634,7 @@ class Server{
*
* @return float
*/
public function getTicksPerSecond(){
public function getTicksPerSecond() : float{
return round($this->currentTPS, 2);
}
@ -637,7 +643,7 @@ class Server{
*
* @return float
*/
public function getTicksPerSecondAverage(){
public function getTicksPerSecondAverage() : float{
return round(array_sum($this->tickAverage) / count($this->tickAverage), 2);
}
@ -646,7 +652,7 @@ class Server{
*
* @return float
*/
public function getTickUsage(){
public function getTickUsage() : float{
return round($this->currentUse * 100, 2);
}
@ -655,7 +661,7 @@ class Server{
*
* @return float
*/
public function getTickUsageAverage(){
public function getTickUsageAverage() : float{
return round((array_sum($this->useAverage) / count($this->useAverage)) * 100, 2);
}
@ -669,7 +675,7 @@ class Server{
/**
* @return Player[]
*/
public function getOnlinePlayers(){
public function getOnlinePlayers() : array{
return $this->playerList;
}
@ -686,7 +692,7 @@ class Server{
*
* @return OfflinePlayer|Player
*/
public function getOfflinePlayer($name){
public function getOfflinePlayer(string $name){
$name = strtolower($name);
$result = $this->getPlayerExact($name);
@ -702,7 +708,7 @@ class Server{
*
* @return CompoundTag
*/
public function getOfflinePlayerData($name) : CompoundTag{
public function getOfflinePlayerData(string $name) : CompoundTag{
$name = strtolower($name);
$path = $this->getDataPath() . "players/";
if($this->shouldSavePlayerData()){
@ -794,9 +800,9 @@ class Server{
/**
* @param string $name
*
* @return Player
* @return Player|null
*/
public function getPlayer($name){
public function getPlayer(string $name){
$found = null;
$name = strtolower($name);
$delta = PHP_INT_MAX;
@ -819,9 +825,9 @@ class Server{
/**
* @param string $name
*
* @return Player
* @return Player|null
*/
public function getPlayerExact($name){
public function getPlayerExact(string $name){
$name = strtolower($name);
foreach($this->getOnlinePlayers() as $player){
if($player->getLowerCaseName() === $name){
@ -837,7 +843,7 @@ class Server{
*
* @return Player[]
*/
public function matchPlayer($partialName){
public function matchPlayer(string $partialName) : array{
$partialName = strtolower($partialName);
$matchedPlayers = [];
foreach($this->getOnlinePlayers() as $player){
@ -875,12 +881,12 @@ class Server{
/**
* @return Level[]
*/
public function getLevels(){
public function getLevels() : array{
return $this->levels;
}
/**
* @return Level
* @return Level|null
*/
public function getDefaultLevel(){
return $this->levelDefault;
@ -891,7 +897,7 @@ class Server{
* This won't change the level-name property,
* it only affects the server on runtime
*
* @param Level $level
* @param Level|null $level
*/
public function setDefaultLevel($level){
if($level === null or ($this->isLevelLoaded($level->getFolderName()) and $level !== $this->levelDefault)){
@ -904,16 +910,16 @@ class Server{
*
* @return bool
*/
public function isLevelLoaded($name){
public function isLevelLoaded(string $name) : bool{
return $this->getLevelByName($name) instanceof Level;
}
/**
* @param int $levelId
*
* @return Level
* @return Level|null
*/
public function getLevel($levelId){
public function getLevel(int $levelId){
if(isset($this->levels[$levelId])){
return $this->levels[$levelId];
}
@ -922,11 +928,13 @@ class Server{
}
/**
* @param $name
* NOTE: This matches levels based on the FOLDER name, NOT the display name.
*
* @return Level
* @param string $name
*
* @return Level|null
*/
public function getLevelByName($name){
public function getLevelByName(string $name){
foreach($this->getLevels() as $level){
if($level->getFolderName() === $name){
return $level;
@ -944,7 +952,7 @@ class Server{
*
* @throws \InvalidStateException
*/
public function unloadLevel(Level $level, $forceUnload = false){
public function unloadLevel(Level $level, bool $forceUnload = false) : bool{
if($level === $this->getDefaultLevel() and !$forceUnload){
throw new \InvalidStateException("The default level cannot be unloaded while running, please switch levels.");
}
@ -966,7 +974,7 @@ class Server{
*
* @throws LevelException
*/
public function loadLevel($name){
public function loadLevel(string $name) : bool{
if(trim($name) === ""){
throw new LevelException("Invalid empty level name");
}
@ -1011,14 +1019,14 @@ class Server{
/**
* Generates a new level if it does not exists
*
* @param string $name
* @param int $seed
* @param string $generator Class name that extends pocketmine\level\generator\Noise
* @param array $options
* @param string $name
* @param int|null $seed
* @param string|null $generator Class name that extends pocketmine\level\generator\Noise
* @param array $options
*
* @return bool
*/
public function generateLevel($name, $seed = null, $generator = null, $options = []){
public function generateLevel(string $name, $seed = null, $generator = null, array $options = []){
if(trim($name) === "" or $this->isLevelGenerated($name)){
return false;
}
@ -1042,7 +1050,7 @@ class Server{
/** @var \pocketmine\level\format\io\LevelProvider $provider */
$provider::generate($path, $name, $seed, $generator, $options);
$level = new Level($this, $name, $path, $provider);
$level = new Level($this, $name, $path, (string) $provider);
$this->levels[$level->getId()] = $level;
$level->initLevel();
@ -1090,7 +1098,7 @@ class Server{
*
* @return bool
*/
public function isLevelGenerated($name){
public function isLevelGenerated(string $name) : bool{
if(trim($name) === ""){
return false;
}
@ -1130,28 +1138,13 @@ class Server{
return null;
}
/**
* @param string $variable
* @param string $defaultValue
*
* @return string
*/
public function getConfigString($variable, $defaultValue = ""){
$v = getopt("", ["$variable::"]);
if(isset($v[$variable])){
return (string) $v[$variable];
}
return $this->properties->exists($variable) ? $this->properties->get($variable) : $defaultValue;
}
/**
* @param string $variable
* @param mixed $defaultValue
*
* @return mixed
*/
public function getProperty($variable, $defaultValue = null){
public function getProperty(string $variable, $defaultValue = null){
if(!array_key_exists($variable, $this->propertyCache)){
$v = getopt("", ["$variable::"]);
if(isset($v[$variable])){
@ -1164,11 +1157,26 @@ class Server{
return $this->propertyCache[$variable] === null ? $defaultValue : $this->propertyCache[$variable];
}
/**
* @param string $variable
* @param string $defaultValue
*
* @return string
*/
public function getConfigString(string $variable, string $defaultValue = "") : string{
$v = getopt("", ["$variable::"]);
if(isset($v[$variable])){
return (string) $v[$variable];
}
return $this->properties->exists($variable) ? (string) $this->properties->get($variable) : $defaultValue;
}
/**
* @param string $variable
* @param string $value
*/
public function setConfigString($variable, $value){
public function setConfigString(string $variable, string $value){
$this->properties->set($variable, $value);
}
@ -1178,7 +1186,7 @@ class Server{
*
* @return int
*/
public function getConfigInt($variable, $defaultValue = 0){
public function getConfigInt(string $variable, int $defaultValue = 0) : int{
$v = getopt("", ["$variable::"]);
if(isset($v[$variable])){
return (int) $v[$variable];
@ -1191,17 +1199,17 @@ class Server{
* @param string $variable
* @param int $value
*/
public function setConfigInt($variable, $value){
public function setConfigInt(string $variable, int $value){
$this->properties->set($variable, (int) $value);
}
/**
* @param string $variable
* @param boolean $defaultValue
* @param string $variable
* @param bool $defaultValue
*
* @return boolean
* @return bool
*/
public function getConfigBoolean($variable, $defaultValue = false){
public function getConfigBoolean(string $variable, bool $defaultValue = false) : bool{
$v = getopt("", ["$variable::"]);
if(isset($v[$variable])){
$value = $v[$variable];
@ -1227,16 +1235,16 @@ class Server{
* @param string $variable
* @param bool $value
*/
public function setConfigBool($variable, $value){
public function setConfigBool(string $variable, bool $value){
$this->properties->set($variable, $value == true ? "1" : "0");
}
/**
* @param string $name
*
* @return PluginIdentifiableCommand
* @return PluginIdentifiableCommand|null
*/
public function getPluginCommand($name){
public function getPluginCommand(string $name){
if(($command = $this->commandMap->getCommand($name)) instanceof PluginIdentifiableCommand){
return $command;
}else{
@ -1261,7 +1269,7 @@ class Server{
/**
* @param string $name
*/
public function addOp($name){
public function addOp(string $name){
$this->operators->set(strtolower($name), true);
if(($player = $this->getPlayerExact($name)) !== null){
@ -1273,7 +1281,7 @@ class Server{
/**
* @param string $name
*/
public function removeOp($name){
public function removeOp(string $name){
$this->operators->remove(strtolower($name));
if(($player = $this->getPlayerExact($name)) !== null){
@ -1285,7 +1293,7 @@ class Server{
/**
* @param string $name
*/
public function addWhitelist($name){
public function addWhitelist(string $name){
$this->whitelist->set(strtolower($name), true);
$this->whitelist->save(true);
}
@ -1293,7 +1301,7 @@ class Server{
/**
* @param string $name
*/
public function removeWhitelist($name){
public function removeWhitelist(string $name){
$this->whitelist->remove(strtolower($name));
$this->whitelist->save();
}
@ -1303,7 +1311,7 @@ class Server{
*
* @return bool
*/
public function isWhitelisted($name){
public function isWhitelisted(string $name){
return !$this->hasWhitelist() or $this->operators->exists($name, true) or $this->whitelist->exists($name, true);
}
@ -1312,7 +1320,7 @@ class Server{
*
* @return bool
*/
public function isOp($name){
public function isOp(string $name){
return $this->operators->exists($name, true);
}
@ -1337,7 +1345,7 @@ class Server{
/**
* @return string[]
*/
public function getCommandAliases(){
public function getCommandAliases() : array{
$section = $this->getProperty("aliases");
$result = [];
if(is_array($section)){
@ -1376,7 +1384,7 @@ class Server{
* @param string $dataPath
* @param string $pluginPath
*/
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, string $filePath, string $dataPath, string $pluginPath){
self::$instance = $this;
self::$sleeper = new \Threaded;
$this->autoloader = $autoloader;
@ -1650,12 +1658,12 @@ class Server{
}
/**
* @param string $message
* @param Player[]|null $recipients
* @param TextContainer|string $message
* @param Player[] $recipients
*
* @return int
*/
public function broadcastMessage($message, $recipients = null){
public function broadcastMessage($message, array $recipients = null) : int{
if(!is_array($recipients)){
return $this->broadcast($message, self::BROADCAST_CHANNEL_USERS);
}
@ -1669,16 +1677,15 @@ class Server{
}
/**
* @param string $tip
* @param Player[]|null $recipients
* @param string $tip
* @param Player[] $recipients
*
* @return int
*/
public function broadcastTip($tip, $recipients = null){
public function broadcastTip(string $tip, array $recipients = null) : int{
if(!is_array($recipients)){
/** @var Player[] $recipients */
$recipients = [];
foreach($this->pluginManager->getPermissionSubscriptions(self::BROADCAST_CHANNEL_USERS) as $permissible){
if($permissible instanceof Player and $permissible->hasPermission(self::BROADCAST_CHANNEL_USERS)){
$recipients[spl_object_hash($permissible)] = $permissible; // do not send messages directly, or some might be repeated
@ -1695,12 +1702,12 @@ class Server{
}
/**
* @param string $popup
* @param Player[]|null $recipients
* @param string $popup
* @param Player[] $recipients
*
* @return int
*/
public function broadcastPopup($popup, $recipients = null){
public function broadcastPopup(string $popup, array $recipients = null) : int{
if(!is_array($recipients)){
/** @var Player[] $recipients */
$recipients = [];
@ -1751,12 +1758,12 @@ class Server{
}
/**
* @param string $message
* @param string $permissions
* @param TextContainer|string $message
* @param string $permissions
*
* @return int
*/
public function broadcast($message, $permissions){
public function broadcast($message, string $permissions) : int{
/** @var CommandSender[] $recipients */
$recipients = [];
foreach(explode(";", $permissions) as $permission){
@ -1794,7 +1801,7 @@ class Server{
* @param bool $forceSync
* @param bool $immediate
*/
public function batchPackets(array $players, array $packets, $forceSync = false, bool $immediate = false){
public function batchPackets(array $players, array $packets, bool $forceSync = false, bool $immediate = false){
Timings::$playerNetworkTimer->startTiming();
$targets = [];
@ -1856,7 +1863,7 @@ class Server{
/**
* @param int $type
*/
public function enablePlugins($type){
public function enablePlugins(int $type){
foreach($this->pluginManager->getPlugins() as $plugin){
if(!$plugin->isEnabled() and $plugin->getDescription()->getOrder() === $type){
$this->enablePlugin($plugin);
@ -1899,7 +1906,7 @@ class Server{
*
* @return bool
*/
public function dispatchCommand(CommandSender $sender, $commandLine){
public function dispatchCommand(CommandSender $sender, string $commandLine){
if($this->commandMap->dispatch($sender, $commandLine)){
return true;
}
@ -2115,8 +2122,8 @@ class Server{
}
$this->hasStopped = false;
ini_set("error_reporting", 0);
ini_set("memory_limit", -1); //Fix error dump not dumped on memory problems
ini_set("error_reporting", '0');
ini_set("memory_limit", '-1'); //Fix error dump not dumped on memory problems
$this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.create"));
try{
$dump = new CrashDump($this);
@ -2272,11 +2279,11 @@ class Server{
$this->getLogger()->debug("Raising level \"{$level->getName()}\" tick rate to {$level->getTickRate()} ticks");
}elseif($tickMs >= 50){
if($level->getTickRate() === $this->baseTickRate){
$level->setTickRate(max($this->baseTickRate + 1, min($this->autoTickRateLimit, floor($tickMs / 50))));
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
$level->setTickRate(max($this->baseTickRate + 1, min($this->autoTickRateLimit, (int) floor($tickMs / 50))));
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), (int) round($tickMs, 2), $level->getTickRate()));
}elseif(($tickMs / $level->getTickRate()) >= 50 and $level->getTickRate() < $this->autoTickRateLimit){
$level->setTickRate($level->getTickRate() + 1);
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), round($tickMs, 2), $level->getTickRate()));
$this->getLogger()->debug(sprintf("Level \"%s\" took %gms, setting tick rate to %d ticks", $level->getName(), (int) round($tickMs, 2), $level->getTickRate()));
}
$level->tickRateCounter = $level->getTickRate();
}
@ -2324,7 +2331,7 @@ class Server{
/**
* @return bool
*/
public function isLanguageForced(){
public function isLanguageForced() : bool{
return $this->forceLanguage;
}
@ -2367,7 +2374,7 @@ class Server{
*
* TODO: move this to Network
*/
public function handlePacket($address, $port, $payload){
public function handlePacket(string $address, int $port, string $payload){
try{
if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){
$this->queryHandler->handle($address, $port, $payload);

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
class ThreadManager extends \Volatile{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine;
/**

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class AcaciaWoodStairs extends WoodStairs{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class ActivatorRail extends Rail{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\AnvilInventory;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\TranslationContainer;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class BirchWoodStairs extends WoodStairs{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
/**
* All Block classes are in here
*/

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
interface BlockIds{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Effect;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class CocoaBlock extends Solid{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockGrowEvent;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DarkOakWoodStairs extends WoodStairs{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DaylightSensor extends Transparent{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\level\Level;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class DetectorRail extends Rail{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\inventory\EnchantInventory;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Arrow;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
abstract class Flowable extends Transparent{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\BlockSpreadEvent;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Tool;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class JungleWoodStairs extends WoodStairs{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\item\Item;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Effect;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\LeavesDecayEvent;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\event\block\LeavesDecayEvent;

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
class Lever extends Flowable{

View File

@ -19,6 +19,8 @@
*
*/
declare(strict_types=1);
namespace pocketmine\block;
use pocketmine\entity\Entity;

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