mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-09 11:31:49 +00:00
Fix some strict type violations reported by PhpStorm (strict types <3)
This commit is contained in:
parent
b775e8c88a
commit
cf07af8b55
@ -1808,7 +1808,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
$this->allowFlight = (bool) ($this->gamemode & 0x01);
|
$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->setLevel($this->server->getDefaultLevel());
|
||||||
$this->namedtag["Level"] = $this->level->getName();
|
$this->namedtag["Level"] = $this->level->getName();
|
||||||
$this->namedtag["Pos"][0] = $this->level->getSpawnLocation()->x;
|
$this->namedtag["Pos"][0] = $this->level->getSpawnLocation()->x;
|
||||||
@ -1844,7 +1844,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
protected function completeLoginSequence(){
|
protected function completeLoginSequence(){
|
||||||
parent::__construct($this->level, $this->namedtag);
|
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);
|
$this->spawnPosition = new WeakPosition($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@ use pocketmine\event\level\LevelLoadEvent;
|
|||||||
use pocketmine\event\player\PlayerDataSaveEvent;
|
use pocketmine\event\player\PlayerDataSaveEvent;
|
||||||
use pocketmine\event\server\QueryRegenerateEvent;
|
use pocketmine\event\server\QueryRegenerateEvent;
|
||||||
use pocketmine\event\server\ServerCommandEvent;
|
use pocketmine\event\server\ServerCommandEvent;
|
||||||
|
use pocketmine\event\TextContainer;
|
||||||
use pocketmine\event\Timings;
|
use pocketmine\event\Timings;
|
||||||
use pocketmine\event\TimingsHandler;
|
use pocketmine\event\TimingsHandler;
|
||||||
use pocketmine\event\TranslationContainer;
|
use pocketmine\event\TranslationContainer;
|
||||||
@ -1165,7 +1166,7 @@ class Server{
|
|||||||
return (string) $v[$variable];
|
return (string) $v[$variable];
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->properties->exists($variable) ? $this->properties->get($variable) : $defaultValue;
|
return $this->properties->exists($variable) ? (string) $this->properties->get($variable) : $defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1654,8 +1655,8 @@ class Server{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param TextContainer|string $message
|
* @param TextContainer|string $message
|
||||||
* @param Player[] $recipients
|
* @param Player[] $recipients
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
|
@ -64,7 +64,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
public $eyeHeight = 1.62;
|
public $eyeHeight = 1.62;
|
||||||
|
|
||||||
protected $skinId;
|
protected $skinId;
|
||||||
protected $skin = null;
|
protected $skin = "";
|
||||||
|
|
||||||
protected $foodTickTimer = 0;
|
protected $foodTickTimer = 0;
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
protected $xpSeed;
|
protected $xpSeed;
|
||||||
|
|
||||||
public function __construct(Level $level, CompoundTag $nbt){
|
public function __construct(Level $level, CompoundTag $nbt){
|
||||||
if($this->skin === null and (!isset($nbt->Skin) or !isset($nbt->Skin->Data) or !Player::isValidSkin($nbt->Skin->Data->getValue()))){
|
if($this->skin === "" and (!isset($nbt->Skin) or !isset($nbt->Skin->Data) or !Player::isValidSkin($nbt->Skin->Data->getValue()))){
|
||||||
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
|
throw new \InvalidStateException((new \ReflectionClass($this))->getShortName() . " must have a valid skin set");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,7 +250,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
$this->attributeMap->getAttribute(Attribute::EXPERIENCE)->setValue($progress);
|
$this->attributeMap->getAttribute(Attribute::EXPERIENCE)->setValue($progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTotalXp() : float{
|
public function getTotalXp() : int{
|
||||||
return $this->totalXp;
|
return $this->totalXp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,19 +319,19 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
if(!isset($this->namedtag->foodLevel) or !($this->namedtag->foodLevel instanceof IntTag)){
|
if(!isset($this->namedtag->foodLevel) or !($this->namedtag->foodLevel instanceof IntTag)){
|
||||||
$this->namedtag->foodLevel = new IntTag("foodLevel", (int) $this->getFood());
|
$this->namedtag->foodLevel = new IntTag("foodLevel", (int) $this->getFood());
|
||||||
}else{
|
}else{
|
||||||
$this->setFood($this->namedtag["foodLevel"]);
|
$this->setFood((float) $this->namedtag["foodLevel"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->namedtag->foodExhaustionLevel) or !($this->namedtag->foodExhaustionLevel instanceof IntTag)){
|
if(!isset($this->namedtag->foodExhaustionLevel) or !($this->namedtag->foodExhaustionLevel instanceof FloatTag)){
|
||||||
$this->namedtag->foodExhaustionLevel = new FloatTag("foodExhaustionLevel", $this->getExhaustion());
|
$this->namedtag->foodExhaustionLevel = new FloatTag("foodExhaustionLevel", $this->getExhaustion());
|
||||||
}else{
|
}else{
|
||||||
$this->setExhaustion($this->namedtag["foodExhaustionLevel"]);
|
$this->setExhaustion((float) $this->namedtag["foodExhaustionLevel"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->namedtag->foodSaturationLevel) or !($this->namedtag->foodSaturationLevel instanceof IntTag)){
|
if(!isset($this->namedtag->foodSaturationLevel) or !($this->namedtag->foodSaturationLevel instanceof FloatTag)){
|
||||||
$this->namedtag->foodSaturationLevel = new FloatTag("foodSaturationLevel", $this->getSaturation());
|
$this->namedtag->foodSaturationLevel = new FloatTag("foodSaturationLevel", $this->getSaturation());
|
||||||
}else{
|
}else{
|
||||||
$this->setSaturation($this->namedtag["foodSaturationLevel"]);
|
$this->setSaturation((float) $this->namedtag["foodSaturationLevel"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->namedtag->foodTickTimer) or !($this->namedtag->foodTickTimer instanceof IntTag)){
|
if(!isset($this->namedtag->foodTickTimer) or !($this->namedtag->foodTickTimer instanceof IntTag)){
|
||||||
@ -343,7 +343,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
if(!isset($this->namedtag->XpLevel) or !($this->namedtag->XpLevel instanceof IntTag)){
|
if(!isset($this->namedtag->XpLevel) or !($this->namedtag->XpLevel instanceof IntTag)){
|
||||||
$this->namedtag->XpLevel = new IntTag("XpLevel", $this->getXpLevel());
|
$this->namedtag->XpLevel = new IntTag("XpLevel", $this->getXpLevel());
|
||||||
}else{
|
}else{
|
||||||
$this->setXpLevel($this->namedtag["XpLevel"]);
|
$this->setXpLevel((int) $this->namedtag["XpLevel"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($this->namedtag->XpP) or !($this->namedtag->XpP instanceof FloatTag)){
|
if(!isset($this->namedtag->XpP) or !($this->namedtag->XpP instanceof FloatTag)){
|
||||||
|
@ -74,7 +74,7 @@ abstract class Projectile extends Entity{
|
|||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getResultDamage() : int{
|
public function getResultDamage() : int{
|
||||||
return ceil(sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2) * $this->damage);
|
return (int) ceil(sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2) * $this->damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCollideWithEntity(Entity $entity){
|
public function onCollideWithEntity(Entity $entity){
|
||||||
|
@ -51,7 +51,7 @@ class Fish extends Food{
|
|||||||
}elseif($this->meta === self::FISH_CLOWNFISH){
|
}elseif($this->meta === self::FISH_CLOWNFISH){
|
||||||
return 1;
|
return 1;
|
||||||
}elseif($this->meta === self::FISH_PUFFERFISH){
|
}elseif($this->meta === self::FISH_PUFFERFISH){
|
||||||
return 1.2;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -231,7 +231,7 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getGenerator() : string{
|
public function getGenerator() : string{
|
||||||
return $this->levelData["generatorName"];
|
return (string) $this->levelData["generatorName"];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getGeneratorOptions() : array{
|
public function getGeneratorOptions() : array{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user