Hinting up Entity API to PHP 7.2 standards

This commit is contained in:
Dylan K. Taylor
2018-05-19 10:46:47 +01:00
parent 389990e0a8
commit 0bb5e88b5c
17 changed files with 181 additions and 171 deletions

View File

@@ -100,7 +100,7 @@ class ExperienceOrb extends Entity{
*/
protected $targetPlayerRuntimeId = null;
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$this->age = $this->namedtag->getShort("Age", 0);
@@ -115,7 +115,7 @@ class ExperienceOrb extends Entity{
$this->setXpValue($value);
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setShort("Age", $this->age);
@@ -210,7 +210,7 @@ class ExperienceOrb extends Entity{
return $hasUpdate;
}
protected function tryChangeMovement(){
protected function tryChangeMovement() : void{
$this->checkObstruction($this->x, $this->y, $this->z);
parent::tryChangeMovement();
}

View File

@@ -50,7 +50,7 @@ class FallingBlock extends Entity{
public $canCollide = false;
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$blockId = 0;
@@ -83,7 +83,7 @@ class FallingBlock extends Entity{
return false;
}
public function attack(EntityDamageEvent $source){
public function attack(EntityDamageEvent $source) : void{
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($source);
}
@@ -126,15 +126,15 @@ class FallingBlock extends Entity{
return $hasUpdate;
}
public function getBlock(){
public function getBlock() : int{
return $this->block->getId();
}
public function getDamage(){
public function getDamage() : int{
return $this->block->getDamage();
}
public function saveNBT(){
public function saveNBT() : void{
$this->namedtag->setInt("TileID", $this->block->getId(), true);
$this->namedtag->setByte("Data", $this->block->getDamage());
}

View File

@@ -53,7 +53,7 @@ class ItemEntity extends Entity{
public $canCollide = false;
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
$this->setMaxHealth(5);
@@ -106,7 +106,7 @@ class ItemEntity extends Entity{
return $hasUpdate;
}
protected function tryChangeMovement(){
protected function tryChangeMovement() : void{
$this->checkObstruction($this->x, $this->y, $this->z);
parent::tryChangeMovement();
}
@@ -115,7 +115,7 @@ class ItemEntity extends Entity{
return true;
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setTag($this->item->nbtSerialize(-1, "Item"));
$this->namedtag->setShort("Health", (int) $this->getHealth());
@@ -154,7 +154,7 @@ class ItemEntity extends Entity{
/**
* @param int $delay
*/
public function setPickupDelay(int $delay){
public function setPickupDelay(int $delay) : void{
$this->pickupDelay = $delay;
}
@@ -168,7 +168,7 @@ class ItemEntity extends Entity{
/**
* @param string $owner
*/
public function setOwner(string $owner){
public function setOwner(string $owner) : void{
$this->owner = $owner;
}
@@ -182,7 +182,7 @@ class ItemEntity extends Entity{
/**
* @param string $thrower
*/
public function setThrower(string $thrower){
public function setThrower(string $thrower) : void{
$this->thrower = $thrower;
}
@@ -197,7 +197,7 @@ class ItemEntity extends Entity{
$player->dataPacket($pk);
}
public function onCollideWithPlayer(Player $player){
public function onCollideWithPlayer(Player $player) : void{
if($this->getPickupDelay() > 0){
return;
}

View File

@@ -70,13 +70,13 @@ class Painting extends Entity{
parent::__construct($level, $nbt);
}
protected function initEntity(){
protected function initEntity() : void{
$this->setMaxHealth(1);
$this->setHealth(1);
parent::initEntity();
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setInt("TileX", (int) $this->blockIn->x);
$this->namedtag->setInt("TileY", (int) $this->blockIn->y);
@@ -86,7 +86,7 @@ class Painting extends Entity{
$this->namedtag->setByte("Direction", (int) $this->direction); //Save both for full compatibility
}
public function kill(){
public function kill() : void{
parent::kill();
$drops = true;
@@ -138,7 +138,7 @@ class Painting extends Entity{
return false;
}
protected function updateMovement(bool $teleport = false){
protected function updateMovement(bool $teleport = false) : void{
}
@@ -166,7 +166,7 @@ class Painting extends Entity{
return PaintingMotive::getMotiveByName($this->motive);
}
public function getDirection() : int{
public function getDirection() : ?int{
return $this->direction;
}

View File

@@ -47,13 +47,13 @@ class PrimedTNT extends Entity implements Explosive{
public $canCollide = false;
public function attack(EntityDamageEvent $source){
public function attack(EntityDamageEvent $source) : void{
if($source->getCause() === EntityDamageEvent::CAUSE_VOID){
parent::attack($source);
}
}
protected function initEntity(){
protected function initEntity() : void{
parent::initEntity();
if($this->namedtag->hasTag("Fuse", ShortTag::class)){
@@ -73,7 +73,7 @@ class PrimedTNT extends Entity implements Explosive{
return false;
}
public function saveNBT(){
public function saveNBT() : void{
parent::saveNBT();
$this->namedtag->setShort("Fuse", $this->fuse, true); //older versions incorrectly saved this as a byte
}
@@ -101,7 +101,7 @@ class PrimedTNT extends Entity implements Explosive{
return $hasUpdate or $this->fuse >= 0;
}
public function explode(){
public function explode() : void{
$this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4));
if(!$ev->isCancelled()){