mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 10:53:05 +00:00
Added typehints and PhpDoc for events API
excluded blocks and entities events API to avoid merge conflicts
This commit is contained in:
@ -42,8 +42,8 @@ class CraftItemEvent extends Event implements Cancellable{
|
||||
|
||||
/**
|
||||
* @param Player $player
|
||||
* @param Item[] $input
|
||||
* @param Recipe $recipe
|
||||
* @param Item[] $input
|
||||
* @param Recipe $recipe
|
||||
*/
|
||||
public function __construct(Player $player, array $input, Recipe $recipe){
|
||||
$this->player = $player;
|
||||
@ -54,26 +54,23 @@ class CraftItemEvent extends Event implements Cancellable{
|
||||
/**
|
||||
* @return Item[]
|
||||
*/
|
||||
public function getInput(){
|
||||
$items = [];
|
||||
foreach($this->input as $i => $item){
|
||||
$items[$i] = clone $item;
|
||||
}
|
||||
|
||||
return $items;
|
||||
public function getInput() : array{
|
||||
return array_map(function(Item $item) : Item{
|
||||
return clone $item;
|
||||
}, $this->input);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Recipe
|
||||
*/
|
||||
public function getRecipe(){
|
||||
public function getRecipe() : Recipe{
|
||||
return $this->recipe;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
public function getPlayer() : Player{
|
||||
return $this->player;
|
||||
}
|
||||
}
|
||||
|
@ -31,57 +31,66 @@ use pocketmine\tile\Furnace;
|
||||
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $fuel;
|
||||
/** @var int */
|
||||
private $burnTime;
|
||||
/** @var bool */
|
||||
private $burning = true;
|
||||
|
||||
public function __construct(Furnace $furnace, Item $fuel, $burnTime){
|
||||
/**
|
||||
* @param Furnace $furnace
|
||||
* @param Item $fuel
|
||||
* @param int $burnTime
|
||||
*/
|
||||
public function __construct(Furnace $furnace, Item $fuel, int $burnTime){
|
||||
parent::__construct($furnace->getBlock());
|
||||
$this->fuel = $fuel;
|
||||
$this->burnTime = (int) $burnTime;
|
||||
$this->burnTime = $burnTime;
|
||||
$this->furnace = $furnace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Furnace
|
||||
*/
|
||||
public function getFurnace(){
|
||||
public function getFurnace() : Furnace{
|
||||
return $this->furnace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getFuel(){
|
||||
public function getFuel() : Item{
|
||||
return $this->fuel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getBurnTime(){
|
||||
public function getBurnTime() : int{
|
||||
return $this->burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $burnTime
|
||||
*/
|
||||
public function setBurnTime($burnTime){
|
||||
$this->burnTime = (int) $burnTime;
|
||||
public function setBurnTime(int $burnTime){
|
||||
$this->burnTime = $burnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isBurning(){
|
||||
public function isBurning() : bool{
|
||||
return $this->burning;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $burning
|
||||
*/
|
||||
public function setBurning($burning){
|
||||
$this->burning = (bool) $burning;
|
||||
public function setBurning(bool $burning){
|
||||
$this->burning = $burning;
|
||||
}
|
||||
}
|
@ -31,10 +31,18 @@ use pocketmine\tile\Furnace;
|
||||
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $source;
|
||||
/** @var Item */
|
||||
private $result;
|
||||
|
||||
/**
|
||||
* @param Furnace $furnace
|
||||
* @param Item $source
|
||||
* @param Item $result
|
||||
*/
|
||||
public function __construct(Furnace $furnace, Item $source, Item $result){
|
||||
parent::__construct($furnace->getBlock());
|
||||
$this->source = clone $source;
|
||||
@ -46,21 +54,21 @@ class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
/**
|
||||
* @return Furnace
|
||||
*/
|
||||
public function getFurnace(){
|
||||
public function getFurnace() : Furnace{
|
||||
return $this->furnace;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getSource(){
|
||||
public function getSource() : Item{
|
||||
return $this->source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getResult(){
|
||||
public function getResult() : Item{
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ class InventoryCloseEvent extends InventoryEvent{
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
public function getPlayer() : Player{
|
||||
return $this->who;
|
||||
}
|
||||
|
||||
|
@ -42,14 +42,14 @@ abstract class InventoryEvent extends Event{
|
||||
/**
|
||||
* @return Inventory
|
||||
*/
|
||||
public function getInventory(){
|
||||
public function getInventory() : Inventory{
|
||||
return $this->inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Human[]
|
||||
*/
|
||||
public function getViewers(){
|
||||
public function getViewers() : array{
|
||||
return $this->inventory->getViewers();
|
||||
}
|
||||
}
|
@ -45,7 +45,7 @@ class InventoryOpenEvent extends InventoryEvent implements Cancellable{
|
||||
/**
|
||||
* @return Player
|
||||
*/
|
||||
public function getPlayer(){
|
||||
public function getPlayer() : Player{
|
||||
return $this->who;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class InventoryPickupArrowEvent extends InventoryEvent implements Cancellable{
|
||||
/**
|
||||
* @return Arrow
|
||||
*/
|
||||
public function getArrow(){
|
||||
public function getArrow() : Arrow{
|
||||
return $this->arrow;
|
||||
}
|
||||
|
||||
|
@ -45,7 +45,7 @@ class InventoryPickupItemEvent extends InventoryEvent implements Cancellable{
|
||||
/**
|
||||
* @return Item
|
||||
*/
|
||||
public function getItem(){
|
||||
public function getItem() : Item{
|
||||
return $this->item;
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class InventoryTransactionEvent extends Event implements Cancellable{
|
||||
/**
|
||||
* @return TransactionGroup
|
||||
*/
|
||||
public function getTransaction(){
|
||||
public function getTransaction() : TransactionGroup{
|
||||
return $this->ts;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user