mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-08 02:42:58 +00:00
event: modernize property declarations where possible
only private fields are modified; protected ones can't be changed in case someone extended the classes
This commit is contained in:
@ -34,28 +34,17 @@ use pocketmine\player\Player;
|
||||
class CraftItemEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var CraftingTransaction */
|
||||
private $transaction;
|
||||
/** @var CraftingRecipe */
|
||||
private $recipe;
|
||||
/** @var int */
|
||||
private $repetitions;
|
||||
/** @var Item[] */
|
||||
private $inputs;
|
||||
/** @var Item[] */
|
||||
private $outputs;
|
||||
|
||||
/**
|
||||
* @param Item[] $inputs
|
||||
* @param Item[] $outputs
|
||||
*/
|
||||
public function __construct(CraftingTransaction $transaction, CraftingRecipe $recipe, int $repetitions, array $inputs, array $outputs){
|
||||
$this->transaction = $transaction;
|
||||
$this->recipe = $recipe;
|
||||
$this->repetitions = $repetitions;
|
||||
$this->inputs = $inputs;
|
||||
$this->outputs = $outputs;
|
||||
}
|
||||
public function __construct(
|
||||
private CraftingTransaction $transaction,
|
||||
private CraftingRecipe $recipe,
|
||||
private int $repetitions,
|
||||
private array $inputs,
|
||||
private array $outputs
|
||||
){}
|
||||
|
||||
/**
|
||||
* Returns the inventory transaction involved in this crafting event.
|
||||
|
@ -35,20 +35,14 @@ use pocketmine\item\Item;
|
||||
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $fuel;
|
||||
/** @var int */
|
||||
private $burnTime;
|
||||
/** @var bool */
|
||||
private $burning = true;
|
||||
private bool $burning = true;
|
||||
|
||||
public function __construct(Furnace $furnace, Item $fuel, int $burnTime){
|
||||
public function __construct(
|
||||
private Furnace $furnace,
|
||||
private Item $fuel,
|
||||
private int $burnTime
|
||||
){
|
||||
parent::__construct($furnace->getBlock());
|
||||
$this->fuel = $fuel;
|
||||
$this->burnTime = $burnTime;
|
||||
$this->furnace = $furnace;
|
||||
}
|
||||
|
||||
public function getFurnace() : Furnace{
|
||||
|
@ -32,19 +32,14 @@ use pocketmine\item\Item;
|
||||
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Furnace */
|
||||
private $furnace;
|
||||
/** @var Item */
|
||||
private $source;
|
||||
/** @var Item */
|
||||
private $result;
|
||||
|
||||
public function __construct(Furnace $furnace, Item $source, Item $result){
|
||||
public function __construct(
|
||||
private Furnace $furnace,
|
||||
private Item $source,
|
||||
private Item $result
|
||||
){
|
||||
parent::__construct($furnace->getBlock());
|
||||
$this->source = clone $source;
|
||||
$this->source->setCount(1);
|
||||
$this->result = $result;
|
||||
$this->furnace = $furnace;
|
||||
}
|
||||
|
||||
public function getFurnace() : Furnace{
|
||||
|
@ -27,11 +27,10 @@ use pocketmine\inventory\Inventory;
|
||||
use pocketmine\player\Player;
|
||||
|
||||
class InventoryCloseEvent extends InventoryEvent{
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
||||
public function __construct(Inventory $inventory, Player $who){
|
||||
$this->who = $who;
|
||||
public function __construct(
|
||||
Inventory $inventory,
|
||||
private Player $who
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,10 @@ use pocketmine\player\Player;
|
||||
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
||||
public function __construct(Inventory $inventory, Player $who){
|
||||
$this->who = $who;
|
||||
public function __construct(
|
||||
Inventory $inventory,
|
||||
private Player $who
|
||||
){
|
||||
parent::__construct($inventory);
|
||||
}
|
||||
|
||||
|
@ -35,12 +35,7 @@ use pocketmine\inventory\transaction\InventoryTransaction;
|
||||
class InventoryTransactionEvent extends Event implements Cancellable{
|
||||
use CancellableTrait;
|
||||
|
||||
/** @var InventoryTransaction */
|
||||
private $transaction;
|
||||
|
||||
public function __construct(InventoryTransaction $transaction){
|
||||
$this->transaction = $transaction;
|
||||
}
|
||||
public function __construct(private InventoryTransaction $transaction){}
|
||||
|
||||
public function getTransaction() : InventoryTransaction{
|
||||
return $this->transaction;
|
||||
|
Reference in New Issue
Block a user