Apply nullable and void typehints to events namespace

This commit is contained in:
Dylan K. Taylor 2018-06-11 13:49:16 +01:00
parent cfb10360ff
commit eb0276d459
34 changed files with 58 additions and 58 deletions

View File

@ -59,7 +59,7 @@ abstract class Event{
* *
* @throws \BadMethodCallException * @throws \BadMethodCallException
*/ */
public function setCancelled(bool $value = true){ public function setCancelled(bool $value = true) : void{
if(!($this instanceof Cancellable)){ if(!($this instanceof Cancellable)){
throw new \BadMethodCallException("Event is not Cancellable"); throw new \BadMethodCallException("Event is not Cancellable");
} }

View File

@ -92,7 +92,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
/** /**
* @param bool $instaBreak * @param bool $instaBreak
*/ */
public function setInstaBreak(bool $instaBreak){ public function setInstaBreak(bool $instaBreak) : void{
$this->instaBreak = $instaBreak; $this->instaBreak = $instaBreak;
} }
@ -107,7 +107,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
/** /**
* @param Item[] $drops * @param Item[] $drops
*/ */
public function setDrops(array $drops){ public function setDrops(array $drops) : void{
$this->setDropsVariadic(...$drops); $this->setDropsVariadic(...$drops);
} }
@ -116,7 +116,7 @@ class BlockBreakEvent extends BlockEvent implements Cancellable{
* *
* @param Item ...$drops * @param Item ...$drops
*/ */
public function setDropsVariadic(Item ...$drops){ public function setDropsVariadic(Item ...$drops) : void{
$this->blockDrops = $drops; $this->blockDrops = $drops;
} }

View File

@ -81,7 +81,7 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
* *
* @throws \InvalidArgumentException if there are more or less than 4 lines in the passed array * @throws \InvalidArgumentException if there are more or less than 4 lines in the passed array
*/ */
public function setLines(array $lines){ public function setLines(array $lines) : void{
if(count($lines) !== 4){ if(count($lines) !== 4){
throw new \InvalidArgumentException("Array size must be 4!"); throw new \InvalidArgumentException("Array size must be 4!");
} }
@ -94,7 +94,7 @@ class SignChangeEvent extends BlockEvent implements Cancellable{
* *
* @throws \InvalidArgumentException if the index is out of bounds * @throws \InvalidArgumentException if the index is out of bounds
*/ */
public function setLine(int $index, string $line){ public function setLine(int $index, string $line) : void{
if($index < 0 or $index > 3){ if($index < 0 or $index > 3){
throw new \InvalidArgumentException("Index must be in the range 0-3!"); throw new \InvalidArgumentException("Index must be in the range 0-3!");
} }

View File

@ -46,7 +46,7 @@ class EntityCombustEvent extends EntityEvent implements Cancellable{
return $this->duration; return $this->duration;
} }
public function setDuration(int $duration){ public function setDuration(int $duration) : void{
$this->duration = $duration; $this->duration = $duration;
} }
} }

View File

@ -50,7 +50,7 @@ class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
* *
* @return Entity|null * @return Entity|null
*/ */
public function getChild(){ public function getChild() : ?Entity{
return $this->getEntity()->getLevel()->getServer()->findEntity($this->childEntityEid, $this->getEntity()->getLevel()); return $this->getEntity()->getLevel()->getServer()->findEntity($this->childEntityEid, $this->getEntity()->getLevel());
} }
} }

View File

@ -51,7 +51,7 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{
$this->addAttackerModifiers($damager); $this->addAttackerModifiers($damager);
} }
protected function addAttackerModifiers(Entity $damager){ protected function addAttackerModifiers(Entity $damager) : void{
if($damager instanceof Living){ //TODO: move this to entity classes if($damager instanceof Living){ //TODO: move this to entity classes
if($damager->hasEffect(Effect::STRENGTH)){ if($damager->hasEffect(Effect::STRENGTH)){
$this->setModifier($this->getBaseDamage() * 0.3 * $damager->getEffect(Effect::STRENGTH)->getEffectLevel(), self::MODIFIER_STRENGTH); $this->setModifier($this->getBaseDamage() * 0.3 * $damager->getEffect(Effect::STRENGTH)->getEffectLevel(), self::MODIFIER_STRENGTH);
@ -68,7 +68,7 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{
* *
* @return Entity|null * @return Entity|null
*/ */
public function getDamager(){ public function getDamager() : ?Entity{
return $this->getEntity()->getLevel()->getServer()->findEntity($this->damagerEntityId, $this->getEntity()->getLevel()); return $this->getEntity()->getLevel()->getServer()->findEntity($this->damagerEntityId, $this->getEntity()->getLevel());
} }
@ -82,7 +82,7 @@ class EntityDamageByEntityEvent extends EntityDamageEvent{
/** /**
* @param float $knockBack * @param float $knockBack
*/ */
public function setKnockBack(float $knockBack){ public function setKnockBack(float $knockBack) : void{
$this->knockBack = $knockBack; $this->knockBack = $knockBack;
} }
} }

View File

@ -156,7 +156,7 @@ class EntityDamageEvent extends EntityEvent implements Cancellable{
* @param float $damage * @param float $damage
* @param int $type * @param int $type
*/ */
public function setModifier(float $damage, int $type){ public function setModifier(float $damage, int $type) : void{
$this->modifiers[$type] = $damage; $this->modifiers[$type] = $damage;
} }

View File

@ -56,7 +56,7 @@ class EntityDeathEvent extends EntityEvent{
/** /**
* @param Item[] $drops * @param Item[] $drops
*/ */
public function setDrops(array $drops){ public function setDrops(array $drops) : void{
$this->drops = $drops; $this->drops = $drops;
} }
} }

View File

@ -62,7 +62,7 @@ class EntityEffectAddEvent extends EntityEffectEvent{
/** /**
* @return EffectInstance|null * @return EffectInstance|null
*/ */
public function getOldEffect(){ public function getOldEffect() : ?EffectInstance{
return $this->oldEffect; return $this->oldEffect;
} }
} }

View File

@ -27,7 +27,7 @@ namespace pocketmine\event\entity;
* Called when an effect is removed from an entity. * Called when an effect is removed from an entity.
*/ */
class EntityEffectRemoveEvent extends EntityEffectEvent{ class EntityEffectRemoveEvent extends EntityEffectEvent{
public function setCancelled(bool $value = true){ public function setCancelled(bool $value = true) : void{
if($this->getEffect()->getDuration() <= 0){ if($this->getEffect()->getDuration() <= 0){
throw new \InvalidStateException("Removal of expired effects cannot be cancelled"); throw new \InvalidStateException("Removal of expired effects cannot be cancelled");
} }

View File

@ -73,7 +73,7 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
/** /**
* @param Block[] $blocks * @param Block[] $blocks
*/ */
public function setBlockList(array $blocks){ public function setBlockList(array $blocks) : void{
$this->blocks = $blocks; $this->blocks = $blocks;
} }
@ -87,7 +87,7 @@ class EntityExplodeEvent extends EntityEvent implements Cancellable{
/** /**
* @param float $yield * @param float $yield
*/ */
public function setYield(float $yield){ public function setYield(float $yield) : void{
$this->yield = $yield; $this->yield = $yield;
} }
} }

View File

@ -64,7 +64,7 @@ class EntityInventoryChangeEvent extends EntityEvent implements Cancellable{
/** /**
* @param Item $item * @param Item $item
*/ */
public function setNewItem(Item $item){ public function setNewItem(Item $item) : void{
$this->newItem = $item; $this->newItem = $item;
} }

View File

@ -60,7 +60,7 @@ class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
/** /**
* @param float $amount * @param float $amount
*/ */
public function setAmount(float $amount){ public function setAmount(float $amount) : void{
$this->amount = $amount; $this->amount = $amount;
} }

View File

@ -78,7 +78,7 @@ class EntityShootBowEvent extends EntityEvent implements Cancellable{
/** /**
* @param Entity $projectile * @param Entity $projectile
*/ */
public function setProjectile(Entity $projectile){ public function setProjectile(Entity $projectile) : void{
if($projectile !== $this->projectile){ if($projectile !== $this->projectile){
if(count($this->projectile->getViewers()) === 0){ if(count($this->projectile->getViewers()) === 0){
$this->projectile->close(); $this->projectile->close();
@ -97,7 +97,7 @@ class EntityShootBowEvent extends EntityEvent implements Cancellable{
/** /**
* @param float $force * @param float $force
*/ */
public function setForce(float $force){ public function setForce(float $force) : void{
$this->force = $force; $this->force = $force;
} }
} }

View File

@ -56,7 +56,7 @@ class EntityTeleportEvent extends EntityEvent implements Cancellable{
/** /**
* @param Position $to * @param Position $to
*/ */
public function setTo(Position $to){ public function setTo(Position $to) : void{
$this->to = $to; $this->to = $to;
} }
} }

View File

@ -52,7 +52,7 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
return $this->force; return $this->force;
} }
public function setForce(float $force){ public function setForce(float $force) : void{
$this->force = $force; $this->force = $force;
} }
@ -66,7 +66,7 @@ class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
/** /**
* @param bool $affectsBlocks * @param bool $affectsBlocks
*/ */
public function setBlockBreaking(bool $affectsBlocks){ public function setBlockBreaking(bool $affectsBlocks) : void{
$this->blockBreaking = $affectsBlocks; $this->blockBreaking = $affectsBlocks;
} }
} }

View File

@ -74,7 +74,7 @@ class FurnaceBurnEvent extends BlockEvent implements Cancellable{
/** /**
* @param int $burnTime * @param int $burnTime
*/ */
public function setBurnTime(int $burnTime){ public function setBurnTime(int $burnTime) : void{
$this->burnTime = $burnTime; $this->burnTime = $burnTime;
} }
@ -88,7 +88,7 @@ class FurnaceBurnEvent extends BlockEvent implements Cancellable{
/** /**
* @param bool $burning * @param bool $burning
*/ */
public function setBurning(bool $burning){ public function setBurning(bool $burning) : void{
$this->burning = $burning; $this->burning = $burning;
} }
} }

View File

@ -73,7 +73,7 @@ class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
/** /**
* @param Item $result * @param Item $result
*/ */
public function setResult(Item $result){ public function setResult(Item $result) : void{
$this->result = $result; $this->result = $result;
} }
} }

View File

@ -77,7 +77,7 @@ abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
/** /**
* @param Item $item * @param Item $item
*/ */
public function setItem(Item $item){ public function setItem(Item $item) : void{
$this->item = $item; $this->item = $item;
} }

View File

@ -71,7 +71,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $message * @param string $message
*/ */
public function setMessage(string $message){ public function setMessage(string $message) : void{
$this->message = $message; $this->message = $message;
} }
@ -80,7 +80,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
* *
* @param Player $player * @param Player $player
*/ */
public function setPlayer(Player $player){ public function setPlayer(Player $player) : void{
$this->player = $player; $this->player = $player;
} }
@ -94,7 +94,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $format * @param string $format
*/ */
public function setFormat(string $format){ public function setFormat(string $format) : void{
$this->format = $format; $this->format = $format;
} }
@ -108,7 +108,7 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{
/** /**
* @param Player[] $recipients * @param Player[] $recipients
*/ */
public function setRecipients(array $recipients){ public function setRecipients(array $recipients) : void{
$this->recipients = $recipients; $this->recipients = $recipients;
} }
} }

View File

@ -58,14 +58,14 @@ class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $message * @param string $message
*/ */
public function setMessage(string $message){ public function setMessage(string $message) : void{
$this->message = $message; $this->message = $message;
} }
/** /**
* @param Player $player * @param Player $player
*/ */
public function setPlayer(Player $player){ public function setPlayer(Player $player) : void{
$this->player = $player; $this->player = $player;
} }
} }

View File

@ -54,7 +54,7 @@ class PlayerDataSaveEvent extends Event implements Cancellable{
/** /**
* @param CompoundTag $data * @param CompoundTag $data
*/ */
public function setSaveData(CompoundTag $data){ public function setSaveData(CompoundTag $data) : void{
$this->data = $data; $this->data = $data;
} }

View File

@ -70,7 +70,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
/** /**
* @param TextContainer|string $deathMessage * @param TextContainer|string $deathMessage
*/ */
public function setDeathMessage($deathMessage){ public function setDeathMessage($deathMessage) : void{
$this->deathMessage = $deathMessage; $this->deathMessage = $deathMessage;
} }
@ -78,7 +78,7 @@ class PlayerDeathEvent extends EntityDeathEvent{
return $this->keepInventory; return $this->keepInventory;
} }
public function setKeepInventory(bool $keepInventory){ public function setKeepInventory(bool $keepInventory) : void{
$this->keepInventory = $keepInventory; $this->keepInventory = $keepInventory;
} }
} }

View File

@ -66,7 +66,7 @@ class PlayerExhaustEvent extends EntityEvent implements Cancellable{
return $this->amount; return $this->amount;
} }
public function setAmount(float $amount){ public function setAmount(float $amount) : void{
$this->amount = $amount; $this->amount = $amount;
} }

View File

@ -47,7 +47,7 @@ class PlayerJoinEvent extends PlayerEvent{
/** /**
* @param string|TextContainer $joinMessage * @param string|TextContainer $joinMessage
*/ */
public function setJoinMessage($joinMessage){ public function setJoinMessage($joinMessage) : void{
$this->joinMessage = $joinMessage; $this->joinMessage = $joinMessage;
} }

View File

@ -57,7 +57,7 @@ class PlayerKickEvent extends PlayerEvent implements Cancellable{
/** /**
* @param TextContainer|string $quitMessage * @param TextContainer|string $quitMessage
*/ */
public function setQuitMessage($quitMessage){ public function setQuitMessage($quitMessage) : void{
$this->quitMessage = $quitMessage; $this->quitMessage = $quitMessage;
} }

View File

@ -45,7 +45,7 @@ class PlayerLoginEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $kickMessage * @param string $kickMessage
*/ */
public function setKickMessage(string $kickMessage){ public function setKickMessage(string $kickMessage) : void{
$this->kickMessage = $kickMessage; $this->kickMessage = $kickMessage;
} }

View File

@ -61,7 +61,7 @@ class PlayerMoveEvent extends PlayerEvent implements Cancellable{
/** /**
* @param Location $to * @param Location $to
*/ */
public function setTo(Location $to){ public function setTo(Location $to) : void{
$this->to = $to; $this->to = $to;
} }
} }

View File

@ -45,7 +45,7 @@ class PlayerPreLoginEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $kickMessage * @param string $kickMessage
*/ */
public function setKickMessage(string $kickMessage){ public function setKickMessage(string $kickMessage) : void{
$this->kickMessage = $kickMessage; $this->kickMessage = $kickMessage;
} }

View File

@ -50,7 +50,7 @@ class PlayerQuitEvent extends PlayerEvent{
/** /**
* @param TranslationContainer|string $quitMessage * @param TranslationContainer|string $quitMessage
*/ */
public function setQuitMessage($quitMessage){ public function setQuitMessage($quitMessage) : void{
$this->quitMessage = $quitMessage; $this->quitMessage = $quitMessage;
} }

View File

@ -52,7 +52,7 @@ class PlayerRespawnEvent extends PlayerEvent{
/** /**
* @param Position $position * @param Position $position
*/ */
public function setRespawnPosition(Position $position){ public function setRespawnPosition(Position $position) : void{
$this->position = $position; $this->position = $position;
} }
} }

View File

@ -57,7 +57,7 @@ class PlayerTransferEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $address * @param string $address
*/ */
public function setAddress(string $address){ public function setAddress(string $address) : void{
$this->address = $address; $this->address = $address;
} }
@ -71,7 +71,7 @@ class PlayerTransferEvent extends PlayerEvent implements Cancellable{
/** /**
* @param int $port * @param int $port
*/ */
public function setPort(int $port){ public function setPort(int $port) : void{
$this->port = $port; $this->port = $port;
} }
@ -85,7 +85,7 @@ class PlayerTransferEvent extends PlayerEvent implements Cancellable{
/** /**
* @param string $message * @param string $message
*/ */
public function setMessage(string $message){ public function setMessage(string $message) : void{
$this->message = $message; $this->message = $message;
} }
} }

View File

@ -105,7 +105,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param int $timeout * @param int $timeout
*/ */
public function setTimeout(int $timeout){ public function setTimeout(int $timeout) : void{
$this->timeout = $timeout; $this->timeout = $timeout;
} }
@ -119,7 +119,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param string $serverName * @param string $serverName
*/ */
public function setServerName(string $serverName){ public function setServerName(string $serverName) : void{
$this->serverName = $serverName; $this->serverName = $serverName;
} }
@ -133,7 +133,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param bool $value * @param bool $value
*/ */
public function setListPlugins(bool $value){ public function setListPlugins(bool $value) : void{
$this->listPlugins = $value; $this->listPlugins = $value;
} }
@ -147,7 +147,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param Plugin[] $plugins * @param Plugin[] $plugins
*/ */
public function setPlugins(array $plugins){ public function setPlugins(array $plugins) : void{
$this->plugins = $plugins; $this->plugins = $plugins;
} }
@ -161,7 +161,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param Player[] $players * @param Player[] $players
*/ */
public function setPlayerList(array $players){ public function setPlayerList(array $players) : void{
$this->players = $players; $this->players = $players;
} }
@ -175,7 +175,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param int $count * @param int $count
*/ */
public function setPlayerCount(int $count){ public function setPlayerCount(int $count) : void{
$this->numPlayers = $count; $this->numPlayers = $count;
} }
@ -189,7 +189,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param int $count * @param int $count
*/ */
public function setMaxPlayerCount(int $count){ public function setMaxPlayerCount(int $count) : void{
$this->maxPlayers = $count; $this->maxPlayers = $count;
} }
@ -203,7 +203,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param string $world * @param string $world
*/ */
public function setWorld(string $world){ public function setWorld(string $world) : void{
$this->map = $world; $this->map = $world;
} }
@ -219,7 +219,7 @@ class QueryRegenerateEvent extends ServerEvent{
/** /**
* @param array $extraData * @param array $extraData
*/ */
public function setExtraData(array $extraData){ public function setExtraData(array $extraData) : void{
$this->extraData = $extraData; $this->extraData = $extraData;
} }

View File

@ -67,7 +67,7 @@ class ServerCommandEvent extends ServerEvent implements Cancellable{
/** /**
* @param string $command * @param string $command
*/ */
public function setCommand(string $command){ public function setCommand(string $command) : void{
$this->command = $command; $this->command = $command;
} }
} }